Thursday 21 September 2017

ABAP: Logical Operators

Logical operators are used to combine the conditions. Below table summarizes the logical operators supported by ABAP.

Operator
Description
AND
condition1 AND condition2: Return true if both the conditions are true, else false.
OR
condition1 OR condition2: Return true if either of the conditions is true, else false.
NOT
Not condition : return true, if the condition is false, false if the condition is true.

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 > 5 AND var2 > 5.
  Write / 'var1 and var2 are > 5'.
ENDIF.

IF NOT ( var1 > 20 ).
  Write / 'var1 is not > 20'.
ENDIF.

IF ( var1 > 15 OR var2 > 15 ).
  Write / 'var1 or var2 are > 15'.
ENDIF.

IF ( var1 > 15 AND var2 > 15 ).
  Write / 'var1 or var2 are > 15'.
ENDIF.



Previous                                                 Next                                                 Home

No comments:

Post a Comment