ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Meshes → Meshes - Using Mesh Paths → Mesh Path Expressions
Mesh Path Expressions
This example demonstrates how mesh paths can be used as standalone expressions.
Other versions:
7.31 | 7.40 | 7.54
Source Code
input( ).
TRY.
out->begin_section(
'Forward Association scarr\to_spfli' ).
DATA(spfli_wa) =
flights-scarr\to_spfli[ flights-scarr[ carrname = name ]
connid = connection ].
out->write( spfli_wa ).
out->next_section(
'Inverse Association spfli\^to_spfli~scarr' ).
DATA(scarr_wa) =
flights-spfli\^to_spfli~scarr[
flights-spfli[ carrid = ID connid = CONNECTION ] ].
out->write( scarr_wa ).
out->next_section(
'Chained Association scarr\to_spfli\to_sflight' ).
DATA(sflight_wa) =
flights-scarr\to_spfli[ flights-scarr[ carrname = name ]
connid = connection
]\to_sflight[ fldate = date ].
out->write( sflight_wa ).
out->next_section(
'Addressing Component' ).
DATA(price) =
flights-scarr\to_spfli[ flights-scarr[ carrname = name ]
connid = connection
]\to_sflight[ fldate = date ]-price.
out->write( price ).
out->next_section(
'Assigning to Field Symbol' ).
ASSIGN
flights-scarr\to_spfli[ flights-scarr[ carrname = NAME ]
connid = CONNECTION
]\to_sflight[ fldate = DATE ]
TO FIELD-SYMBOL(<sflight_wa>).
IF sy-subrc = 0.
out->write( 'Field symbol OK' ).
ENDIF.
out->next_section(
'Write Access and Check Existence' ).
flights-scarr\to_spfli[ flights-scarr[ carrname = NAME ]
connid = CONNECTION
]\to_sflight[ fldate = DATE
]-price = price - 10.
IF line_exists(
flights-scarr\to_spfli[ flights-scarr[ carrname = name ]
connid = connection
]\to_sflight[ fldate = date
price = price - 10 ] ).
out->write( 'Line found!' ).
ENDIF.
CATCH cx_sy_itab_line_not_found.
out->write( 'Exception!' ).
ENDTRY.
out->display( ).
Description
The following mesh paths are used as mesh path expressions:
- Mesh path with forward association as an initial association on the right side of an assignment. The source in the square brackets is a table expression, plus a condition.
connid = connection ]
- Mesh path with inverse association as an initial association on the right side of an assignment. The source in the square brackets is a table expression.
connid = CONNECTION ] ]
- Mesh path with path extension after the initial association on the right side of an assignment.
connid = connection
]\to_sflight[ fldate = date ]
The mesh path with path extension is also used to demonstrate the addressing of a component using the
structure component selector, assignments to a field symbol, reads, and usage in the predicate function line_exists
.