Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Regarding including 'Find' in a table control

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

Tags:
Former Member
Former Member replied

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 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question