Decision control statements are used to execute block of statements only when certain conditions are met.
The conditions are coded along with decision control statements. The block of statements under decision control statement always executes when the condition is determined as true.
The block of statements executes only once even the condition is determined as true. Decision control statements can be coded with one or more conditions together.
Decision control statements should have one condition at least. Condition can be either a combination of two operands with relational operator in between or one operand, value with relational operator in between.
ABAP supports various decision control statements. Below diagram provides the flow of simple decision control statement.
In the flow, if the specified condition is determined as true, then the statements-set1 gets executed. Next the control flow goes to the statements-set2.
If the specified condition is determined as false, then the control directly transfers to statements-set2 directly.
ABAP programming language supports the below list of decision control statements –
Statement | Description |
---|---|
IF Statement | IF statement consists one or more logical expressions/Conditions followed by one or more statements. |
IF ELSE Statement | IF statement followed by ELSE statement that executes when the logical expression/condition is false. |
Nested IF Statement | IF Statement contains another IF statement within when multiple logical expressions/conditions requires to be validated in hierarchy. |
CASE Statement | CASE statement used to validate more than one logical expressions/conditions at the same level. |