2008 Sep 19 4:29 PM
Hi All,
My records are in one variable with charecter 200, i want to replace space by %20. How do i do this....
Reg,
Suren
2008 Sep 19 4:34 PM
DATA: pref TYPE char3 VALUE '%20'.
DATA: aux TYPE char1 VALUE '#'.
TRANSLATE <your_var> USING ' #'.
REPLACE ALL OCCURRENCES OF aux IN <your_var> WITH pref.
Regards,
Valter Oliveira.
2008 Sep 19 4:34 PM
DATA: pref TYPE char3 VALUE '%20'.
DATA: aux TYPE char1 VALUE '#'.
TRANSLATE <your_var> USING ' #'.
REPLACE ALL OCCURRENCES OF aux IN <your_var> WITH pref.
Regards,
Valter Oliveira.
2008 Sep 19 4:35 PM
hi,
use replace for all occurences of that varibale with %20.
syntax is like this.
Replace for all occurances of space in variable with '%20'.
2008 Sep 22 6:44 AM
Hi Subas,
Syntax is showing an error, will appreciate if you can provide me the right Syntax.
Rg,
Suren
Edited by: Suren on Sep 22, 2008 7:44 AM
2008 Sep 22 6:54 AM
Hi Suren,
What is the error u r getting?
Valter's solution given above is working fine.
Regards,
Surinder
2010 Nov 05 9:25 AM
Hi,
for all who seached the solution of the problem in this diskussion like me:
The solution is in first answer of Valter Oliveira.
First translate spaces to sharps and then replace sharps by '%20'.
Direct replace of spaces is not possible, cause only spaces are recognized as empty string, and the result is an infinite loop.
You have only a problem, if you use sharps in your source string ;-(
Regards
Christoph
2008 Sep 19 4:47 PM
Suren...
Can you come again with ur ques...Just do u want to eliminate spaces...
Exam "sldjfl slkdjsl sakljkldj slkdjls sdljkkl sdljlj ",
result must be "sdkljdflsjaddjlsjjldjlsjljdlsjldjs"
What is ur exact requirement
Thanks
2008 Sep 20 6:07 PM
Hi, Santosh
Exam "sldjfl slkdjsl sakljkldj slkdjls sdljkkl sdljlj ",
Result Wanted : sldjfl%20slkdjsl%20sakljkldj%20slkdjls%20sdljkkl%20sdljlj ",
Ashoak Narayandas Advani
2010 Nov 05 3:02 PM
Hi,
I suppose you have not to translate the trailing spaces.
(if you translate the trailing spaces, you have a risk to truncate %20 as %2 or %).
So I should propose this:
data: text(30) value 'this is a test '.
data: wwlen type i.
write: / text.
wwlen = strlen( text ).
replace all occurrences of ` `
in SECTION OFFSET 0 LENGTH wwlen OF text with '%20'.
* CAUTION: use ` ` and not ' '
write: / text.