2010 Oct 28 5:46 PM
HI
I should replace ' | ' with space .
I am using 'Replacing all occurances ' but its not replacing with space .
please give inputs on this
thanks
kamesh
2010 Oct 28 6:25 PM
What does your code (and your string) look like? It helps when you post it...
The statement works just fine for pipes and so does TRANSLATE...though the gaps will be handled differently.
2010 Oct 28 6:25 PM
What does your code (and your string) look like? It helps when you post it...
The statement works just fine for pipes and so does TRANSLATE...though the gaps will be handled differently.
2010 Oct 28 6:33 PM
HI brad
I have one text field like . 'This| is|test |Program ' .
I want this like 'This is test program '. For this I am using REPLACE ALL OCCURANCES OF ' | ' in field with ' ' .
But its not giving space but removing |. This is my issue .I think ou understood .
How TRANSLATE statement will help in this .
Thanks
kamesh
Edited by: KAMESH G on Oct 28, 2010 7:37 PM
2010 Oct 28 6:40 PM
REPLACE doesn't work well when replacing with a space. Use TRANSLATE instead:
DATA: f1(10) VALUE '1234|567|8'.
TRANSLATE f1 USING '| '.Rob
2010 Oct 28 8:05 PM
Try this code
DATA lv_data TYPE char20 VALUE 'This|test |is for SDN | '.
WRITE :/ lv_data.
REPLACE ALL OCCURRENCES OF '|' IN lv_data WITH ' '.
WRITE :/ lv_data.
2010 Oct 28 8:25 PM
I think this code works the same as the original.
Regular expressions are another option. You can search the forum for examples.
Rob
2010 Oct 28 8:25 PM
From help.sap.com:
Character literals are sequences of alphanumeric characters in the source code of an ABAP program enclosed in single quotation marks or backquotes. Character literals enclosed in quotation marks have the predefined ABAP type c and are described as text field literals. Literals enclosed in backquotes have the ABAP type string and are described as string literals. The field length is defined by the number of characters. With text field literals trailing blanks are ignored while in string literals they are taken into account.
So in your case you need to use string literal which is represented by backquotes `
REPLACE ALL OCCURRENCES OF '|' IN lv_data WITH ` `.
Now it will work
Regards
Marcin
2012 Aug 16 8:12 AM
2014 Nov 26 8:37 AM
Use the below if you want to convert '_' with space.
TRANSLATE lv_text USING '_ '.