Math Functions in SAP
What are the math functions in SAP?
This is what u want may be
ABAP contains a range of built-in functions that you can use as mathematical expressions, or as part of a mathematical expression:
[COMPUTE] <n> = <func>( <m> ).
The blanks between the parentheses and the argument <m> are obligatory. The result of calling the function <func> with the argument <m> is assigned to <n>.
Functions for all Numeric Data Types
The following built-in functions work with all three numeric data types (F, I, and P) as arguments.
Functions for all numeric data types
Absolute value of argument.
Sign of argument: 1 X > 0
SIGN( X) = 0 if X = 0
-1 X < 0
Smallest integer value not smaller than the argument.
Largest integer value not larger than the argument.
Integer part of argument.
Fraction part of argument.
The argument of these functions does not have to be a numeric data type. If you choose another type, it is converted to a numeric type. For performance reasons, however, you should use the correct type whenever possible. The functions itself do not have a data type of their own. They do not change the numerical precision of a numerical operation.
DATA N TYPE P DECIMALS 2.
DATA M TYPE P DECIMALS 2 VALUE '-5.55'.
N = ABS( M ). WRITE: 'ABS: ', N.
N = SIGN( M ). WRITE: / 'SIGN: ', N.
N = CEIL( M ). WRITE: / 'CEIL: ', N.
N = FLOOR( M ). WRITE: / 'FLOOR:', N.
N = TRUNC( M ). WRITE: / 'TRUNC:', N.
N = FRAC( M ). WRITE: / 'FRAC: ', N.
The output appears as follows:
T2(10) VALUE '-100'.
T1 = ABS( T2 ).
This produces the following output:
Two conversions are performed. First, the contents of field T2 (type C) are converted to type P. Then the system processes the ABS function using the results of the conversion. Then, during the assignment to the type C field T1, the result of the function is converted back to type C.
The following built-in functions work with floating point numbers (data type F) as an argument.
Functions for floating point data types
ACOS, ASIN, ATAN; COS, SIN, TAN
COSH, SINH, TANH
Exponential function with base e (e=2.7182818285).
Natural logarithm with base e.
Logarithm with base 10.
For all functions, the normal mathematical constraints apply (for example, square root is only possible for positive numbers). If you fail to observe them, a runtime error occurs.
The argument of these functions does not have to be a floating point field. If you choose another type, it is converted to type F. The functions themselves have the data type F. This can change the numerical precision of a numerical operation.