11. Control Statements Flashcards
SY-FDPOS statement
Occurrence after certain operations on character-like or byte-like data objects (for example FIND or Comparisons). Is set after each string comparison. Depending on the type and outcome of the string comparison operation, SY-FDPOS is either set to the length of one string, or to the offset of one string within another.
CASE statement
The CASE statement is used to distinguish between mutually exclusive options. It is used when a single variable can take on one of several known values.
WHEN clause
Is used with the case statement. Each of the possible known values is specified in a WHEN clause, which heads a block of code to be executed when the variable takes on that value.
WHEN OTHERS clause
The WHEN OTHERS clause can be used to provide a default action if the variable does not equal one of the specified values. It is good programming practice to include a WHEN OTHERS clause in a CASE statement.
DO loop
A DO loop is used to unconditionally execute a block of code multiple times. By default, a DO statement creates an infinite loop. Ref.
it is possible to terminate a DO loop by issuing one of the following statements inside the loop
EXIT, STOP, or REJECT.
WHILE
a WHILE loop conditionally executes a block of code, possibly multiple times.
The WHILE statement must always be followed by a logical expression. Before each loop iteration (including the first), the logical expression is evaluated.
SY-INDEX
The system variable SY-INDEX represents the index of the current loop pass (starting with 1 for the first loop pass). Outside a loop, SY-INDEX is zero.
CHECK statement- true
The CHECK statement is used to test a logical expression. If the logical expression of a CHECK statement evaluates to true, processing continues as if the CHECK statement was not there. If the logical expression of a CHECK statement evaluates to false, processing proceeds in one of three ways, depending on the context of the CHECK statement:
Check statement-false
If the logical expression of a CHECK statement evaluates to false, processing proceeds in one of three ways, depending on the context of the CHECK statement:
• If the CHECK statement is in a loop, control immediately returns to the top of the loop for
the next loop pass. If the loop was already in its last iteration, the loop terminates.
• If the CHECK statement is outside a loop but within a subroutine, the subroutine
immediately terminates, and control returns to the calling module.
• If the CHECK statement is outside a loop and outside a subroutine, the current
processing event immediately terminates.
EXIT statement
The EXIT statement unconditionally terminates a loop, subroutine, or program.
CONTINUE statement
The CONTINUE statement is used inside a loop. CONTINUE unconditionally returns control to the top of the loop for the next loop pass. If the loop was already in its last iteration, the loop terminates.
IF statement
The IF statement is used to ensure statements are executed only if certain conditions are met