DO [n TIMES] [varying].
The statements DO and ENDDO define a control structure, which can contain a closed statement block statement_block .
Without the addition n TIMES ,the statement block will be repeated until one of the statements termination of loops terminates the loop. Especially the statement EXIT is intended to completely terminate loops. Within the statement block, the system field sy-index contains the number of accomplished loop passes (inclusive current loop) . In nested loops, sy-index always refers to the current loop.
With the addition n TIMES you can limit the amount of loop passes. n expects a data object of the data type i. The numerical value of n at entry in the loop determines the maximum amount of passes of the statement block. The control structure does not accept a change of the value n within the loop. If n contains a value less than or equal to 0, the statement block will not be executed.
Using the obsolete addition varying, a sequence of data objects can be processed in the memory.
If the addition n TIMES is not specified, the loop has to be terminated by a statement; otherwise the loop will be processed endlessly. The
profile parameter rdisp/max_wprun_time limits the maximum execution time of an ABAP program.
calculation and output of the first ten square numbers in a DO-loop.
DATA square TYPE i.
DO 10 TIMES.
square = sy-index ** 2.
WRITE: / sy-index, square.