SAP ABAP Syntax for DO part one
1. DO.
2. DO n TIMES.
Variant 1
DO.
Addition
... VARYING f FROM f1 NEXT f2
Effect
Repeats the processing enclosed by the DO and ENDDO statements until the loop is terminated by EXIT , STOP or REJECT .
You can use the CONTINUE statement to end the current loop pass prematurely and continue with the next loop pass.
The system field SY-INDEX counts the number of loop passes, starting from 1. You can nest DO loops. When the processing leaves a DO loop, the value of SY-INDEX belonging to the outer DO loop is restored.
Example
DO. WRITE: / 'SY-INDEX - Begin:', (3) SY-INDEX. IF SY-INDEX = 10. EXIT. ENDIF. WRITE: 'End:', (3) SY-INDEX.ENDDO.
This DO loop outputs 9 lines of the form
" SY-INDEX - Begin: n End: n ".
Here, n stands for the numbers 1 to 9.
The last line displayed is
" SY-INDEX - Begin: 10 ".
On the 10th pass, the loop is terminated.
Note
The danger with this statement is programming endless loops. Therefore, you must ensure that the loop contains at least one EXIT , STOP or REJECT statement which is executed at least once.



0 comments:
Post a Comment