IF


Basic form

IF logexp.

Effect

Used for case distinction.

Depending on whether the logical expression logexp is true or not, this statement triggers the execution of various sections of code enclosed by IF and ENDIF .

There are three different types:
IF logexp.
processing1
ENDIF.

If the logical expression is true, processing1 is executed. Otherwise, the program resumes immediately after ENDIF .
IF logexp.
processing1
ELSE.
processing2
ENDIF.

If the logical expression is true, processing1 is executed. Otherwise, processing2 is executed (see ELSE ).
IF logexp1.
processing1
ELSEIF logexp2.
processing2
ELSEIF ...
...
ELSE.
processingN
ENDIF.

If the logexp1 is false, logexp2 is evaluated and so on. You can use any number of ELSEIF statements. If an ELSE statement exists, it always appears after all the ELSEIF statements.

Notes

All IF statements must be concluded in the same processing block by ENDIF .
IF statements can be nested as mayn times as you like.
The IF statement does not directly affect the selection. For this purpose, you should use the CHECK statement.


Index
© SAP AG 1996