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\to_spfli' ).
LOOP AT
flights-scarr\to_spfli[ flights-scarr[ carrname = name ]
WHERE countryto = country ]
INTO DATA(spfli_wa).
out->write( spfli_wa ).
ENDLOOP.
out->next_section(
'Chained Association SCARR\to_spfli\to_sairport' ).
LOOP AT
flights-scarr\to_spfli[ flights-scarr[ carrname = name ]
WHERE countryto = country
]\to_sairport[ USING KEY primary_key ]
INTO DATA(sairport_wa).
out->write( sairport_wa ).
ENDLOOP.
out->next_section(
'Chained Association' &&
' SCARR\to_spfli\to_sflight\^to_sflight~spfli' ).
LOOP AT
flights-scarr\to_spfli[ flights-scarr[ carrname = name ]
WHERE countryto = country
]\to_sflight[
WHERE planetype = plane1 OR
planetype = plane2
]\^to_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 association. The source in the square brackets is a table expression, plus a
WHERE
condition.
WHERE countryto = country ]
spfli
that meet the condition.
- Mesh path with forward associations as its initial association and path extension. The source in
the square brackets of the initial association is a table expression, plus a
WHERE
condition. A key is specified in the square brackets of the path extension for evaluating the association.
WHERE countryto = country
]\to_sairport[ USING KEY primary_key ]
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 association and two path extensions. The last path extension is an inverse association that leads back to the source node.
WHERE countryto = country
]\to_sflight[
WHERE planetype = plane1 OR
planetype = plane2
]\^to_sflight~spfli[ ]
spfli
for which the rows
in the results set of sflight
have specific values in the column plane_type
.
See also the example for table comprehensions for meshes.