SAP LOOP- ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• LOOP - extract ABAP Statement

LOOP, Extract
Short Reference

ABAP_SYNTAX_OBS
LOOP.
...
ENDLOOP.

What does it do?
The statements LOOP and ENDLOOP define a loop across a statement block. The loop is passed for each line from the extract dataset. In each loop pass, the statement LOOP assigns the content of the components from the current line of the extract dataset to the data objects that make up the field group of the line. If the extract dataset is not sorted, the order in which the lines 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 simultaneously ends the construction of the extract dataset. If the statement EXTRACT is executed after the statement LOOP, an uncatchable exception is raised. In addition, it is not possible to process the extract dataset using either LOOP or SORT within a LOOP block. LOOP blocks that read the extract dataset must not be nested.
The loop can be exited with one of the following statements: