2007 Dec 20 1:47 AM
hi,
now i want replace , with space in string ,i use replace sentence,ie
REPLACE ALL OCCURRENCES OF REGEX ',' IN string WITH ''.
at ecc6.0 this sentence is ok ,but at 4.6c it has error.
can you help me ? my sap edition s 4.6c .
regards
sophia
2007 Dec 20 4:26 AM
Hi,
REPLACE syntax in 4.6c is
REPLACE f ...WITH g
...INTO h.
Replaces the first occurrence of the contents of field f in field h with the contents of field g.
If you want to replace all the commas with blank space ,
DO.
REPLACE ',' WITH ' ' INTO l_f_string.
if sy-subrc <> 0.
exit.
endif.
ENDDO.
2007 Dec 20 1:57 AM
Try this.
REPLACE ALL OCCURRENCES OF ',' WITH ' ' IN string .
condense string.
2007 Dec 20 2:41 AM
Hi,
You cannot use Replace all occurences in 4.6c.You can use replace.
data str(5) value '34,45'.
REPLACE ',' WITH '' into str.
condense str no-gaps.
write str.
2007 Dec 20 3:01 AM
Replace all occurrences doesn't work in 4.6c
what you can do is a
while sy-subrc = 0.
replace ',' into regex with ''.
endwhile.
condense regex no-gaps.
Edited by: Kris Donald on Dec 20, 2007 8:31 AM
2007 Dec 20 4:26 AM
Hi,
REPLACE syntax in 4.6c is
REPLACE f ...WITH g
...INTO h.
Replaces the first occurrence of the contents of field f in field h with the contents of field g.
If you want to replace all the commas with blank space ,
DO.
REPLACE ',' WITH ' ' INTO l_f_string.
if sy-subrc <> 0.
exit.
endif.
ENDDO.
2007 Dec 20 4:45 AM
Hi
Check this..also from 4.6C
REPLACE ',' WITH ' ' INTO H_FIELD.
Hope this Helps.
Praveen
2007 Dec 20 4:56 AM
Hi Sophia,
In place of replace statement you can also use Translate statement.
Example:
DATA : v_text(4) value ', '.
Data : v_str type string.
string = 'This is, one, of the, demo, of, translate,statement'.
TRANSLATE v_str USING v_text.
Here v_text contain the pattern in which you want to covert the string . so in this example all the , are replace by space.
Reward points,if useful.
Regards,
Manoj Kumar