Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Assignments →  Assigning Components →  Assigning Components: Examples 

Component Operator, Reflexive Assignment

This example demonstrates the component operator with FROM USING for a single table.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA(out) = cl_demo_output=>new( ).

    out->begin_section( `itab`
      )->write( itab ).


    itab = CORRESPONDING #(
              itab FROM itab
                   USING node = parent ) ##operator.
    out->next_section(
      `itab = CORRESPONDING #( itab FROM itab USING node = parent )`
      )->write( itab ).

    out->display( ).

Description

The example associates an internal table itab in a component expression using the component operator CORRESPONDING (which uses the components of two arguments) with itself and assigns the result to the same table. This requires a temporary copy of the table to be created, which raises a warning from the syntax check. This warning can be hidden using the pragma ##operator.

The table contains a hierarchical tree structure in which nodes of the column node are assigned to a top node using the column parent. This relationship is specified after USING, which finds the top node for every row. The assignment of the identically named component text ensures that every row in this column is given the content of its direct top node.