MichaelB.
7/23/2018 - 7:54 PM

CONCATENATE string fields

The CONCATENATE statement allows us to join two character strings together to form a third string. Can add an additional term SEPERATED BY to allow you to insert a specific value in-between each field into the destination field. If the destination field is shorter than the overall length of the input fields the character string will be truncated to the length of the destination field. So use string data types, because they can hold more than 65,000 characters.

*Defintion: CONCATENATE f1 f2 f3 INTO d1 [SEPERATED BY sep].

DATA: title(15)        TYPE c value  'Mr',
      surname(40)      TYPE c VALUE  'Smith',
      forename(40)     TYPE c VALUE  'Joe',
      sep,
      destination(200) TYPE c.
*-----

CONCATENATE title surname forename INTO destination.
WRITE destination.
ULINE.

CONCATENATE title surname forename INTO destination SEPARATED BY sep.
WRITE destination.
ULINE.