Application Development 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: 

FM to round Quantity

Former Member
0 Kudos

Hi I need a FM to round quantity to the highest 10's.

for eg if I have 11, it should make it to 20.

if i have 27, it should make it to 30.

Any FM.

Ster.

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos

No FM required.

divide by 10, use CEIL, multiply by 10.

data: value1 type i value 11,
      value2 type p DECIMALS 1.

value2 = CEIL( value1 / 10 ).
value1 = value2 * 10.

write: / value1.

or if you want to do it in one go, with an integer

DATA: value1 TYPE i VALUE 11.

value1 = ( ( value1 + 4 ) / 10 ) * 10.

WRITE: / value1.

3 REPLIES 3

matt
Active Contributor
0 Kudos

No FM required.

divide by 10, use CEIL, multiply by 10.

data: value1 type i value 11,
      value2 type p DECIMALS 1.

value2 = CEIL( value1 / 10 ).
value1 = value2 * 10.

write: / value1.

or if you want to do it in one go, with an integer

DATA: value1 TYPE i VALUE 11.

value1 = ( ( value1 + 4 ) / 10 ) * 10.

WRITE: / value1.

Former Member
0 Kudos

try to use system function floor (Largest integer number that is not larger than the value of the argument arg. ) or ceil (Smallest integer number that is not smaller than the value of the argument arg).

Ex:

l_amount = ceil ( l_amount1 ).

Edited by: Joyjit Ghosh on Oct 16, 2008 5:37 PM

JozsefSzikszai
Active Contributor
0 Kudos

I wonder if such FM exists, I think a small workaorund is necessary:

DATA : p TYPE p DECIMALS 1.

p = quantity / 10.

p = CEIL( p ).

quantity = p * 10.