Skip to Content
author's profile photo Former Member
Former Member

Concatenate with new-line

Hi,

i got a Small problem. I have to Concatenate two Strings and Separated them with a New Line but i couldn't find anything to get this done.

My test Code looks like this :

DATA: test1 TYPE String,

test2 TYPE String,

test3 TYPE string.

test1 = 'Hallo'.

test2 = 'du da'.

CONCATENATE test1 test2 INTO test3 SEPARATED BY space.

WRITE test3.

This works so far but i need to replace space with something to get a new Line.

Maybe someone had an idea.

Greetings

Moritz

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 10:43 AM

    Hi Mortiz,

    Please check below:

    data: l_cr(1) type c value cl_abap_char_utilites=>cr_lf,
          l_lf(1) type c value cl_abap_char_utilities=>linefeed.
    

    One of the above will certainly help you. Am not on SAP now to check the same. Use this for concatenating.

      CONCATENATE str1 str2 INTO out SEPARATED BY l_cr.
      CONCATENATE str1 str2 INTO out SEPARATED BY l_lf.
    

    Kind Regards

    Eswar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 29, 2008 at 07:25 PM

    Hai

    There is small error in this code,

    when using concatenate operator ,

    CONCATENATE C1 C2 ....CN INTO STR1 BY H.

    H should be Character type either C ,N,D,T or String.

    In your program,

    you are declaring line_br(2) type X.

    so, it gives that error.

    you should correct your code in either way like

    DATA: line_br(4) TYPE C VALUE '0D0A'.

    OR

    DATA: line_br TYPE STRING VALUE '0D0A'.

    DATA: v_line TYPE string.

    CONCATENATE 'LINE1' 'LINE2' INTO v_line SEPARATED BY line_br.

    Then it works.

    if it useful, reward points.

    Thank you,

    G.V.K.Prasad

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 11:00 AM

    Hi,

    u just try like this

    DATA: test1 TYPE String,

    test2 TYPE String,

    test3 TYPE string.

    test1 = 'Hallo'.

    test2 = 'du da'.

    CONCATENATE test1 sy-uline(5) test2 INTO test3 SEPARATED BY space.

    WRITE test3.

    rgds,

    bharat.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 22, 2008 at 11:05 AM

    hi,

    try it

    data: l_cr(1) type c value cl_abap_char_utilities=>cr_lf,

    l_lf(1) type c value cl_abap_char_utilities=>linefeed.

    CONCATENATE str1 str2 INTO out SEPARATED BY l_cr.

    CONCATENATE str1 str2 INTO out SEPARATED BY l_lf.

    L.Velu

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hmm if i download it to a file it works, but the Problem is i have to show the result in SAP.

      In a Message Box and there i got the "#" or for sy-uline(5) i got "-----" :-/.

      So i seperate the two Strings with a space.

      This works but dint look nice, but its the only way to solve it at the moment.

      Thanks for your great help.

      Greetings

      Moritz

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.