SAP IF ABAP Statements

Get Example source ABAP code based on a different SAP table

Standard SAP Help for IF


Short Reference
• IF ABAP Statement

ABAP Syntax IF log_exp1.

[ELSEIF log_exp2.

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 IFstatement, 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'.
|{ time TIME = ISO } AM| ).
ELSEIF time > '120000' AND
time <(><<)> '240000'.
|{ CONV t( time - 12 * 3600 ) TIME = ISO } PM| ).
|High Noon| ).

See also the example for COND .

Return to menu