SAP TABLE EXP CHAINING



Get Example source ABAP code based on a different SAP table
  



ABAP_ITABEXP - Chainings
Table expressions can be chained with the structure component selector -, with other table expressions, and with the object component selector ->.
ITOC
If the constructor operator VALUE or REF is specified before a chaining to control the result, only the final result is affected. Any intermediate results are always temporary field symbols and the corresponding performance notes should be considered.



Latest notes:

Chainings of table expressions with functional method calls, that is, specifying the internal table as a functional method call meth( ... )[ ... ] or meth( ... )-comp[ ... ] and accessing the internal table using a chained attribute access meth( ... )->itab[ ... ], are not yet possible. Table expressions cannot currently be placed on the right of a method call in method chainings.
NON_V5_HINTS
ABAP_HINT_END

Chainings with the Structure Component Selector
A table expression can be chained as follows using the structure component selector -:
If the result of a table expression itab[ ... ] is a structure, the structure component selector can be used to read each component comp of the structure: ... itab[ ... ]-comp ... If comp has a suitable type, a specified offset/length +off(len) can be appended, except when the chaining is used as a memory area of the statement ASSIGN or as an argument of the reference operator REF.
If a structure struct has a table-like component comp, it can be specified as the name of the internal table of a table expression: ... struct-comp[ ... ] ...
Both of these alternatives can be combined, enabling a structured component selector to be located directly on the left and right of a table expression.



Latest notes:

If the reference operator REF is specified in front of a chaining whose result is a component of a structured table line, it creates a reference to this component.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Reading of the first column of the second line of the table-like second component of the first line of the internal table itab. The result is 4.
ABEXA 01331
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
Table Expressions, Chainings
ABAP_EXAMPLE_END

Chainings with Table Expressions
If the result of a table expression itab[ ... ] is an internal table, it can be used as the name of the internal table of a table expression:
... itab[ ... ][ ... ] ...
An expression of this type can
itself be continued with square brackets [ ... ], if its result is again table-like.
be combined with the information from structure component selectors above.

ABAP_EXAMPLE_VX5
In an internal table nested twice, reads the first line of the innermost table in the second line of the center table in the second line of the outermost table. The result is 7.
ABEXA 01332
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
Direct chaining of table expressions and chaining with the structure component selector in a single expression. Reading of the structure component of the innermost nested table with the value 13.
ABEXA 01333
ABAP_EXAMPLE_END

Chainings with the Object Component Selector
If the result of a table expression or one of the preceding chainings has a reference type, these chainings can be placed directly in front of the object component selector to access the components of the referenced object:
... itab[ ... ]->comp ...
... itab[ ... ]-comp->comp ...
... struct-comp[ ... ]->comp ...
... itab[ ... ][ ... ]->comp ...
A component addressed in this way can, depending on its design, be used in all suitable operand positions and particularly in further chainings.



Latest notes:

More specifically, the dereferencing operator ->* can be specified after table expressions.
An instance method call can be a standalone call or a functional method call. The obsolete form of the statement CALL METHOD cannot be used.
No table expressions can be specified in a write position for a read-only internal table. This also applies when the object component selector is used to access another object. Furthermore, standalone method calls a not possible using a read-only internal table.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Dereferencing a line of an internal table of data reference variables and accessing a single component.
ABEXA 01334
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
Filling of an internal table of reference variables with object references and accessing attributes and methods of the objects using table expressions in front of the object component selector.
ABEXA 01335
ABAP_EXAMPLE_END