READ TABLE - index

Syntax

... INDEX idx ... .

Effect:

In standard tables and sorted tables, the table index of the row to be read can be specified explicitly in idx. For idx, a data object of type i is expected.

If the value of idx is smaller than or equal to 0, or greater than the number of rows in the table, no line is read and sy-subrc is set to 4.

Example:

Reading the first ten lines of the internal table sflight_tab using the index. Instead of the DO loop, the LOOP loop can also be used for this purpose.

DATA: sflight_tab TYPE SORTED TABLE OF sflight
                  WITH NON-UNIQUE KEY seatsocc,
      sflight_wa  LIKE LINE OF sflight_tab.

...

SELECT *
       FROM sflight
       INTO TABLE sflight_tab
       WHERE carrid = 'LH' AND
             connid = '400'.

...

DO 10 TIMES.
  READ TABLE sflight_tab INDEX sy-index INTO sflight_wa.
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.
  ...
ENDDO.