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

CONTAINS STRING

Former Member
0 Likes
4,162

hi friends,

i have one urgent issue.

in my internal table, i hav one field status with value 'PREL'.

i have one more record with status value 'REL'.

so, the problem here is - when i want to display the record containing value 'REL',

the record with value 'PREL' is also getting picked up.

here, all the other records with statuses 'CRTD', 'MSPT' are getting deleted.

the code i'm using is:

delete t_final where status ns l_status.

Please suggest me some solution for this..

An early reply could be of great help and deserve great reward.

Thanks,

Praveen

1 ACCEPTED SOLUTION
Read only

h_senden2
Active Contributor
0 Likes
4,045

You can use CS

CS (Contains String):

c1 contains the character string c2.

Trailing blanks in c1 and c2 are ignored if the respective field is of type C.

An empty string c2 (i.e., only blanks with type C, or empty string with type STRING) is included in any string c1, including the empty string itself. On the other hand, there is no non-empty string c2 included in an empty string c1.

If the result of the comparison is positive, the system field SY-FDPOS contains the offset of the first character of c2 in c1.

If the result of the comparison is negative, the system field SY-FDPOS contains the length of c1.

The comparison is not case-sensitive.

regards,

Hans

Please reward all helpful answers !!!!!

8 REPLIES 8
Read only

Former Member
0 Likes
4,045

Hi

Try this:

PARAMETERS: P(4).

DATA: STRING(3) VALUE 'REL'.

IF P CS STRING. WRITE P. ENDIF.

Max

Read only

h_senden2
Active Contributor
0 Likes
4,046

You can use CS

CS (Contains String):

c1 contains the character string c2.

Trailing blanks in c1 and c2 are ignored if the respective field is of type C.

An empty string c2 (i.e., only blanks with type C, or empty string with type STRING) is included in any string c1, including the empty string itself. On the other hand, there is no non-empty string c2 included in an empty string c1.

If the result of the comparison is positive, the system field SY-FDPOS contains the offset of the first character of c2 in c1.

If the result of the comparison is negative, the system field SY-FDPOS contains the length of c1.

The comparison is not case-sensitive.

regards,

Hans

Please reward all helpful answers !!!!!

Read only

Former Member
0 Likes
4,045

hi

if it's only that u have to draw a line between PREL and REL..then u could do something like this

just add a field value in your itab...set flag for all the records with status PREL..and then change your del condition as below

data val(1) value 'X'.

MODIFY t_final TRANSPORTING val where status eq 'PREL'.

delete t_final where status ns l_status and val ne 'X'.

if helpful, reward

Sathish. R

Message was edited by:

Sathish R

Read only

0 Likes
4,045

actually its not just 'REL' or 'PREL'.

its like 1. CRTD MSPT REL.

2. DLV TECO PREL.

in these records i need to delete the 2nd record.

Hope you got it right now.

Thanks,

Praveen.

Read only

0 Likes
4,045

hi

u want to delete the 2nd record, right? then, just change the status to REL

MODIFY t_final TRANSPORTING val where status eq 'REL'.

delete t_final where status ns l_status and val ne 'X'.

if helpful, reward

Sathish. R

Read only

0 Likes
4,045

Hi

DATA: BEGIN OF ITAB OCCURS 0,

STATUS(4),

END OF ITAB.

DATA: WA(50) VALUE 'CRTD MSPT REL'.

SPLIT WA AT SPACE INTO TABLE ITAB.

LOOP AT ITAB WHERE STATUS = 'REL'.

EXIT.

ENDLOOP.

IF SY-SUBRC = 0. WRITE 'OK'. ENDIF.

Max

Read only

Former Member
0 Likes
4,045

Hi!

In ur code write NP instead of NS.

Check n reply if it works.

Reward points if it helps.

Regards,

Neha Bansal.

Read only

Former Member
0 Likes
4,045

hi friends,

really thanks for your help.

Max - i have followed your logic of course not the entire idea but copying it into one ITAB and using it as per my requirement.

Thanks a lot friends,

Praveen