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 comment
10|10000 characters needed characters exceeded

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 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 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 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