sapdev logo background
sapdev logo sapdev logo
Comments

SAP CHAINED STATEMENTS documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

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.
ABAP_PGL 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 those of Open SQL , 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.
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




    CHAINED_NAME_GLOSRY
    CHAINED_STATEMENTS_GUIDL




    comments powered by Disqus