The CONCATENATE statement combines two or more separate strings into one.
CONCATENATE <c1> ... <cn> INTO <c> [SEPARATED BY <s>].
This statement concatenates the character fields <c1> to <cn> and assigns the result to <c>. The system ignores spaces at the end of the individual source strings.
The addition SEPARATED BY <s> allows you to specify a character field <s> which is placed in its defined length between the individual fields.
If the result fits into <c>, SY-SUBRC is set to 0. However, if the result has to be truncated, SY-SUBRC is set to 4.
DATA: C1(10) VALUE 'Sum',
C2(3) VALUE 'mer',
C3(5) VALUE 'holi ',
C4(10) VALUE 'day',
C5(30),
SEP(3) VALUE ' - '.
CONCATENATE C1 C2 C3 C4 INTO C5.
WRITE C5.
CONCATENATE C1 C2 C3 C4 INTO C5 SEPARATED BY SEP.
WRITE / C5.
Output:
Summerholiday
Sum - mer - holi - day
In C1 to C5, the trailing blanks are ignored. The separator SEP retains them.