SAP CDS SQL FUNCTIONS NUMERIC V2



Get Example source ABAP code based on a different SAP table
  


• ABS ABAP_CDS_FUNCTION
• CEIL ABAP_CDS_FUNCTION
• DIV ABAP_CDS_FUNCTION
• DIVISION ABAP_CDS_FUNCTION
• FLOOR ABAP_CDS_FUNCTION
• MOD ABAP_CDS_FUNCTION
• ROUND ABAP_CDS_FUNCTION

ABAP_CDS_DDL - CDS View Entity, Numeric Functions
The following table shows the possible numeric SQL functions in a CDS view entity, plus the requirements made on the arguments. FunctionResultValid Argument TypesResult Type
ABS(arg)Absolute amount of arg INT1, INT2, INT4, INT8, DEC, CURR, QUAN, DECFLOAT16, DECFLOAT34, FLTPData type of arg
CEIL(arg) Returns the first integer that is greater than or equal to the value of arg DEC, DECFLOAT16, DECFLOAT34 Data type of arg
DIV(arg1, arg2)The result of a division of arg1 by arg2 is rounded to an integer. The sign is assigned after the amounts are divided; positive if the arguments have the same sign, and negative if the arguments have different signs. ABAP_EXCEPTION arg2 has the value 0. INT1, INT2, INT4, INT8, DEC.Data type of the argument with the greatest value range
DIVISION(arg1, arg2, dec) Division of arg1 by arg2. The result is rounded to dec decimal places. arg1, arg2: INT1, INT2, INT4, INT8, DEC lbr lbr dec: integer numeric literal greater than or equal to 0. Length must be suitable so that the total of 31 valid places is not exceeded. DEC with dec decimal places. The length of the result must not be greater than 31.
FLOOR(arg)Returns the largest integer number not greater than the value of arg. Counterpart to CEIL. DEC, DECFLOAT16, DECFLOAT34Data type of arg
MOD(arg1, arg2)Positive or negative integer remainder of the division of arg1 by arg2 . arg1: INT1, INT2, INT4, INT8 lbr lbr arg2: INT1, INT2, INT4 Data type of arg1
ROUND(arg, pos)Rounded value of arg. If pos is greater than 0, the value is rounded to the position pos on the right of the decimal separator. 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. arg: INT1, INT2, INT4, INT8, DEC, CURR, QUAN, DECFLOAT16, DECFLOAT34 lbr lbr pos: Literal, field of a data source or input parameter of type INT1, INT2, or INT4 When arg has data type INT1, INT2, or INT4, then the result has data type INT4. For all other data types, the result has the same data type as arg.
The following can be specified as the arguments arg:
Literals of a suitable type.
Session variables of a suitable type.
Suitable fields of a data source data_source of the current CDS view entity.
Path expressions that identify a suitable field of a data source data_source.
Input parameters from the parameter list parameter_list.
Reuse expressions using $projection
SQL-based scalar functions (if they return a matching type)
The following built-in functions and expressions (if they return a matching type):
Other built-in SQL functions
Arithmetic expressions
Aggregate expressions
Type modifications using CAST
Case distinctions using CASE



Latest notes: