ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Assignments → Assigning Components → Assigning Components: Examples
Component Operator for Internal Tables
This example demonstrates the component operator for internal tables.
Other versions:
7.31 | 7.40 | 7.54
Source Code
out = cl_demo_output=>new( ).
fill_tables( ).
out->begin_section( `itab1` ).
display_table1( ).
out->next_section( `itab2` ).
display_table2( ).
DATA(base) = itab2.
out->begin_section(
`CORRESPONDING itab2( itab1 )` ).
itab2 = CORRESPONDING #( itab1 ).
display_table2( ).
out->next_section(
`CORRESPONDING itab2( BASE ( itab2 ) itab1 )` ).
itab2 = CORRESPONDING #( BASE ( base ) itab1 ).
display_table2( ).
out->next_section(
`CORRESPONDING itab2( DEEP itab1 )` ).
itab2 = CORRESPONDING #( DEEP itab1 ).
display_table2( ).
out->next_section(
`CORRESPONDING itab2( DEEP BASE ( itab2 ) itab1 )` ).
itab2 = CORRESPONDING #( DEEP BASE ( base ) itab1 ).
display_table2( ).
out->display( ).
Description
This example uses the same internal tables as the
example for MOVE-CORRESPONDING
.
Here, the source table itab1
is used as a parameter of a constructor expression
with the component operator CORRESPONDING
and the result is assigned to the
target table itab2
. The source table itab1
is
assigned to the result with the type of itab2
, both with and without the
addition DEEP
. If the addition BASE
is used, the
result is given the original value of itab2
as its start value and otherwise stays initial. The assignment is made exactly as described in the
example for MOVE-CORRESPONDING
with or without EXPANDING NESTED TABLES
. The component selector with the
addition BASE
has the same effect as using MOVE-CORRESPONDING
with the addition KEEPING TARGET LINES
. If DEEP
is used the name comparison is made for the components of the substructure col3
. This is why fewer assignments are made than when omitting DEEP
.
The uninvolved component col4
keeps its initial value in the new rows in both examples. The result is assigned to the target table itab2
. Unlike in the
example for structures, the final results
for MOVE-CORRESPONDING
and the component selector CORRESPONDING
are the same, since assignments are made to initial new rows in both cases.