ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Internal Tables → Expressions and Functions for Internal Tables → table_exp - Table Expressions → table_exp - Chainings
Table Expressions, Chainings
This example demonstrates how table expressions are chained.
Other versions:
7.31 | 7.40 | 7.54
Source Code
DATA(out) = cl_demo_output=>new( ).
"Read a column of a nested table with table statements
out->begin_section( `Table Statements` ).
READ TABLE index WITH KEY key1 = 'ASSIGNING'
ASSIGNING FIELD-SYMBOL(<wa1>).
READ TABLE <wa1>-docu_objects WITH KEY key2 = 'READ TABLE itab'
ASSIGNING FIELD-SYMBOL(<wa2>).
IF sy-subrc = 0.
DATA(title1) =
cl_abap_docu=>get_title(
langu = langu
object = <wa2>-docu_name ).
out->write_data( title1 ).
ELSE.
out->write_text( `Nothing found` ).
ENDIF.
"Read a column of a nested table with chained table expressions
out->next_section( `Table Expressions` ).
TRY.
DATA(title2) =
cl_abap_docu=>get_title(
langu = langu
object = index[ key1 = 'ASSIGNING'
]-docu_objects[ key2 = 'READ TABLE itab'
]-docu_name ).
out->write_data( title2 ).
CATCH cx_sy_itab_line_not_found ##no_handler.
out->write_text( `Nothing found` ).
ENDTRY.
out->display( ).
Description
The example shows a read performed on a nested internal table using the statement READ TABLE
and using a chained
table expression.
- Reads performed using statements require the statement
READ TABLE
to be used twice and two explicitly declared field symbols. The first field symbol,wa1
, is used in the secondREAD
statement and the second field symbol,wa2
, is used to pass the result to a method.
- When reads are performed using table expressions, the expressions can be chained and passed to the method directly. No explicitly declared field symbols are required.
The result of both reads is the same.