Entering content frame

Concatenating Character Strings Locate the document in its SAP Library structure

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.

Example

DATA: c1(10) TYPE c VALUE  'Sum',
      c2(3)  TYPE c VALUE  'mer',
      c3(5)  TYPE c VALUE  'holi ',
      c4(10) TYPE c VALUE  'day',
      c1 (30) TYPE c,
      sep(3) TYPE c VALUE ' - '.

CONCATENATE c1 c2 c3 c4 INTO c5.
WRITE c5.

CONCATENATE c1 c2 c3 c4 INTO c5 SEPARATED BY sep.

WRITE / c5.

The output looks like this:

Summerholiday

Sum - mer - holi - day

In c1 to c5, the trailing blanks are ignored. The separator sep retains them.

 

Leaving content frame