Skip to content

ABAP Keyword Documentation →  ABAP - Dictionary →  Built-In Functions in ABAP Dictionary →  SQL Functions 

SQL Functions for Numeric Values

The following table shows the numeric SQL functions supported by ABAP CDS and ABAP SQL. The columns ABAP CDS and SQL indicate where a function can be used. The Table Buffer column indicates whether the function can be executed in the table buffer.

SQL Function Result ABAP CDS ABAP SQL Table Buffer
ABS(arg) Absolute amount of arg. x x x
CEIL(arg) Smallest integer number not less than the value of arg. x x x
DIV(arg1, arg2) Integer part of the division of arg1 by arg2The sign is assigned after the amounts are divided; positive if the arguments have the same sign, and negative if the arguments have different signs. Exception: arg2 has the value 0. x x x
DIVISION(arg1, arg2, dec) Division of arg1 by arg2 The result is rounded to dec decimal places. x x -
FLOOR(arg) Largest integer number not greater than the value of arg. x x x
MOD(arg1, arg2) Positive or negative integer remainder of the division of arg1 by arg2. x x x
ROUND(arg, pos) Rounded value of arg. If pos is greaterthan 0, the value is rounded to the position pos on the right of the decimalseparator. If this is not the case, position abs(pos)+1 to the left of the decimal separator is rounded. This results in a 0 if the number of places is not sufficient. x x -

Descriptions of the potential operands and data types can be found in the corresponding documentation for ABAP CDS and ABAP SQL.

Other versions: 7.31 | 7.40 | 7.54


Note

The SQL functions DIV and MOD behave differently with respect to the signs than the ABAP operators DIV and MOD. In the SQL function DIV, the amounts of the arguments are divided and then the sign is assigned (positive if the arguments have the same signs and negative if they have different signs). Accordingly, the result of MOD can be negative, so that multiplying the result of DIV by expr2 plus the result of MOD produces the value of expr1. The ABAP operator MOD, on the other hand, only produces positive results.


Example

The following table shows the results of integer divisions and their integer remainders in SQL. See also the example for the ABAP operators DIV and MOD.

expr1 expr2 DIV MOD
7 3 2 1
-7 3 -2 -1
7 -3 -2 1
-7 -3 2 -1