LOOP.
...
ENDLOOP.
The LOOP and ENDLOOP statements define a a loop around a statement block. The loop is passed for each row from the Extract dataset, until it is ended with one of the statements from the section Loops. During each loop pass, the LOOP statement 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 sequence in which the rows are read is the same in which they were appended with the EXTRACT statement. If the extract dataset is sorted with SORT, the read sequence is the same as the sort sequence.
A LOOP-Loop also ends the process of setting up the extract
dataset. If you execute an EXTRACT statement after a
LOOP statement, an untreatable exception occurs. In addition, you cannot process the extract
dataset with either LOOP or
SORT within a LOOP block. You cannot nest LOOP blocks that read the extract dataset.
System fields
sy-subrc | Relevance |
0 | The loop was run at least once. |
4 | The loop was not run at all. |
Do not confuse the LOOP statement for the extract dataset
with the LOOP AT statement for internal tables.
See AT.
Non-Catchable Exceptions