In a CDS View select statement, given that I have a column of type DEC
, how do I convert that to type INT
?
Work done so far: According to the CAST_EXPR
documentation, this is not possible with CAST_EXPR
. According to the numeric functions documentation, math functions like FLOOR
will return a value of the same type.
Update: the numeric functions documentation is correct.
The code floor(fieldname)
will convert a DEC(X,Y)
(where Y > 0
) into a DEC(X,0)
. Essentially, floor
strips the decimal places from the field without changing its type.
On the other hand, ceil(fieldname)
will round up to the nearest integer and convert a DEC
to an INT
If you want to get an integer from the floor
function, then you must call ceil(floor(fieldname))
On a NetWeaver system, you should be able to find the CDS View demo_cds_sql_functions_num
and program/report demo_cds_sql_functions_num
that help demonstrate these concepts. You can use the debugger to view the report's variable result
and confirm my findings.