Ansicht
Dokumentation
ABAPCALL_METHOD_STATIC_CHAIN - CALL METHOD STATIC CHAIN
SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up rdisp/max_wprun_time - Maximum work process run timeThis documentation is copyright by SAP AG.
... meth1( ... )->meth2( ... )->..., Method Chaining
... ${ meth( ... )->
meth1( ... )->meth2( ... )->...->methn( ... ) $}
$| ${ meth( ... )->meth1( ... )->meth2( ... )->...->attr $} ...
Alternatives:
1. meth( ... )->meth1( ... )->meth2( ... )->...->methn( ... )
2. meth( ... )->meth1( ... )->meth2( ... )->...->attr
Effect
Chaining of static method calls to a chained method call or a chained attribute access. meth, meth1, meth2, ..., expect functional methods whose return values are reference variables that point to objects with the next method in question. All methods that follow meth must be called using the object component selector.
The parameters are passed to the functional methods meth, meth1, meth2, ... using the syntax valid for functional method calls.
System Fields
Each method call sets the system field sy-subrc to 0 in the moment the method is called.
Alternative 1
meth( ... )->meth1( ... )->meth2( ... )->...->methn( ... )
Effect
Chained method call. Call of the instance method methn in an object. The reference variable for the object is the return value of the preceding method chaining.
A chained method call can be specified as a standalone statement or as a functional method call in a suitable operand position. The relevant rules apply in parameter passing to meth.
If the return value of the last method has a structured data type, the chained method call can, like a structure, be listed in front of the structure component selector - and be used to access a component of the structure.
Note
In methn, a constructor expression can be specified with a constructor operator NEW or CAST for oref not only in a functional call, but also in standalone statements.
Example
Call of the method m3 in an object of the class c3 that is addressed using method chaining.
Alternative 2
meth( ... )->meth1( ... )->meth2( ... )->...->attr
Effect
Chained attribute access. Access to the instance attribute attr in an object. The reference variable for the object is the return value of the preceding method chaining.
If the attribute has a structured data type, the chained attribute access can, like a structure, be listed in front of the structure component selector - and be used to access a component of the structure.
Chained attribute access can currently only be specified in suitable
read positions. Writes to an attribute addressed using method chaining are not yet possible.
Example
Chained attribute access in executable example program DEMO_METHOD_CHAINING.
cl_demo_output=>display(
oref->meth( `Hello ` )->meth( `world` )->meth( `!` )->text ).
CL_GUI_FRONTEND_SERVICES - Frontend Services BAL Application Log Documentation
This documentation is copyright by SAP AG.
Length: 5272 Date: 20240427 Time: 031909 sap01-206 ( 75 ms )