Skip to Content
Former Member
Jan 12, 2017 at 05:11 AM

To search a string or part of a string in internal table


Hi all

I have a requirement to search if a particular text exists in my ztable field (case_category_text) and to display the row details of that field.

This is my ztable:



I have a module pool screen where there is a input text field and when the user enters the whole case category text name or a part of the case category text (For eg: if 'Manuel Automatisk text' is the cas_category_text; user can enter the whole Manuel Automatisk Text to search or any one work out of all like Manuel*text), I should display the corresponding work_package assigned to it in my ztable.

It is same as how we search for a report in SE38, where we enter ZR*module* and SAP displays all the program name which has 'ZR' and 'module' in it after we press F4. I did my coding without thinking of '*' and it was told by the users later that they will search the text with '*'.

Here is my coding. But it just searches the whole text or a part of it and it doesnot work fine if user enters the text to search as Manuel*text as explained above.

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S32 { color: #3399FF; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

SELECT case_category_text workpackage_title
FROM zworkpackage_cus INTO TABLE lt_searchwp.
IF sy-subrc = 0.
LOOP AT lt_searchwp INTO ls_searchwp WHERE
case_category_text = gv_cctxt OR case_category_text CS gv_cctxt.
ls_wrkpack-workpackage_title = ls_searchwp-workpackage_title.
APPEND ls_wrkpack TO lt_wrkpack.
CLEAR: ls_wrkpack, ls_searchwp.


***gv_cctxt is the search text which user enters.

***lt_wrkpack internal table contains all the work packages in which the search text exits

Please help.