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 addition n TIMES limits the amount of loop passes. n
is a numerical expression
position of operand type i .
The numerical value of n when entering the loop determines the
maximum amount of passes of the statement block. The control structure
ignores changes to the value n within the loop. If n
contains a value less than or equal to 0, the statement block is not
executed.
Latest notes: If the addition n TIMES is not specified, the loop
has to be terminated by a statement; otherwise the loop is processed
endlessly. The profile parameter
rdisp/max_wprun_time limits the
maximum execution time of an ABAP program.
The obsolete addition varying can be
used to process a sequence of data objects in the memory.
Example ABAP Coding Calculation and output of the first ten square numbers
in a DO loop.
DATA square TYPE i.
DO 10 TIMES.
square = ipow( base = sy-index exp = 2 ).
cl_demo_output=>write( |{ sy-index } { square }| ).
ENDDO.
cl_demo_output=>display( ).
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved