12-13-2007 11:46 AM
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.
12-13-2007 11:50 AM
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
12-13-2007 11:50 AM
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
12-13-2007 11:50 AM
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
12-13-2007 11:53 AM
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.
12-13-2007 11:59 AM
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.