03-02-2007 3:02 PM
Hi ,
There is a single field in an ITAB I need to check th field and replace some characters for example:
ITAB-f1 = 130 " front & 12 " back
I need to change it like this :
130 inches front and 12 inches back
anyone please give me the code.
Thanks
03-02-2007 3:10 PM
If you are on a 46c release, you can to this.
report zrich_0001 .
data: begin of itab occurs 0,
str type string,
end of itab.
itab-str = '130 " front & 12 " back'.
append itab.
loop at itab.
while sy-subrc = 0.
replace '"' with 'inches' into itab-str.
replace '&' with 'and' into itab-str.
endwhile.
modify itab.
endloop.
loop at itab.
write:/ itab-str.
endloop.
With newer releases, the REPLACE statement allows you to do ALL OCCURANCES, which means that you don't need the WHILE to loop it.
Regards,
Rich Heilman
03-02-2007 3:04 PM
Hi,
You can use REPLACE command or try this FM STRING_REPLACE
Regards,
Amit
03-02-2007 3:04 PM
Hi,
Loop at ITAB.
REPLACE '''' with 'Inches' into itab-f1.
REPLACE '&' with 'and' into itab-f1.
modify ITAB.
Endloop.
Regards
Sudheer
03-02-2007 3:10 PM
If you are on a 46c release, you can to this.
report zrich_0001 .
data: begin of itab occurs 0,
str type string,
end of itab.
itab-str = '130 " front & 12 " back'.
append itab.
loop at itab.
while sy-subrc = 0.
replace '"' with 'inches' into itab-str.
replace '&' with 'and' into itab-str.
endwhile.
modify itab.
endloop.
loop at itab.
write:/ itab-str.
endloop.
With newer releases, the REPLACE statement allows you to do ALL OCCURANCES, which means that you don't need the WHILE to loop it.
Regards,
Rich Heilman