Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Meshes →  Meshes - Using Mesh Paths →  LOOP AT mesh_path 

Loops Across Mesh Paths

This example demonstrates loops across mesh paths.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    input( ).

    TRY.

        out->begin_section(
          'Initial Association SCARR\_spfli' ).
        LOOP AT
          flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                                 WHERE countryto = country  ]
             INTO DATA(spfli_wa).
          out->write( spfli_wa ).
        ENDLOOP.

        out->next_section(
          'Chained Association SCARR\_spfli\_sairport' ).
        LOOP AT
          flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                                 WHERE countryto = country
                               ]\_sairport[ USING KEY primary_key ]
             INTO DATA(sairport_wa).
          out->write( sairport_wa ).
        ENDLOOP.

        out->next_section(
          'Chained Association' &&
          ' SCARR\_spfli\_sflight\^_sflight~spfli' ).
        LOOP AT
          flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                                 WHERE countryto = country
                                ]\_sflight[
                                 WHERE planetype = plane1 OR
                                       planetype = plane2
                                ]\^_sflight~spfli[ ]
             ASSIGNING FIELD-SYMBOL(<spfli_wa>).
          out->write( <spfli_wa> ).
        ENDLOOP.

      CATCH cx_sy_itab_line_not_found.
        out->write( 'Exception!' ).
    ENDTRY.
    out->display( ).

Description

Loops are performed across the following mesh paths:

  • Mesh path with forward association as its initial mesh association. The source in the square brackets is a table expression, plus a WHERE condition.
flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                      WHERE countryto = country  ]
The results set consists of all rows of the node spfli that meet the condition.
  • Mesh path with forward associations as its initial mesh association and path extension. The source in the square brackets of the initial mesh association is a table expression, plus a WHERE condition. A key is specified in the square brackets of the path extension for evaluating the mesh association.
flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                      WHERE countryto = country
                    ]\_sairport[ USING KEY primary_key ]
The results set consists of all rows of the node sairport that match the column airpfrom in the results set of the source node spfli. Duplicate rows are removed automatically.
  • Mesh path with forward associations as its initial mesh association and two path extensions. The last path extension is an inverse mesh association that leads back to the source node.
flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                      WHERE countryto = country
                    ]\_sflight[
                      HERE planetype = plane1 OR
                           planetype = plane2
                      ]\^_sflight~spfli[ ]
The results set consists of all rows of the node spfli for which the rows in the results set of sflight have specific values in the column plane_type.

See also the executable example for table comprehensions for meshes.

Effect