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

Round up a quantity field

Former Member
0 Likes
3,607

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
Read only

naimesh_patel
Active Contributor
0 Likes
1,807

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

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

6 REPLIES 6
Read only

Former Member
0 Likes
1,807

try FM ROUND

Read only

0 Likes
1,807

DATA: VAR1 TYPE P DECIMALS 2,

RES TYPE P DECIMALS 2.

VAR1 = '12.33'.

RES = ROUND( VAR1 ).

WRITE RES.

Read only

naimesh_patel
Active Contributor
0 Likes
1,808

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

Read only

Former Member
0 Likes
1,807

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)

Read only

0 Likes
1,807

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.

Read only

Former Member
0 Likes
1,807

Hi

Use CEIL function . This gives the nearest integer value.

Regards