Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  ABAP Syntax 

Chained Statements

Consecutive statements that have the same initial part can be combined into one chained statement. To do this, the identical initial part is specified once and closed with a colon (:). The remaining parts are then specified separately, separated by commas (,), and closed with a period (.). When the syntax is checked and the program executed, the chained statement is handled in the same way as the corresponding string of individual ABAP statements.

Other versions: 7.31 | 7.40 | 7.54

Programming Guideline

Only use chained statements where appropriate


Notes

  • The identical starting parts are not restricted to the keyword.

  • When using chained statements, care must be taken to not mistakenly produce any statements that have correct syntax but the wrong behavior. This mistake is most commonly made with more complex statements, such as when using expressions or function calls where chained statements must be avoided all together.

  • If further colons are specified after the first colon of a chained statement, they are handled like blanks.

Examples

Typical use of a chained statement:

DATA: BEGIN OF struc,
        col1 TYPE c LENGTH 4,
        col2 TYPE c LENGTH 4,
      END OF struc.

The complete syntax of the four statements is:

DATA BEGIN OF struc.
DATA   col1 TYPE c LENGTH 4.
DATA   col2 TYPE c LENGTH 4.
DATA END OF struc.

Chained statement in which more than just the keyword is cut off:

CALL FUNCTION func EXPORTING para = : '1', '2', '3'.

The complete syntax of the three statements is:

CALL FUNCTION func EXPORTING para = '1'.
CALL FUNCTION func EXPORTING para = '2'.
CALL FUNCTION func EXPORTING para = '3'.

Incorrect use of a chained statement in ABAP SQL. This code fragment does not represent an individual statement that updates the discount and phone number of customer 00017777. Instead, there are two statements, with the first changing the discount for all customers and the second changing the phone number of customer 00017777.

UPDATE scustom SET:  discount  = '003',
                     telephone = '0621/444444'
               WHERE id        = '00017777'.

Chained statements without commas. The colons are all handled like blanks:

DATA: :num :TYPE :i.
ADD :1 TO :num.
num :+= :1.