Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Meshes →  Meshes - Using Mesh Paths →  INSERT mesh_path 

Insertions in Mesh Paths

This example demonstrates how rows are inserted in mesh paths.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA(out) = cl_demo_output=>new(
      )->begin_section( 'node1'
      )->write( mesh-node1
      )->next_section( 'node2'
      )->write( mesh-node2
      )->next_section( 'node3'
      )->write( mesh-node3 ).

    out->next_section(
      'Inserting One Line Into node1\to_node2' ).
    INSERT VALUE line2( col2 = 3333 ) INTO TABLE
      mesh-node1\to_node2[ mesh-node1[ 1 ] ].
    out->write( mesh-node2 ).

    out->next_section(
      'Inserting Multiple Lines Into node1\to_node2' ).
    INSERT LINES OF VALUE t_itab2( ( col2 = 1 )
                                  ( col2 = 2 )
                                  ( col2 = 3 ) ) INTO TABLE
      mesh-node1\to_node2[ mesh-node1[ 2 ] ].
    out->write( mesh-node2 ).

    out->next_section(
      'Inserting Initial Lines Into node1\to_node2\to_node3' ).
    INSERT INITIAL LINE INTO TABLE
      mesh-node1\to_node2[ mesh-node1[ 3 ] ]\to_node3[ ].
    out->write( mesh-node3 ).

    out->next_section(
      'Inserting  Multiple Lines Into node1\to_node2\to_node3' ).
    INSERT LINES OF VALUE t_itab3( ( col3 = 10 )
                                  ( col3 = 20 )
                                  ( col3 = 30 ) ) INTO TABLE
      mesh-node1\to_node2[ mesh-node1[ 3 ] ]\to_node3[ ].
    out->write( mesh-node3 ).

    out->display( ).

Description

Row insertions are demonstrated using previously filled mesh nodes mesh-node1, mesh-node2, and mesh-node3.

  • The statement INSERT for inserting a work area into a mesh path with an initial association.
INSERT VALUE line2( col2 = 3333 ) INTO TABLE
  mesh-node1\to_node2[ mesh-node1[ 1 ] ].
The work area is created by a constructor expression in which only the component col2 needs to be filled. This is because the other component is filled implicitly when the association is evaluated. If specified in the square brackets of the association, source is a table expression that reads the first row of the root node. In the follow-on node mesh-node2, a row is inserted whose first column matches the initial node and whose third column has a new value.
  • The statement INSERT for inserting the rows of an internal table into a mesh path with an initial association.
INSERT LINES OF VALUE t_itab2( ( col2 = 1 )
                               ( col2 = 2 )
                               ( col2 = 3 ) ) INTO TABLE
  mesh-node1\to_node2[ mesh-node1[ 2 ] ].
The internal table is created by a constructor expression in which only the column col2 needs to be filled. This is because the other component is filled implicitly when the association is evaluated. If specified in the square brackets of the initial association, source is a table expression that reads the second row of the root node. In the follow-on node mesh-node2, rows are inserted whose first column matches the initial node and whose third column has new values.
  • The statement INSERT for inserting initial rows into a mesh path with an path extension.
INSERT INITIAL LINE INTO TABLE
  mesh-node1\to_node2[ mesh-node1[ 3 ] ]\to_node3[ ].
If specified in the square brackets of the initial association, source is a table expression that reads the third row of the root node. Two rows in the follow-on node mesh-node2 match the result of the initial association. Accordingly, two rows are inserted in mesh-node3, where the first two columns are determined by the association and the third column col3 is initial.
  • The statement INSERT for inserting multiple rows into a mesh path with an path extension.
INSERT LINES OF VALUE t_itab3( ( col3 = 10 )
                               ( col3 = 20 )
                               ( col3 = 30 ) ) INTO TABLE
  mesh-node1\to_node2[ mesh-node1[ 3 ] ]\to_node3[ ].
As in the previous step, but here three rows of an internal table are inserted for each described row. Only the value of the third column col3 is taken from the table.