Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Processing Internal Data →  Internal Tables →  Expressions and Functions for Internal Tables →  table_exp - Table Expressions →  table_exp - itab_line 

Table Expressions, Specified Rows

This example demonstrates how the row is specified in table expressions.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    TRY.
        DATA(out) = cl_demo_output=>new(
          )->begin_section(
          `Primary index line 1`
          )->write(
            flight_tab[ 1 ] ).

        out->next_section(
          `Secondary index CITIES line 1`
          )->write(
            flight_tab[ KEY cities INDEX 1 ] ).

        out->next_section(
          `Free key CARRID, CONNID not optimized`
          )->write(
            flight_tab[ carrid = 'UA'
                        connid = '0941' ] ) ##primkey[id].

        out->next_section(
          `Secondary key ID optimized`
          )->write(
            flight_tab[ KEY id COMPONENTS carrid = 'UA'
                                         connid = '0941' ] ).

        out->next_section(
          `Secondary key CITIES optimized`
          )->write(
            flight_tab[ KEY cities cityfrom = 'FRANKFURT'
                                  cityto   = 'NEW YORK' ] ).

      CATCH cx_sy_itab_line_not_found.
        out->write( `Nothing found` ).
    ENDTRY.
    out->display( ).

Description

Table expressions that specify different rows are used as input parameters of the method WRITE_DATA of the output class CL_DEMO_OUTPUT. The following output is produced:

  • The first row of the primary table index
  • The first row of the secondary table index that is assigned to the secondary table key cities.
  • A row with specific content in the columns CARRID and CONNID. Searches using a free key are not optimized and the associated syntax check warning is hidden here using a pragma.
  • The same row as before, but with a read optimized using the secondary hash key id.
  • A row with specific content in the columns CITYFROM and CITYTO with searches optimized using the secondary sorted key cities.