‎2007 Mar 26 8:58 PM
I trying to read a character string which has #'s in it. I need to replace each of these #'s with spaces. None of the standard string functions help in this regard.
Is there a way that I can read character by character and replace the #'s with spaces.
Thanks in advance
‎2007 Mar 26 9:03 PM
REPLACE '#' WITH space INTO from_string.
or
replace all occurences of '#' in from_string with ''.
aRs
‎2007 Mar 26 9:09 PM
Hi,
You can also use TRANSLATE statement.
TRANSLATE WA_TEXT USING '# '.
Regards,
Ferry Lianto
‎2007 Mar 26 9:16 PM
Hi Vamseedhar,
I think # representing Horizontal tabl and it is equivalent to CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
Try with the following statement.
replace all occurrences of
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB in str with space.
Thanks,
Vinay
‎2007 Mar 26 10:06 PM
Hi,
You shoud user the TRANSLATE command. DO NOT USE REPLACE command. If you have character "#" at the end of the string, REPLACE command thinks it as a "return command" and does not replace it. Please check this code.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
DATA: string(10) TYPE c VALUE '123#5678#'.
DATA: string1(10) TYPE c,
string2(10) TYPE c,
WRITE:/0 'Original String :',
20 string.
string1 = string.
REPLACE '#' WITH space INTO string1.
WRITE:/0 'REPLACE String :',
20 string1.
string2 = string.
TRANSLATE string2 USING '# '.
WRITE:/0 'TRANSLATE String :',
20 string2.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*Regards,
RS
‎2007 Mar 27 10:22 AM
Hi!
data: c(30) value 'AAXZC#D#GH'.
translate c using '# '.
condense c.
WRITE C.
Reward points if it helps.
Regards,
Neha Bansal.
‎2007 Mar 27 10:28 AM
<b>The character '#' can be a Horizontal tab or a new line or a Vertical tab...
Those '#' are special characters to indicates new line or tab. You need to use the abap objects CL_ABAP_CHAR_UTILITIES to fix this issue.</b>
try with all the threee...
define a constant..
constants :
C_HTAB value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
C_VTAB value CL_ABAP_CHAR_UTILITIES=>VERTICAL_TAB,
C_NLINE value CL_ABAP_CHAR_UTILITIES=>NEWLINE.
replace all occurrences of C_HTAB in w_string with space.
replace all occurrences of C_VTAB in w_string with space.
replace all occurrences of C_NLINE in w_string with space.
<b><u>I am sure.. one of the above three will work.</u></b>
plz do remember to close the thread when ur problem gets solved..
reward all helpful answers,
sai ramesh
‎2007 Mar 27 10:28 AM
hi,
DATA: STRING(80).
STRING = 'Variable: The variable # is substituted later.'.
REPLACE '#' WITH ' ' INTO STRING.
WRITE / STRING.Rgds
Reshma