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

Concatenating strings with trailing spaces

Hi,

can somebody advise me of how to concatenate strings so that trailing space is not ignored? For example I have two variabvles 'ABC ' and 'XYZ ' I need the result to be 'ABC XYZ '. By default trailing spaces are removed, how to retain them?

thanks,

erki

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on May 10, 2004 at 09:48 AM

    Hi Erki,

    see the docu, this is the example from the docu:

    Examples DATA: ONE(10) VALUE 'John',

    TWO(3) VALUE 'F.',

    THREE(10) VALUE 'Kennedy',

    NAME(20).

    CONCATENATE ONE TWO THREE INTO NAME SEPARATED BY SPACE.

    Then, NAME has the value "John F. Kennedy".

    Regards,

    Dirk

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 11, 2004 at 02:30 PM

    You can also achieve the result you require with a deep data structure. Either group your elements in the order in which they should be concatenated or move the data into the elements into a separate structure. To access the concatenated result, use the higher level data name:

    report z_jac_test.

    data: begin of concat,

    element1(4) value 'ABC ',

    element2(4) value 'DEF ',

    end of concat.

    write: / '[' no-gap, concat no-gap, ']' no-gap.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 12, 2004 at 11:06 AM

    There is a much easier way.

    CONCATENATE `abc ` 'xyz' INTO target.

    Using the `` form will keep trailing space characters!

    ++bcm

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Dirk Altmann

      The backquote ` is used to delimit a STRING literal whereas the single quote ' is used to delimit a text field literal.

      The string literals retain any trailing spaces, the text literals do not.

      But the STRING type was not available in 3.1I and therefore this method won't work for you :o(

      Cheers,

      John

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.