IF
Short Reference
ABAP Syntax IF log_exp1 .
[statement_block1]
[ELSEIF log_exp2 .
[statement_block2]]
...
[ELSE.
[statement_blockn]]
ENDIF.
What does it do? These statements define a control structure which can
contain multiple statement blocks statement_block of which a
maximum of one will be executed in conjunction with logical expressions
log_exp .
After IF and ELSEIF any logical expressions
log_exp can be executed while the expressions
statement_block stand for any statement blocks.
The logical expressions, beginning with the IF statement, are
checked from top to bottom and the statement block after the first is
executed during the logical expression. If none of the logical
expressions are true, the statement block after the ELSE
statement is executed.
When the end of the statement block is reached or if no statement
block is to be executed, the processing is continued after ENDIF .
Latest notes: Furthermore, the
conditional operator COND
can also be used to implement branches in operand positions that are
based on logical expressions.
Example ABAP Coding Converts a time output into the 12-hour format (see also
Country-Specific Formats ).
DATA time TYPE t.
fltime = sy-time.
IF time <(><<)> '120000'.
cl_demo_output=>display(
|{ time TIME = ISO } AM| ).
ELSEIF time > '120000' AND
time <(><<)> '240000'.
cl_demo_output=>display(
|{ CONV t( time - 12 * 3600 ) TIME = ISO } PM| ).
ELSE.
cl_demo_output=>display(
|High Noon| ).
ENDIF.
See also the example for COND
.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved