String Concatenation:CONCATENATE

  Define Data

Over View

CONCATENATE is a command to combine strings. Handle strings
It can be used with Char, Numeric, Dats, Time and String variables.
How to simply combine the strings, delimiter between the combined strings
There are a method of inserting and a method of inserting a space according to the length of the data type.
Let’s explain each with sample code.

Sample Code:String Concatenation

DATA: V_CHAR(15) TYPE C.
CONCATENATE 'ABC' 'DEF' 'GHI' INTO V_CHAR.

Explain

This example is simple concatenation.
The value ‘ABC’、’DEF’ and ‘GHI’ concatenate to variable:V_CHAR so it will be ‘ABCDEFGHI’.

Sample Code:String Concatenation(Separate)

DATA: V_CHAR(15) TYPE C.
CONCATENATE 'ABC' 'DEF' 'GHI' INTO V_CHAR
  SEPARATED BY ';'.

Explain

In this example, when combining strings, they are separated by; (semicolon) by the SEPARATED BY option.
Because a (semicolon) is inserted between the letters’ABC ‘,’ DEF ‘, and’GHI’
The result is’ABC; DEF; GHI ‘.
The delimiter character can be any character such as Space (blank), or (comma).

Sample code: Combining character strings (automatic space insertion)

DATA: V_CHAR(15) TYPE C.
TYPES: BEGIN OF t_char,
         col1(5) type c,
         col2(10) type c,
         col3(5) type c,
       END of t_char.
DATA: wa_char type t_char.
wa_char-col1 = 'ABC'.
wa_char-col2 = 'DEF'.
wa_char-col3 = 'GHI'.

CONCATENATE wa_char-col1 wa_char-col2 wa_char-col3 INTO V_CHAR
 RESPECTING BLANKS.

Explain

In this example, the RESPECTING BLANKS option is used when combining strings.
The result looks like’ABC DEF GHI ‘.
The RESPECTING BLANKS option is an option that automatically fills spaces according to the data length.
It may not be useful when you want to output a fixed length file.
However, this command is relatively new and cannot be used per ECC 6.0.