‎2009 Jun 10 4:39 PM
Hi,
I have a 3 recordslike
1) '*********break adfljsdalfj jalsfdjsladj'
2) '$$$$$$$$$breakfast***********
3) '********break#************'
I have an input field like 'break'
when i have search for those records with 'break' then requires to pick only 1st and 3rd record
i have tried with SEARCH and FIND commands ...But iam unable to get those required records
please advise on this....
Thanks&Regards
ramesh
‎2009 Jun 11 8:27 AM
Hi,
Use the below code.
DATA: v_position TYPE sy-fdpos,
v_alpha(52).
DATA: BEGIN OF itab OCCURS 0,
text(100),
END OF itab.
v_alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.
itab-text = '*********break adfljsdalfj jalsfdjsladj'.
APPEND itab.
CLEAR itab.
itab-text = '$$$$$$$$$breakfast***********'.
APPEND itab.
CLEAR itab.
itab-text = '********break#************'.
APPEND itab.
CLEAR itab.
LOOP AT itab.
CLEAR v_position.
SEARCH itab-text FOR 'break' IN CHARACTER MODE.
IF sy-subrc = 0.
v_position = sy-fdpos + 5.
IF itab-text+v_position(1) = ' ' OR
NOT itab-text+v_position(1) CO v_alpha.
WRITE: itab-text.
ENDIF.
ENDIF.
ENDLOOP.
Regards,
Kumar Bandanadham
‎2009 Jun 10 5:17 PM
Hi,
You can use the operator CP (Contains Pattern).
With regards,
Vamsi
‎2009 Jun 10 5:19 PM
‎2009 Jun 10 5:28 PM
Hi,
You can use regular expressions
FIND REGEX '\<break\>' IN v_char.In the abap help, you will find the documentation for REGEX statement:
Start and end of a word
The operator \< fits at the start of a word and the operator \> fits at the end of a word. ... . A word is defined as an uninterrupted sequence of alphanumeric characters.
Regards
Darley
‎2009 Jun 11 8:27 AM
Hi,
Use the below code.
DATA: v_position TYPE sy-fdpos,
v_alpha(52).
DATA: BEGIN OF itab OCCURS 0,
text(100),
END OF itab.
v_alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.
itab-text = '*********break adfljsdalfj jalsfdjsladj'.
APPEND itab.
CLEAR itab.
itab-text = '$$$$$$$$$breakfast***********'.
APPEND itab.
CLEAR itab.
itab-text = '********break#************'.
APPEND itab.
CLEAR itab.
LOOP AT itab.
CLEAR v_position.
SEARCH itab-text FOR 'break' IN CHARACTER MODE.
IF sy-subrc = 0.
v_position = sy-fdpos + 5.
IF itab-text+v_position(1) = ' ' OR
NOT itab-text+v_position(1) CO v_alpha.
WRITE: itab-text.
ENDIF.
ENDIF.
ENDLOOP.
Regards,
Kumar Bandanadham