WHILE log_exp [vary]
[statement_block]
ENDWHILE.
The statements WHILE and ENDWHILE define a control structure that can contain a closed statement block statement_block. After WHILE, any logical expression log_exp can follow.
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
EXIT statement is perfect for completely exiting a loop. Within the statement block,
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.
The obsolete addition vary can be used to process a sequence of objects in the memory.
Replace all blank characters with hyphens in a character-type data object text. Since release 6.10 and later, you can achieve the same effect using the addition ALL OCCURRENCES of the statement REPLACE.
DATA text TYPE string VALUE `One Two Three`.
WHILE sy-subrc = 0.
REPLACE space WITH '-' INTO text.
ENDWHILE.