Loops and Loop Controls in SAP ABAP

Author | Last Updated| | 0 Comments Facebook Share Twitter Share Google Plus Share A+ A-

Working with loops and loop controls in SAP ABAP, using continue, check and exit inside loops in SAP ABAP

Loops and loop controls are the most widely used programming methods in SAP ABAP, these are useful when you wants to execute a code block multiple times and you can use loop controls to do some operations inside the repetitive code block.

Below are the types of loops available in SAP ABAP

Loop Usage
WHILE loop Repeats a statement or group of statements when a given condition is true. It tests the condition before executing the loop body.
DO loop The DO statement is useful for repeating particular task a specific number of times.
Nested loop You may use one or more loops inside any another WHILE or DO loop.

WHILE syntax

WHILE <logical expression>
<statement block>.


DO syntax

<statement block>.

Loop Control Statements

Loop control statements change execution from its normal sequence. ABAP includes control statements that allow loops to be ended prematurely. It supports the following control statements.

Statement Description
CONTINUE Causes the loop to skip the remainder of its body and starts the next loop pass.
CHECK If the condition is false, then the remaining statements after the CHECK are just ignored and the system starts the next loop pass.
EXIT Terminates the loop entirely and transfers execution to the statement immediately following the loop.

Tutorial Comments

Total Comments: Add your Comment

Leave a Comment

Enter Comment Text