SAP ABAP SYNTAX FOR COMPUTE PART THREE

Exponentiation

The exponential expression "x**y" means x*x*...*x y times, provided that y is a natural number. For any value of y, x**y is explained by exp(y*log(x)).
Operators of the same ranke are evaluated from left to right. Only the exponential operator, as is usual in mathematics, is evaluated from right to left . The expression " 4 ** 3 ** 2 " thus corresponds to " 4 ** ( 3 ** 2 ) " and not " ( 4 ** 3 ) ** 2 ", so the result is 262144 and not 4096.
The following resrtictions apply for the expression " X ** Y ": If X is equal to 0, Y must be positive. If X is negative, Y must be a whole number.

Note

DIV and MOD

The whole number division operators DIV and MOD are defined as follows:
  • ndiv = n1 DIV n2
  • nmod = n1 MOD n2

so that:
n1 = ndiv * n2 + nmod ndiv is a whole number 0 <= nmod < |n2| A runtime error occurs if n2 is equal to 0 and n1 is not equal to 0.

Example

 
DATA: D1 TYPE I, D2 TYPE I, D3 TYPE I, D4 TYPE I,
      M1 TYPE P DECIMALS 1, M2 TYPE P DECIMALS 1,
      M3 TYPE P DECIMALS 1, M4 TYPE P DECIMALS 1,
      PF1 TYPE F VALUE '+7.3',
      PF2 TYPE F VALUE '+2.4',
      NF1 TYPE F VALUE '-7.3',
      NF2 TYPE F VALUE '-2.4',
D1 = PF1 DIV PF2.  M1 = PF1 MOD PF2.
D2 = NF1 DIV PF2.  M2 = NF1 MOD PF2.
D3 = PF1 DIV NF2.  M3 = PF1 MOD NF2.
D4 = NF1 DIV NF2.  M4 = NF1 MOD NF2.

The variables now have the following values:

D1 = 3, M1 = 0.1,
D2 = - 4, M2 = 2.3,
D3 = - 3, M3 = 0.1,
D4 = 4, M4 = 2.3.
   

Notes

Floating point functions
Although the functions SIN , COS and TAN are defined for any numbers, the results are imprecise if the argument is greater than about 1E8 , i.e. 10**8.
The logarithm for a base other than e or 10 is calculated as follows:

Logarithm of b for base a = LOG( b ) / LOG( a )

Note

Run time errors

Depending on the operands, the above operators and functions can cause run time errors (e.g. when evaluating the logarithm with a negative argument).

RELATED POST

SAP ABAP SYNTAX FOR COMPUTE PART TWO
SAP security infrastructure for data production
SAP safety infrastructure
SAP Network Level Security
Mysap web application server

No comments :

Post a Comment