Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding including 'Find' in a table control

Former Member
0 Kudos
119

Hi Experts,

I want to include a Find & Find Next functionality in my table control wherein there should be a popup in which I can enter a string and match that string with values in the internal table .The row which contains the value should become the first row with cursor on it.

Please suggest any standard function module or a way to implement the same.

Thanks & Regards,

Garima

1 ACCEPTED SOLUTION

Former Member
0 Kudos
79

hi,

I have same senario and this is the code....

I have two buttons FIND and FINDN.......

Now in user command of first screen's PAI

WHEN 'FIND'.

CALL SCREEN 0100 STARTING AT 37 5 ENDING AT 87 22.

WHEN 'FINDN'.

IF strin <> ''.

f = 1.

CALL SCREEN 9000.

ENDIF.

0100 is my screen in which i am entering my string which i want to find from table control

now in user command of that screen write

MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'OK'.

CALL SCREEN 9000.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

9000 is my main screen having table control..

now there is one module in which u fetching data into internal table in PBO.

write there like...

MODULE itab_fetch OUTPUT.

SELECT maramatnr maktmaktx marc~werks INTO CORRESPONDING FIELDS OF TABLE itab

FROM mara INNER JOIN makt ON

maramatnr = maktmatnr

INNER JOIN marc ON

maramatnr = marcmatnr

WHERE marcwerks IN werks AND maramatnr IN matno.

IF strin IS NOT INITIAL AND f <> 1.

wa_itab-mark = 'X'.

LOOP AT itab.

IF itab-matnr = strin OR itab-werks = strin.

line1 = sy-tabix.

EXIT.

ENDIF.

ENDLOOP.

IF line1 <> 0.

MODIFY itab INDEX line1 FROM wa_itab TRANSPORTING mark.

SET CURSOR LINE line1.

tab1-top_line = line1.

a = line1.

ENDIF.

ENDIF.

IF f = 1.

wa_itab-mark = 'X'.

LOOP AT itab.

IF itab-matnr = strin OR itab-werks = strin.

line-line2 = sy-tabix.

APPEND line.

ENDIF.

ENDLOOP.

LOOP AT line.

lines = line-line2.

ENDLOOP.

LOOP AT line.

IF line-line2 > a.

line_1 = line-line2.

MODIFY itab INDEX line_1 FROM wa_itab TRANSPORTING mark.

SET CURSOR LINE line_1.

tab1-top_line = line_1.

a = line_1.

EXIT.

ENDIF.

ENDLOOP.

ENDIF.

ENDMODULE. " itab_fetch OUTPUT

And this is data declaration

DATA:BEGIN OF line OCCURS 0,

line2 TYPE int4,

END OF line.

DATA: strin(15) TYPE c,

line1 TYPE int4,

lines TYPE int4,

ok_code LIKE sy-ucomm,

save_code LIKE ok_code,

op LIKE ok_code,

a TYPE int4,

line_1 TYPE int4.

reward if useful ...

3 REPLIES 3

Former Member
0 Kudos
79

using search syntax used for Find table value.

logic.

loop at table cotol value.

search.

read sy-index.

place cursor.

endloop.

WHEN 'FIND'.

CLEAR: ITAB_FIELDS. REFRESH: ITAB_FIELDS[].

ITAB_FIELDS-TABNAME = 'RSEDD0'.

ITAB_FIELDS-FIELDNAME = 'FIELDNAME'.

ITAB_FIELDS-NOVALUEHLP = 'X'.

APPEND ITAB_FIELDS.

CALL FUNCTION 'POPUP_GET_VALUES'

EXPORTING

POPUP_TITLE = '&#25991;&#23383;&#21015;&#26908;&#32034;'

IMPORTING

RETURNCODE = IRETURN

TABLES

FIELDS = ITAB_FIELDS.

LOOP AT ITAB_FIELDS WHERE FIELDNAME = 'FIELDNAME'.

TARGET_VAL = ITAB_FIELDS-VALUE.

ENDLOOP.

CLEAR : SY-TABIX.

SEARCH GT_ZNJNFI_FJPDAT FOR TARGET_VAL." AND MARK.

IF SY-SUBRC = 0.

TARGET_LINE = SY-TABIX.

TAB_100-TOP_LINE = SY-TABIX.

ELSE.

MESSAGE S000 WITH '&#25991;&#23383;&#21015;' TARGET_VAL '&#12364;&#35211;&#12388;&#12363;&#12426;&#12414;&#12379;&#12435;'.

ENDIF.

WHEN 'FIND_NEXT'.

SY-TABIX = TARGET_LINE + 1.

SEARCH GT_ZNJNFI_FJPDAT FOR TARGET_VAL STARTING AT SY-TABIX.

IF SY-SUBRC = 0.

TARGET_LINE = SY-TABIX.

TAB_100-TOP_LINE = SY-TABIX.

ELSE.

MESSAGE S000 WITH '&#25991;&#23383;&#21015;' TARGET_VAL '&#12364;&#35211;&#12388;&#12363;&#12426;&#12414;&#12379;&#12435;'.

ENDIF.

ENDCASE.

Former Member
0 Kudos
80

hi,

I have same senario and this is the code....

I have two buttons FIND and FINDN.......

Now in user command of first screen's PAI

WHEN 'FIND'.

CALL SCREEN 0100 STARTING AT 37 5 ENDING AT 87 22.

WHEN 'FINDN'.

IF strin <> ''.

f = 1.

CALL SCREEN 9000.

ENDIF.

0100 is my screen in which i am entering my string which i want to find from table control

now in user command of that screen write

MODULE user_command_0100 INPUT.

CASE sy-ucomm.

WHEN 'OK'.

CALL SCREEN 9000.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

9000 is my main screen having table control..

now there is one module in which u fetching data into internal table in PBO.

write there like...

MODULE itab_fetch OUTPUT.

SELECT maramatnr maktmaktx marc~werks INTO CORRESPONDING FIELDS OF TABLE itab

FROM mara INNER JOIN makt ON

maramatnr = maktmatnr

INNER JOIN marc ON

maramatnr = marcmatnr

WHERE marcwerks IN werks AND maramatnr IN matno.

IF strin IS NOT INITIAL AND f <> 1.

wa_itab-mark = 'X'.

LOOP AT itab.

IF itab-matnr = strin OR itab-werks = strin.

line1 = sy-tabix.

EXIT.

ENDIF.

ENDLOOP.

IF line1 <> 0.

MODIFY itab INDEX line1 FROM wa_itab TRANSPORTING mark.

SET CURSOR LINE line1.

tab1-top_line = line1.

a = line1.

ENDIF.

ENDIF.

IF f = 1.

wa_itab-mark = 'X'.

LOOP AT itab.

IF itab-matnr = strin OR itab-werks = strin.

line-line2 = sy-tabix.

APPEND line.

ENDIF.

ENDLOOP.

LOOP AT line.

lines = line-line2.

ENDLOOP.

LOOP AT line.

IF line-line2 > a.

line_1 = line-line2.

MODIFY itab INDEX line_1 FROM wa_itab TRANSPORTING mark.

SET CURSOR LINE line_1.

tab1-top_line = line_1.

a = line_1.

EXIT.

ENDIF.

ENDLOOP.

ENDIF.

ENDMODULE. " itab_fetch OUTPUT

And this is data declaration

DATA:BEGIN OF line OCCURS 0,

line2 TYPE int4,

END OF line.

DATA: strin(15) TYPE c,

line1 TYPE int4,

lines TYPE int4,

ok_code LIKE sy-ucomm,

save_code LIKE ok_code,

op LIKE ok_code,

a TYPE int4,

line_1 TYPE int4.

reward if useful ...

0 Kudos
79

Thanks a lot!!