Application Development 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: 

Replacing ',,' by space

Former Member
0 Kudos
130

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

former_member386202
Active Contributor
0 Kudos
98

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

Former Member
0 Kudos
98

Hi,

Use replace statment.

Replace ... all occurences ....

regards,

Santosh Thorat

JozsefSzikszai
Active Contributor
0 Kudos
98

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

former_member386202
Active Contributor
0 Kudos
99

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

0 Kudos
98

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

0 Kudos
98

Nikil,

then try this

REPLACE ',' WITH space INTO string.

Regards,

Satish

0 Kudos
98

Hi Prashant,

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

Regards,

Nikhil Moghe

0 Kudos
98

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

Former Member
0 Kudos
98

Do like this

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

Regards,

Satish

raymond_giuseppi
Active Contributor
0 Kudos
98

Try yo use

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

Regards

Former Member
0 Kudos
98

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...