Application Development 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: 

Finding Specific Text within a string

Former Member
0 Kudos

I have an internal table with a comments field defined as a string.

An example of the contents could be :-

Sickness Insurance; Payment fund; Compensation

or

Payment fund; Compensation; Medical Cover

What I am trying to do, is when looping through the internal table, if Payment Fund exists anywhere within the string, I need to remove the words 'Payment Funds' from the string.

Hope this makes sense.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

One solution can be :

Loop at itab.

if itab-field1 CS 'Payment Fund'.

replace 'Payment Funds' by space.

endif.

endloop,

Hope this would be helpful.

Regards,

Lalit

4 REPLIES 4

Former Member
0 Kudos

loop at itab.

replace all occurances of 'Payment fund' in itab-string with space ignoring case.

condense itab-string.

modify itab index sy-tabix.

endloop.

hope that make sense

Former Member
0 Kudos

Hi,

One solution can be :

Loop at itab.

if itab-field1 CS 'Payment Fund'.

replace 'Payment Funds' by space.

endif.

endloop,

Hope this would be helpful.

Regards,

Lalit

kesavadas_thekkillath
Active Contributor
0 Kudos

wk_val = 'Payment fund;' <--"include semi-colon here

wk_val1 = 'Sickness Insurance;' <--"include semi-colon here

guess your words in the fields are seperated by semi-colons

loop at itab.

if itab-fields CS wk_val..

replace all occurences of wk_val in itab-fields with space.

condense itab-fields .

endif.

if itab-fields CS wk_val1..

replace all occurences of wk_val in itab-fields with space.

condense itab-fields .

endif.

same way check for other strings.

before endloop modify the itab.

code this using modularization techniques !!!!

reward if usefull.

Former Member
0 Kudos

try this...


DATA : BEGIN OF itab OCCURS 0,
text TYPE string ,
END OF itab.
DATA : substr TYPE string VALUE 'Payment fund;'.

itab-text = 'Sickness Insurance; Payment fund; Compensation;'.
APPEND itab.

LOOP AT itab.
  REPLACE ALL OCCURRENCES OF  substr
    IN itab-text
    WITH space.
  WRITE itab-text.
ENDLOOP.