Application Development and Automation 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: 
Read only

Reg string identification

Former Member
0 Likes
602

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
581

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

4 REPLIES 4
Read only

former_member219399
Active Participant
0 Likes
581

Hi,

You can use the operator CP (Contains Pattern).

With regards,

Vamsi

Read only

Former Member
0 Likes
581

Do CS on the variable for value as '*break'

~Nanda

Read only

Former Member
0 Likes
581

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

Read only

Former Member
0 Likes
582

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