Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Calling and leaving program units →  Calling Processing Blocks →  Calling Procedures →  Method Calls →  Static Method Calls →  ... meth1( ... )->meth2( ... )->... - Method Chaining 

Method Chaining

This example demonstrates method chaining in an operand position.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA oref TYPE REF TO demo.
    CREATE OBJECT oref.
    cl_demo_output=>display(
      oref->meth( `Hello ` )->meth( `world` )->meth( `!` )->text ).

Description

In the argument of the method DISPLAY_TEXT statement, a chained attribute access is performed on the attribute text of the class demo. The attribute is changed by three chained method calls.