12-03-2007 11:45 AM
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
12-03-2007 11:48 AM
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
12-03-2007 11:47 AM
Hi,
Use replace statment.
Replace ... all occurences ....
regards,
Santosh Thorat
12-03-2007 11:47 AM
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
12-03-2007 11:48 AM
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
12-03-2007 12:09 PM
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
12-03-2007 12:11 PM
Nikil,
then try this
REPLACE ',' WITH space INTO string.
Regards,
Satish
12-03-2007 12:13 PM
Hi Prashant,
But then it will only replace the first occurence of ',,' by space.
Regards,
Nikhil Moghe
12-03-2007 12:28 PM
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
12-03-2007 11:48 AM
Do like this
REPLACE ALL OCCURRENCES OF ',' in STRING with space.
Regards,
Satish
12-03-2007 12:14 PM
Try yo use
TRANSLATE string USING ', . '. " , space . space
Regards
12-03-2007 12:22 PM
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...