Friday, 22 September 2017

ABAP: IF-ELSE statement

IF-ELSE statement is an enhancement to IF statement that I explained in my previous post. The statements preceded by IF statement will execute only the condition is true, else the statements preceded by ELSE statement will execute.

Syntax
IF condition.
         * statements
ELSE.
         * statements
ENDIF.

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

DATA var1 TYPE I VALUE 10.
DATA var2 TYPE I VALUE 20.

IF var1 > 10.
  Write 'var1 is > 10'.
ELSE.
  Write / 'var1 is <= 10'.
ENDIF.

IF var2 > 10.
  Write / 'var2 is > 10'.
ELSE.
  Write / 'var2 is <= 10'.
ENDIF.



Previous                                                 Next                                                 Home

No comments:

Post a Comment