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

Replacing ',,' by space

Former Member
0 Likes
1,088

Hi All,

I have a variable in that the value is "3,,,,,,,,,,Test".

Now the user wants to replace the ",," by space.

Its urgent.

Can anyone give me a solution.

Points will be rewarded immediately.

Regards,

Nikhil Moghe

1 ACCEPTED SOLUTION
Read only

former_member386202
Active Contributor
0 Likes
1,056

Hi,

Use replace with all occurances statement

Try like this

DATA: myText type string.

myText = 'abcabcabcabcabc'.

REPLACE ALL OCCURRENCES OF 'abc' IN myText WITH 'XYZ'.

Regards,

Prashant

10 REPLIES 10
Read only

Former Member
0 Likes
1,056

Hi,

Use replace statment.

Replace ... all occurences ....

regards,

Santosh Thorat

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,056

hi Nikhil,

TRANSLATE string USING ', '.

(pls. note there is a space between , and ')

if the use wants only one space instead of n comas than you also have to:

CONDENSE string.

hope this helps

ec

Message was edited by:

Eric Cartman

Read only

former_member386202
Active Contributor
0 Likes
1,057

Hi,

Use replace with all occurances statement

Try like this

DATA: myText type string.

myText = 'abcabcabcabcabc'.

REPLACE ALL OCCURRENCES OF 'abc' IN myText WITH 'XYZ'.

Regards,

Prashant

Read only

0 Likes
1,056

Hi Prashant,

Thanks for your quick response.

But my versionis 4.6C and replace for all occurrences does not seem to work in my version.

Can you suggest me any other alternative.

Regards,

Nikhil Moghe

Read only

0 Likes
1,056

Nikil,

then try this

REPLACE ',' WITH space INTO string.

Regards,

Satish

Read only

0 Likes
1,056

Hi Prashant,

But then it will only replace the first occurence of ',,' by space.

Regards,

Nikhil Moghe

Read only

0 Likes
1,056

Nikihl,

Do like this

data: text(50) type c value 'a,,,,,b,,,,',
      len type i,
      ind type i,
      pos type i.

len = strlen( text ).

do len times.
ind = sy-index.
pos = sy-tabix.
if text+ind(pos) = ','.
replace ',' with space into text.
endif.
enddo.
condense text no-gaps.
write text.

Regards,

Satish

Read only

Former Member
0 Likes
1,056

Do like this

REPLACE ALL OCCURRENCES OF ',' in STRING with space.

Regards,

Satish

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,056

Try yo use

TRANSLATE string USING ', . '. " , space . space 

Regards

Read only

Former Member
0 Likes
1,056

Hi try this...

data : var type STRING.

var = '3,,,,,,,,,,,,,,,,,,,,,,,,Test'.

write var.

REPLACE ALL OCCURRENCES OF ',' in var with space.

write 😕 var.

reward poinds if usefull...