SAP NetWeaver AS ABAP Release 750, ©Copyright 2016 SAP AG. All rights reserved.
ABAP - Keyword Documentation → ABAP - Reference → Processing External Data → ABAP Database Accesses → Open SQL → Open SQL - Operands → Open SQL - SQL Functions →sql_exp - sql_num_func
Syntax
... func( arg1[, arg2] ... ) ...
Effect
Calls an numeric function func as an SQL expression or operand of an expression in Open SQL. The arguments arg1, arg2, ... of the function are specified as a comma-separated list in parentheses. A blank must be placed before the opening parenthesis and after the closing parenthesis.
The following table shows the numeric functions that can be specified as SQL expressions and the requirements made on the arguments. The meaning of the functions can be found under SQL Functions for Numeric Values.
| Syntax | Valid Argument Types | Result Type |
| ABS( expr ) | All numeric types except decimal floating point numbers | Type of the argument |
| CEIL( expr ) | DEC, CURR, and QUAN with decimal places | DEC without decimal places in the length of the result |
| DIV( expr1,expr2 ) | INT1, INT2, INT4, and INT8 plus DEC, CURR, and QUAN without decimal places | Type of the argument with the greatest value range. |
| FLOOR( expr ) | DEC, CURR, and QUAN with decimal places | DEC without decimal places in the length of the result |
| MOD( expr1,expr2 ) | INT1, INT2, INT4, and INT8 plus DEC, CURR, and QUAN without decimal places | Type of the argument with the greatest value range. |
| ROUND( expr,pos ) | expr: INT1, INT2, INT4, INT8, DEC, CURR, and QUAN pos: INT1, INT2, and INT4 |
Type of expr, where INT1 and INT2 are updated after INT4 and CURR and QUAN are updated after DEC. |
The arguments expr, expr1, expr3, and pos can be SQL expressions, more specifically individual columns, literals, SQL functions, host variables, or host expressions. The possible types are specified as predefined dictionary types. The possible data types for literals, host variables, and host expressions are the ABAP types assigned to the dictionary types above.
If an argument of a numeric function has the null value, the result of the full numeric function is the null value.
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 with expr2 plus the result of MOD produces the value of expr1. The ABAP operator MOD, on the other hand, only produces positive results. See Example.
Example
See SQL Expressions, Arithmetic Calculations.