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 string by space

Former Member
0 Likes
498

I would like to replace all ',' appear in a strng by space. So, i use

replace all occurrences of ',' in tempStr with space.

But, the outcome is all pattern are replaced, and concatenate together. For example, i have string

tempStr = '1,2,3,4,5,6,7'

But the result is

tempStr = 1234567

How can i replace the string by space. thanks!

3 REPLIES 3
Read only

Former Member
0 Likes
469

Hi,

Try the below logic:

data: val1 type char10.

val1 = '1,2,3,4,5'.

write : / val1.

do.

replace ',' with ' ' into val1.

if sy-subrc <> 0.

exit.

endif.

enddo.

write : / val1.

Read only

Former Member
0 Likes
469

data: tempStr type string value '1,2,3,4,5,6,7'.

REPLACE ALL OCCURRENCES OF REGEX ',' IN tempstr WITH ''.

write:/ tempstr.

Read only

Former Member
0 Likes
469

Hi,

Try this.

data : tempstr type string,

temp(2) type c.

tempStr = '1,2,3,4,5,6,7'

temp = ', '.

Translate tempstr using temp.

Write tempstr.

Regards,

Mohaiyuddin