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
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
Instead of the loop shown here for demonstartion purposes, in a productive program the ALL
OCCURRENCES addition of the statement
REPLACE or the built-in
function with the value 0 for the argument
occ should be used for this task.
DATA text TYPE string VALUE `One Two Three`. WHILE sy-subrc = 0. REPLACE ` ` IN text WITH `-`. ENDWHILE.