SAP ABAP SYNTAX FOR ELSE AND ELSE IF

Basic form

ELSE.

Effect

Within an " IF ... ENDIF " processing block, precedes the code to be executed if the logical expression specified by IF fails.

Example

DATA: RESULT TYPE I,
OP1 TYPE I,
OP2 TYPE I.
...
RESULT = OP1 - OP2.
IF RESULT > 0.

WRITE / 'Result greater than zero.'.
ELSE.
WRITE / 'Result less or equal zero.'.
ENDIF.

Depending on the value of RESULT , both different texts are output.

ELSE IF

ELSEIF logexp.

Effect

Within a processing block enclosed by " IF ... ENDIF ", this statement indicates the processing to be executed if the logical expressions specified by IF and the preceding ELSEIF s are false, but the logical exprEssion in this ELSEIF processing block is true.

Between the IF and ENDIF statements, there may be any number of ELSEIF s. These may be followed, optionally, by an ELSE statement, but this is executed only if none of the logical
expressions under IF or ELSEIF is true.

Example

DATA RESULT TYPE I.
...
IF RESULT < 0. WRITE / 'Result less than zero'. ELSEIF RESULT = 0. WRITE / 'Result equal zero'. ELSE. WRITE / 'Result greater than zero'. ENDIF. Depending on the value of RESULT , the three different texts are output. RELATED POST

SAP ABAP SYNTAX FOR EDITOR CALL PART TWO
MySAP CRM Marketing Introduction
Marketing and Advertizing in CRM
MySAP CRM Marketing Calender

No comments :

Post a Comment