Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Handeling Carriage Return is not working for program

Former Member
0 Likes
924

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

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
653

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

3 REPLIES 3
Read only

MarcinPciak
Active Contributor
0 Likes
653

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

Read only

rainer_hbenthal
Active Contributor
0 Likes
653

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.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
654

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