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 listed separately, divided by commas (,) and closed with a period (.). When the syntax is checked and the program executed, the chained statement is handled the same way as the single ABAP statements would be in their defined sequence.

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 key word.

  • When using chained statements, make sure not to mistakenly produce any syntactically correct statements with 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.

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 the key word is truncated:

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 Open SQL:

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

The code fragment does not represent an individual statement that updates the discount and phone number of customer 00017777. Instead, these are two statements. The first changes the discount for all customers and the second changes the phone number of customer 00017777.