Thursday 21 September 2017

ABAP: Bit wise operators

Bit wise operators are used to perform bit wise operations between variables. Below table summarizes the bit wise operators provided by ABAP.

ABAP provides BIT-NOT, BIT-AND, BIT-XOR, BIT-OR operators to perform bit level operations.

BIT-NOT Operator
Unary operator that flips all the bits in a hexadecimal number to the opposite value.

BIT-AND, BIT-OR, BIT-XOR operators
Bit1
Bit2
BIT-AND
BIT-OR
BIT-XOR
0
0
0
0
0
0
1
0
1
1
1
0
0
1
1
1
1
1
1
0

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

DATA: var1 TYPE X VALUE 8,
      var2 TYPE X VALUE 9,
      result TYPE X.

result = var1 BIT-AND var2.
Write result.

result = var1 BIT-OR var2.
Write / result.

result = var1 BIT-XOR var2.
Write / result.

result = BIT-NOT var1.
Write / result.



Previous                                                 Next                                                 Home

No comments:

Post a Comment