‎2009 Feb 03 10:34 AM
How can I use replace function in an internal table for eg
My internal table contain following entries.
line
my name is xyz
now I want to replace this xyz with priya..how to do that??? Can I use a place holder in internal table and feed data later to it? for eg
line
my name is &
and later add 'priya' in this place holder.
‎2009 Feb 03 10:36 AM
Hello,
You can use the REPLACE stmt for this.
REPLACE ALL OCCURRENCES OF '&' IN v_string WITH 'Priya'.Suhas
Edited by: Suhas Saha on Feb 3, 2009 4:08 PM
‎2009 Feb 03 10:39 AM
hi,
yes, u can do that
my name is &
REPLACE '&' WITH 'Priya'.
‎2009 Feb 03 10:40 AM
Hi,
You can use the replace statement
REPLACE sub_string WITH new into text1.
where sub_string = xyz
and text1 = priya.
Thanks & Regards
‎2009 Feb 03 10:43 AM
Hi,
See the following code:
DATA: name type string VALUE 'xyz',
name1 TYPE string VALUE 'priya'.
REPLACE name WITH name1 into name.
WRITE:/ name.
Like this u can loop ur internal table and replace the name.
Hope this helps u.
Thanks.
‎2009 Feb 03 10:44 AM
Hi,
Yes, you can do it.
REPLACE 'xyz' WITH 'Priya'.
Other wise you can use move commad and pass to perticular field and append internal table.
Regards
Md.MahabooobKhan
‎2009 Feb 03 10:52 AM
my problem is I am passing an internal table and not a single variable...and it is not working in an internal table
‎2009 Feb 03 11:10 AM
Loop at itab.
Move tablename-fieldname to temp var.
replace temp var.
move the temp var back to tablename-fieldname.
modify table.
endloop
‎2009 Feb 03 11:14 AM
Hello Priya,
What is the structure of your internal table? Can you share this?
Else you can try this:
DATA: V_STR TYPE STRING.
LOOP AT ITAB INTO WA.
MOVE WA TO V_STR.
REPLACE ALL OCCURENECES OF '&' IN V_STR WITH V_TEXT. "You can pass a varaible as well
MOVE V_STR TO WA.
MODIFY ITAB INDEX SY-TABIX.
CLEAR V_STR.
ENDLOOP.
Waiting for your input.
BR,
Suhas
‎2009 Feb 03 11:09 AM
data: name type TABLE OF string ,
wa_name type string.
wa_name = 'my name is xxx'.
append wa_name to name.
REPLACE ALL OCCURRENCES OF 'xxx'
IN TABLE name WITH 'PRIYA' .
‎2009 Feb 03 11:13 AM
Hi There,
use modify.
for eg:
123 345 abc
read that particular line with key using read statement.
itab-<filed> = priya.
Modify <itab>.
Reg
‎2009 Feb 03 11:25 AM
hi,
if you are replacing one reocrd than
REPLACE FIRST OCCURRENCE OF REGEX 'XYZ' IN wa_t090naz-afasl WITH 'PRIYA'.
If you want to alter all record where is name is XYZ.
than use this code
LOOP AT it_t090naz INTO wa_t090naz.
" Replacing v to l.
REPLACE FIRST OCCURRENCE OF REGEX 'XYZ' IN wa_t090naz-afasl WITH 'PRIYA'.
"wa_t090naz-afasl is the name of work area of internal table and afasl is the name of field,
Endloop.
Hope it will help you.
Thanks
Arun kayal.