‎2020 Feb 15 10:39 AM
Hi,
Is there a function in abap for ceiling like in excel?
There are two parameter,
first the number we want to round up
second is the multiple number
for example
https://exceljet.net/excel-functions/excel-ceiling-function
So we supply the number and then the significance.
10 significance 3 = 12
Thanks
Sam
‎2020 Feb 15 1:06 PM
The link says: "The Excel CEILING function rounds a given number up to the nearest specified multiple. CEILING works like the MROUND function, but CEILING always rounds up."
So,
10 significance 3 = 12
If I understand well:
10 / 3 = 3.333 rounded up to the closest integer = 4 and multiply it by 3 = 12
Code with round:
METHODS ceiling
IMPORTING number TYPE numeric multiple TYPE numeric
RETURNING VALUE(result) TYPE decfloat34.
METHOD ceiling.
result = round( val = EXACT( number / multiple ) dec = 0 mode = cl_abap_math=>ROUND_UP ) * multiple.
ENDMETHOD.NB: I didn't test...
‎2020 Feb 15 1:06 PM
The link says: "The Excel CEILING function rounds a given number up to the nearest specified multiple. CEILING works like the MROUND function, but CEILING always rounds up."
So,
10 significance 3 = 12
If I understand well:
10 / 3 = 3.333 rounded up to the closest integer = 4 and multiply it by 3 = 12
Code with round:
METHODS ceiling
IMPORTING number TYPE numeric multiple TYPE numeric
RETURNING VALUE(result) TYPE decfloat34.
METHOD ceiling.
result = round( val = EXACT( number / multiple ) dec = 0 mode = cl_abap_math=>ROUND_UP ) * multiple.
ENDMETHOD.NB: I didn't test...