 ## SAP Operator: Arithmetic Operators

Following are the basic SAP Operator using which Arithmetic operations can be performed upon ABAP variables:

1. ## Assign Values to variables

To assign value to a variable, we can use equal to “=” sign or Keyword MOVE.

DATA:   LV_NUMBER1 TYPE      n,

LV_NUMBER2   TYPE     n.

LV_NUMBER1 = 10.

MOVE LV_NUMBER1 TO LV_NUMBER2.

WRITE: / LV_NUMBER1, LV_NUMBER2.

OUTPUT:

1. ## Apply Sum, Subtraction, Multiplication and division on two or more variables

DATA:           LV_NUMBER1 TYPE      n             VALUE  10,

LV_NUMBER2   TYPE     n             VALUE  20,

LV_SUB                 TYPE     n,

LV_MUL               TYPE     n,

LV_DIV                 TYPE     n.

(OR)

A = ADD LV_NUMBER2 TO LV_NUMBER1.

LV_SUB = LV_NUMBER1 – LV_NUMBER2.

(OR)

B = SUBTRACT LV_NUMBER2 FROM LV_NUMBER1

LV_MUL = LV_NUMBER1 * LV_NUMBER2.

(OR)

C = MULTIPLY LV_NUMBER1 BY LV_NUMBER2

LV_DIV                 = LV_NUMBER2 / LV_NUMBER1.

(OR)

D = DIVIDE LV_NUMBER2 BY LV_NUMBER1

WRITE: / LV_ADD, LV_SUB, LV_MUL, LV_DIV.

(OR)

WRITE: / A, B, C, D.

1. ## Clear Variables

Keyword CLEAR is used to clear the values in variable to default values i.e. 0 for numeric and “ ” for character field.

WRITE: / “BEFORE CLEAR”.

WRITE: / A, B, C, D.

CLEAR: A, B, C, D.

WRITE: / “AFTER CLEAR”.

WRITE: / A, B, C, D.

# ABAP MATHS FUNCTIONS

ABAP provides predefined built-in maths functions that you can use according to your requirement.

Following are some of the Maths Functions:

 FUNCTIONS SUPPORTED NUMERIC DATA TYPES DESCRIPTION ABS ALL TO CALCULATE ABSOLUTE VALUE SIGN ALL TO DETERMINE SIGN, RETURNS 1 FOR (+) 0 FOR (-) CEIL ALL It gives next highest integer i.e.  ceil (2.1) = 3 FLOOR ALL It gives next lowest integer  i.e. floor (2.1) = 2 TRUNC ALL It gives truncated part of the input FRAC ALL It gives fractional part of input i.e. FRAC(1.2) = .2 COS,SIN,TAN F It will implement the given trigonometry function EXP F It will implement Exponential function LOG F It will implement Natural Log on that number SQRT F It will return square root of the input MOD N It will return remainder mod(12,5) = 2

## SAP Operator: Comparison Operators

Following are the SAP Operator provided for ABAP Comparison Operation:

 Operator Alternate Form Meaning = EQ Equality Test returns 1 if equal <> NE Inequality Test return 1 if True > GT Greater Than Test < LT Less Than Test >= GE Greater than or Equal <= LE Less than or Equal BETWEEN Interval Test returns value between two value IS INITIAL Initial Test returns True if variable have no value IS NOT INITIAL Not Initial Test returns True if variable is not empty

Apart from above operators ABAP also provide Bitwise Operators and Character String Operators

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Translate »