CONCATENATE

CONCATENATE Syntax Diagram

Addition:

... SEPARATED BY h

Note

As with any string processing statement, all the operands are processed here as type C fields (regardless of type). No internal conversion is performed.

Effect

Places the fields f1 to fn (n >= 2) after g.

With the fields fi (1 <= i <= n), trailing blanks are ignored, i.e. these fields are considered only to have the length STRLEN( fi).

SY-SUBRC = 4:

The result was too long for g and was only copied to g in that length.

Example

DATA: ONE(10)   VALUE 'John', 
	TWO(3)	VALUE 'F.', 
	THREE(10) VALUE ' Kennedy', 
	NAME(20). 
CONCATENATE ONE TWO THREE INTO NAME.

Then, NAME contains the value "JohnF. Kennedy".

Effect

Inserts the separator h between the fields fi.
Here, h is used in its defined length.

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

DATA SEPARATOR(4) VALUE 'USA'. 
CONCATENATE SPACE ONE TWO THREE INTO NAME 
			SEPARATED BY SEPARATOR.

Then, NAME has the value "USA JohnUSA F.USA Ke".
The return code of SY-SUBRC is set to 4.

Related

SPLIT, SHIFT, REPLACE, TRANSLATE, CONDENSE


You are recommended to use the key word CONCATENATE rather than your own constructions because it is safer, more efficient and clearer. The runtime required to append two 30-byte fields amounts to approx. 14 msn (standardized microseconds).