Application Development 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: 

How to insert Newline in text file thr CL_ABAP_CHAR_UTILITIES

rameshkumar_ramasamy2
Participant
0 Kudos
3,325

Hi,

I need to send a mail with TEXT file attachment which has many records in it. It is working fine. But the only problem is, all records are displayed in the 1st line itself. So i need to separate the records by inserting new line.

constants: c_new type c value CL_ABAP_CHAR_UTILITIES=>NEWLINE.

LOOP AT it_final INTO wa_final.

lv_menge = wa_final-menge.
CONCATENATE  wa_final-ebeln
           wa_final-bukrs
           wa_final-lifnr
           wa_final-ebelp
           wa_final-matnr
           wa_final-werks
           lv_menge
           c_new    " Newline
           INTO lv_txt SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB. 
APPEND lv_txt to text.
CLEAR: lv_txt, lv_menge.

ENDLOOP.

For this code, i'm not getting the new line for each record.

Plz help me out for the same.

Thanks,

Ramesh

1 ACCEPTED SOLUTION

Former Member
0 Kudos
592

just add one more line of code.... put a CRLF on the end of your tex string, like:

concatenate lv_text <and the CR_LF already mentioned> into lv_text.

append lv_text to....

etc.

9 REPLIES 9

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos
592
SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB

Do i need to say more?

Former Member
0 Kudos
592

Hi,

Declare c_new as below

constants: c_new type ABAP_CR_LF value CL_ABAP_CHAR_UTILITIES=>CR_LF.

Regards,

Smart

0 Kudos
592

Hi,

I replaced my declaration code as u have mentioned but its not working..

@ Suhas Saha : Already i have written that code which u have posted..

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos
592

You did not get my point

You should use LF(line feed / new line) when concatenating the table lines instead of the horizontal tab.

BR,

Suhas

0 Kudos
592

Hi ,

Sorry i cant get u.. Plz let me know exactly.. Now i replaced the Horizontal tab with CR_LF but even this is not working..

CONSTANTS: c_new type ABAP_CR_LF value CL_ABAP_CHAR_UTILITIES=>CR_LF.

      LOOP AT it_final INTO wa_final.

        lv_menge = wa_final-menge.
        CONCATENATE wa_final-ebeln
                   wa_final-bukrs
                   wa_final-lifnr
                   wa_final-ebelp
                   wa_final-matnr
                   wa_final-werks
                   lv_menge
"                   c_new
                   INTO lv_txt SEPARATED BY c_new. "cl_abap_char_utilities=>horizontal_tab.
        APPEND lv_txt TO text.
        CLEAR: lv_txt, lv_menge.

      ENDLOOP.

Correct me if i'm wrong..

Thanks

Ramesh

0 Kudos
592

Hello,

Horizontal tab - provides tab distance between two fields

line feed - provides "Enter" action

You have to give a LF at the end of the record, not separating the fields using it.

As this is a basic question which can be searched in SCN , I am afraid to answer this in detail....

Former Member
0 Kudos
593

just add one more line of code.... put a CRLF on the end of your tex string, like:

concatenate lv_text <and the CR_LF already mentioned> into lv_text.

append lv_text to....

etc.

0 Kudos
592

Thanks for ur answers.. The Issue was solved by coding separately for Newline.

CONSTANTS: c_new type c value CL_ABAP_CHAR_UTILITIES=>CR_LF.

      LOOP AT it_final INTO wa_final.

        lv_menge = wa_final-menge.
        CONCATENATE wa_final-ebeln
                   wa_final-bukrs
                   wa_final-lifnr
                   wa_final-ebelp
                   wa_final-matnr
                   wa_final-werks
                   lv_menge
                   INTO lv_txt SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
        CONCATENATE lv_txt c_new INTO lv_txt.  
        APPEND lv_txt TO text.
        CLEAR: lv_txt, lv_menge.

      ENDLOOP.

0 Kudos
592

HELLO,

i've tried to use this in same way with slight change,

i've concatenated strings instead of fields from work area. but its giving me value of '#' wherever i've used c_new.

*c_new type c value CL_ABAP_CHAR_UTILITIES=>CR_LF...

please reply....