In some scenarios, specific iteration execution needs to be skipped, bypassed or interrupted. Loop control statements used to support to skip the execution of statements block when specific conditions met.
Loop control statements ends the loops early than the expected. Generally, loop control statements comes up along with a condition. The condition describes when the loop to be skipped, bypassed or interrupted.
If the specified condition is true, the corresponding iteration or entire iterations get skipped or bypassed.
Below diagram decribes the flowchart of loop control statement –
- Looping condition – specifies the condition with loop statement(DO/WHILE).
- Loop control statement – specifies the condition with loop control statement.
Execution steps –
Step1 – If the looping condition is true, then loop control condition gets validated.
Step2 – If loop control condition is true, the iteration/loop gets skipped, bypassed or interrupted.
Step3 – If loop control condition is false, statements-block1 gets executed and control goes to validate looping condition again.
Step4 – step-1 to step-3 gets executed repeatedly until the loop condition is false.
Step5 – If loop condition is false, statements-block2 gets executed and control transfers to next executable statements if any.
Below are the list of loop control statements in ABAP –
Control Statement | Description |
---|---|
CONTINUE | Skips the next remaining statements in the current iteration and control passes to the Condition to validate for next iteration. |
CHECK | If CHECK condition is true, then the following statements after the CHECK are executed and control passes to the next loop. If CHECK condition is false, then the following statements after the CHECK are just ignored and control passes to the next loop. |
EXIT | Terminates the loop completely and transfers control to the statement immediately next to the loop. |