Concatenating Similar Statements

The ABAP programming language allows you to concatenate consecutive statements with an identical first part into a chain statement.

To concatenate a sequence of separate statements, write the identical part only once and place a colon (:) after it. After the colon, list the remaining parts of the statements by separating each part with a comma (,). Ensure that you place a period (.) after the last part to inform the system where the chain ends.

Statement sequence:

WRITE SPFLI-CITYFROM.
WRITE SPFLI-CITYTO.
WRITE SPFLI-AIRPTO.

Chain statement:

WRITE: SPFLI-CITYFROM, SPFLI-CITYTO, SPFLI-AIRPTO.

In the chain, a colon separates the beginning of the statement from the variable parts. You can insert as many spaces as you like before and after the colon (or comma).

For example, you could also write the same statement as follows:

WRITE:    SPFLI-CITYFROM,
SPFLI-CITYTO,
SPFLI-AIRPTO.

In a chain statement, the first part (before the colon) is not limited to the keyword of the statements.

Statement sequence:

SUM = SUM + 1.

SUM = SUM + 2.

SUM = SUM + 3.

SUM = SUM + 4.

Chain statement:

SUM = SUM + : 1, 2, 3, 4.