Skip to content

Prefer READ TABLE to LOOP AT

READ TABLE my_table REFERENCE INTO DATA(line) WITH KEY key = 'A'.

expresses the intent clearer and shorter than

" anti-pattern
LOOP AT my_table REFERENCE INTO DATA(line) WHERE key = 'A'.
  EXIT.
ENDLOOP.

or even

" anti-pattern
LOOP AT my_table REFERENCE INTO DATA(line).
  IF line->key = 'A'.
    EXIT.
  ENDIF.
ENDLOOP.
From SAP/styleguides under CC BY 3.0 — more details
Last updated on