The statement block is repeated as long as the logical expression is true, or until it is exited with
one of the statements to leave loops. In particular, the statement
EXIT is ideal for exiting a loop completely. Within the statement block, the system field
sy-index contains the number of previous loop passes, including the current pass. In nested loops,
sy-index always refers to the current loop.
- A maximum runtime can be configured using the profile parameters rdisp/scheduler/prio_low/max_runtime, rdisp/scheduler/prio_normal/max_runtime, and rdisp/scheduler/prio_high/max_runtime. If this runtime is exceeded because the logical expression is never false and the loop is not exited in any other way, the program is ended by the runtime environment. The profile parameter rdisp/max_wprun_time, on the other hand, is obsolete.
WHILEloops are used to construct values or fill internal tables, they can probably be expressed more elegantly using conditional iterations with
FORin constructor expressions.
The obsolete addition
VARYcan be used to process a sequence of data objects in the memory.
Fills an internal table with 100 rows.
DATA itab TYPE TABLE OF i. WHILE lines( itab ) < 100. itab = VALUE #( BASE itab ( sy-index ) ). ENDWHILE.