SAP ABAP - Nested If Statement
Advertisements
It is always legal to nest IF....ELSE statements, which means you can use one IF or ELSEIF statement inside another IF or ELSEIF statement.
The syntax for a nested IF....ELSE statement is as follows −
IF<condition_1>. <statement block>. IF<condition_2>. <statement block>. ELSE. <statement block>. ENDIF. ELSE <statement block>. ENDIF.
Example
Report YH_SEP_15. Data: Title_1(10) TYPE C, Title_2(15) TYPE C, Title_3(10) TYPE C. Title_1 = 'ABAP'. Title_2 = 'Programming'. Title_3 = 'Tutorial'. IF Title_1 = 'ABAP'. IF Title_2 = 'Programming'. IF Title_3 = 'Tutorial'. Write 'Yes, It’s Correct'. ELSE. Write 'Sorry, It’s Wrong'. ENDIF. ENDIF. ENDIF.
The above code produces the following output −
Yes, It’s Correct.
sap_abap_decisions.htm
Advertisements