‎2006 Dec 28 3:13 PM
Hi,
I need some string operations help. I have a field symbol containing <b>a#b#c#</b>. In order to make it work nicely with excel download I would like to replace the # with excel line feeds. The # originates from BSP textedit line feeds. I have tried with <b>replace</b> and <b>translate</b>, but these commands do not find the #s. What should I do?
Thanks in advance.
/Elvez
‎2006 Dec 28 3:23 PM
Hi Elvez,
repsents horizontal tab.
Use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB instead of #s in your replace statement.
Thanks,
Vinay
‎2006 Dec 28 3:26 PM
Hi Vinaykumar G,
here is my code:
DATA: s(256) type c.
s = l_page->if_bsp_page~to_string( value = <f> ).
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN s WITH cl_abap_char_utilities=>cr_lf.It still does not work.
/Elvez
‎2006 Dec 28 3:29 PM
Just an example donno if this works for you
data: lv_var(6) type c value 'a#b#c#',
lv_hash type c value '#'.
search lv_var for lv_hash.
if sy-subrc eq 0.
do your processing.
endif.
Thanks,
Santosh
‎2006 Dec 28 3:29 PM
Hi,
Here is a sample I wrote in 46C. I am able to use both TRANSLATE and REPLACE successfully to change the characters.
[code]
PARAMETERS: p_string TYPE char20.
DATA: w_string TYPE char20 VALUE '#$'.
WRITE: / 'String before Conversion:', p_string.
TRANSLATE p_string USING w_string.
WRITE: / 'String after TRANSLATE :', p_string.
DO.
REPLACE '$' WITH '@&' INTO p_string.
IF sy-subrc NE 0.
EXIT.
ENDIF.
ENDDO.
WRITE: / 'String after REPLACE :', p_string.
[/code]
Hope this helps.
Sumant.
‎2006 Dec 28 3:32 PM
this is working in my system , may be some unicode problems in ur system
REPORT ychatest LINE-SIZE 350.
DATA : v_char(10) VALUE 'a#b#c'.
REPLACE all occurrences of '#' IN v_char WITH space .
CONDENSE v_char.
WRITE : v_char.check the attributes in the class CL_ABAP_CHAR_UTILITIES and try with some of them
‎2006 Dec 28 3:41 PM
Hi,
the example is working fine stand alone, but when I try to use it in my code it is not working. It seems to be some kind cast issue. Anyone who knows how I can cast the variable in order to make this work?
Thanks.
/Elvez
‎2006 Dec 28 4:47 PM
I solved the problem by using CL_ABAP_CHAR_UTILITIES=>NEWLINE instead of #s in my replace statement.
/Elvez