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

Useful Video Courses


Video

SAPUI5 Online Training

25 Lectures 6 hours

Sanjo Thomas

Video

SAP Webi Online Training

Most Popular

26 Lectures 2 hours

Neha Gupta

Video

SAP Basis Online Training

30 Lectures 2.5 hours

Sumit Agarwal

Video

SAP C4C Online Training

30 Lectures 4 hours

Sumit Agarwal

Video

SAP MM Online Training

14 Lectures 1.5 hours

Neha Malik

Video

SAP WM Online Training

13 Lectures 1.5 hours

Neha Malik

Advertisements