Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP Ceiling function

0 Likes
2,906

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

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
2,094

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...

1 REPLY 1
Read only

Sandra_Rossi
Active Contributor
2,095

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...