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

REPLACE

Former Member
0 Likes
887

I want to replace all occurances of

<b>/tmp/</b>

with

<b>\windows\homedir\</b> in the variants set for the programs.

The program name is on selection screen and i am dynamically reading variants.

REPLACE '/tmp/' WITH '\windows\homedir\' into w_path.

works fine.

If I now create paramters that accept the 'from text' and 'to text' and use Replace, it doesnt work. (SY-SUBRC = 4)

parameters : p_from type rlgrap-filename,

p_to type rlgrap-filename.

replace P_FROM with P_TO into w_path.

I need the from and to texts to be user inpits.

Another question : REPLACE only changes first occurance in a string, what if I want to REPLACE all occurances?

for ex in
wwlvfs1009\SystemFolders\DEV\' , I want to replace all '\' with '/'

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
843

to replace all occurances u can use

translate <field> using '\/' into <field>

in the quotes first give the symbol that u want to replace

next with the symbol that replaces that.(without space)

hope this helps u

6 REPLIES 6
Read only

Former Member
0 Likes
843
Read only

Former Member
0 Likes
844

to replace all occurances u can use

translate <field> using '\/' into <field>

in the quotes first give the symbol that u want to replace

next with the symbol that replaces that.(without space)

hope this helps u

Read only

0 Likes
843

perfect! Thanks!

Read only

Former Member
0 Likes
843

HI,

Do this way.

do..

replace

if sy-subrc ne 0.

exit.

endif.

enddo.

Read only

varma_narayana
Active Contributor
0 Likes
843

Hi... Vaishali.

To Replace all the Occurreneces,

This is the command you have to use.

<b>REPLACE ALL OCCURRENECES OF '/tmp/'

IN w_path WITH '\windows\homedir\' .</b>

<b>Reward if Helpful</b>

Read only

0 Likes
843

What version of SAP are you on? I am on 4.6, and REPLACE ALL OCCURENCES is a syntax error.