Skip to content

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\_spfli' ).
        DATA(spfli_wa) =
          flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                                 connid = connection ].
        out->write( spfli_wa ).

        out->next_section(
          'Inverse Association spfli\^_spfli~scarr' ).
        DATA(scarr_wa) =
          flights-spfli\^_spfli~scarr[
            flights-spfli[ carrid = ID connid = CONNECTION ] ].
        out->write( scarr_wa ).

        out->next_section(
          'Chained Association scarr\_spfli\_sflight' ).
        DATA(sflight_wa) =
          flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                                 connid = connection
                               ]\_sflight[ fldate = date ].
        out->write( sflight_wa ).

        out->next_section(
          'Addressing Component' ).
        DATA(price) =
          flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                                 connid = connection
                               ]\_sflight[ fldate = date ]-price.
        out->write( price ).

        out->next_section(
          'Assigning to Field Symbol' ).
        ASSIGN
          flights-scarr\_spfli[ flights-scarr[ carrname = NAME ]
                                 connid = CONNECTION
                               ]\_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\_spfli[ flights-scarr[ carrname = NAME ]
                                connid = CONNECTION
                              ]\_sflight[ fldate = DATE
                              ]-price = price - 10.
        IF line_exists(
          flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                                 connid = connection
                               ]\_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 mesh association on the right side of an assignment. The source in the square brackets is a table expression, plus a condition.
flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                                     connid = connection ]
  • Mesh path with mesh inverse association as an initial mesh association on the right side of an assignment. The source in the square brackets is a table expression.
flights-spfli\^_spfli~scarr[ flights-spfli[ carrid = ID
                                            connid = CONNECTION ] ]
  • Mesh path with path extension after the initial mesh association on the right side of an assignment.
flights-scarr\_spfli[ flights-scarr[ carrname = name ]
                                     connid = connection
                                   ]\_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.