+ -

Pages

Saturday, July 26, 2014

Free text search in a field in a internal table

FUNCTION SEARCH_TEXT_IN_TABLE

Inputparametre:
  • TABLE (general table with header line)
  • FIELDNAME (Name of field that shoul be searched incl. name of table)
  • SEARCH (Teaxt that should be searched for
Returparametre:
  • RESULT (The text from field tht has been found)
  • RESULT_INDEX (Record number. 0, if not found)

field-symbols: <f>
data: txt(500) type c.

assign (FIELDNAME) to <f>.
clear RESULT_INDEX.
translate SEARCH to upper case.
loop at TABLE.
move <f> to txt.
translate txt to upper case.
if <f> cs SEARCH.
move <f> to RESULT.
move sy-tabix to RESULT_INDEX.
exit.
endif.
endloop
5 ABAP Tips: Free text search in a field in a internal table FUNCTION SEARCH_TEXT_IN_TABLE Inputparametre: TABLE (general table with header line) FIELDNAME (Name of field that shoul be searched in...

No comments:

Post a Comment

< >