Tuesday 26 September 2017

ABAP: IF-ELSEIF statement

IF-ELSEIF statement is used to check multiple conditions.

Syntax
IF conditon1.
         * Execute this block,if condition1 is true
ELSEIF condition2.
         * Execute this block, if condition2 is true
ELSEIF condition3.
         * Execute this block, if condition3 is true
ELSE.
         * Execute this block, if all the conditions are false
ENDIF


Z_HELLO_WORLD
*&---------------------------------------------------------------------*
*& Report Z_HELLO_WORLD
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_HELLO_WORLD.

DATA marks TYPE I VALUE 55.

IF marks < 35.
  Write 'Failed'.
ELSEIF marks < 60.
  Write 'Second Class'.
ELSEIF marks < 70.
  Write 'First Class'.
ELSE.
  Write 'Destinction'.
ENDIF.



Previous                                                 Next                                                 Home

No comments:

Post a Comment