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: 

Round up a quantity field

Former Member
0 Kudos

Hi All!

Any FM to get always the round up values.Suppose for example :

quantity is 1.234 I want 2.

or

quantity is 1.789 I want 2.

Always I want to round up.Please advise.

Regards

Praneeth

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

Hello,

data: l_1 type i, l_2 type p decimals 2.

l_2 = '1.78'.

l_1 = FLOOR( l_2 ).

l_1 = l_1 + 1.

write: l_1.

Regards,

Naimesh

6 REPLIES 6

Former Member
0 Kudos

try FM ROUND

0 Kudos

DATA: VAR1 TYPE P DECIMALS 2,

RES TYPE P DECIMALS 2.

VAR1 = '12.33'.

RES = ROUND( VAR1 ).

WRITE RES.

naimesh_patel
Active Contributor
0 Kudos

Hello,

data: l_1 type i, l_2 type p decimals 2.

l_2 = '1.78'.

l_1 = FLOOR( l_2 ).

l_1 = l_1 + 1.

write: l_1.

Regards,

Naimesh

Former Member
0 Kudos

Hi Praneeth,

Dont think 'Round' will always work coz for 1.234.....it will give 1....

So better use Function ceil.

w_qty = ceil( input_qty)

0 Kudos

Hi Praneeth,

You can have two options :

1. Use CEIL function to get the result.

Go through this link for more details.

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3316358411d1829f0000e829fbfe/content.htm

2. U can use ROUND_AMOUNT fm to get also.

REgards,

SP.

Former Member
0 Kudos

Hi

Use CEIL function . This gives the nearest integer value.

Regards