2009 Aug 04 12:41 PM
Hi,
I am trying to get the carriage return in program and my code is as follows:
LOOP AT gt_tab INTO gw_tab.
SEARCH gw_tab FOR CL_ABAP_CHAR_UTILITIES=>CR_LF.
IF sy-subrc = 0.
REPLACE CL_ABAP_CHAR_UTILITIES=>CR_LF WITH '&*$@!$#&' INTO gw_tab.
MODIFY gt_tab FROM gw_tab.
ELSE.
EXIT.
ENDIF.
ENDLOOP.
Also I tried with:
CONSTANTS: c_cr TYPE x VALUE '0D'. " Carriage Return
LOOP AT gt_tab INTO gw_tab .
replace all occurrences of C_CR in gw_tab with '&*$@!$#&'.
ENDLOOP.
It throws error as c_cr should be of type C,N,D,T or STRING.
After this I need to split the values of gt_tab.But the above code is not working.I searched in SDN and the solutions given also not working.Please help.
Edited by: Ginger on Aug 4, 2009 7:43 AM
2009 Aug 04 1:25 PM
Hello Ginger,
You can try like this:
DATA: V_CRLF TYPE CHAR2.
V_CRLF = CL_ABAP_CHAR_UTILITIES=>CR_LF.
LOOP AT gt_tab INTO gw_tab.
SPLIT gw_tab AT V_CRLF INTO
gw_new-field1 gw_new-field2 gw_new-field3 ... gw_new-fieldn.
APPEND gw_new INTO gt_tabnew.
CLEAR gw_new.
ENDLOOP.Hope this helps.
BR,
Suhas
Hi,
I am trying to get the carriage return in program and my code is as follows:
LOOP AT gt_tab INTO gw_tab.
SEARCH gw_tab FOR CL_ABAP_CHAR_UTILITIES=>CR_LF.
IF sy-subrc = 0.
REPLACE CL_ABAP_CHAR_UTILITIES=>CR_LF WITH '&*$@!$#&' INTO gw_tab.
MODIFY gt_tab FROM gw_tab.
ELSE.
EXIT.
ENDIF.
ENDLOOP.
Also I tried with:
CONSTANTS: c_cr TYPE x VALUE '0D'. " Carriage Return
LOOP AT gt_tab INTO gw_tab .
replace all occurrences of C_CR in gw_tab with '&*$@!$#&'.
ENDLOOP.
It throws error as c_cr should be of type C,N,D,T or STRING.
After this I need to split the values of gt_tab.But the above code is not working.I searched in SDN and the solutions given also not working.Please help.
Edited by: Ginger on Aug 4, 2009 7:43 AM
2009 Aug 04 1:17 PM
Try this way
DATA: xsep TYPE xstring,
sep TYPE string.
xsep = '0D'.
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
EXPORTING
in_xstring = xsep
IMPORTING
out_string = sep.
replace all occurences of sep in gw_tab with '&*$@!$#&' in character mode.
Regards
Marcin
2009 Aug 04 1:19 PM
try
CALL METHOD cl_abap_conv_in_ce=>uccp
EXPORTING
uccp = '000D'
RECEIVING
char = cr.
to get CR into the varivalke cr, which is of type c length 1.
then do your loop and your replacement.
2009 Aug 04 1:25 PM
Hello Ginger,
You can try like this:
DATA: V_CRLF TYPE CHAR2.
V_CRLF = CL_ABAP_CHAR_UTILITIES=>CR_LF.
LOOP AT gt_tab INTO gw_tab.
SPLIT gw_tab AT V_CRLF INTO
gw_new-field1 gw_new-field2 gw_new-field3 ... gw_new-fieldn.
APPEND gw_new INTO gt_tabnew.
CLEAR gw_new.
ENDLOOP.Hope this helps.
BR,
Suhas