Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Obsolete Language Elements →  Obsolete Processing of Internal Data →  Obsolete Extracts 

LOOP - Extract

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Obsolete Syntax

LOOP.
  ...
ENDLOOP.

Effect

The statements LOOP and ENDLOOP define a loop across a statement block. The loop is passed for each row from the extract dataset until it is exited using one of the statements from the section Exit Loops. In each loop pass, the statement LOOP assigns the contents of the components from the current row of the extract dataset to the data objects that make up the field group of the row. If the extract dataset is not sorted, the order in which the rows are read is the same in which they were appended using the statement EXTRACT. If the extract dataset is sorted using SORT, the read order is the same as the sort order.

A LOOP loop also ends the process of structuring the extract dataset. If the statement EXTRACT is executed after the statement LOOP, a non-handleable exception is raised. In addition, it is not possible to edit the extract dataset using either LOOP or SORT within a LOOP block. LOOP blocks that read the extract dataset cannot be nested.

System Fields

sy-subrc Meaning
0 The loop was run at least once.
4 The loop was not run at all.


Notes

  • The statement LOOP for the extract dataset must not be confused with the statement LOOP AT for internal tables.
  • In global classes, no field groups can be defined or edited. In methods of local classes of programs other than class pools, the statement LOOP can be used for field groups defined in these methods.
  • Extracts are obsolete. Internal tables are recommended instead.

Executable Example

Extracts, Processing

Exceptions

Non-Handleable Exceptions

  • Cause: Nested loop at an extracted dataset.
    Runtime error: LOOP_WITHIN_LOOP