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 prblem

Former Member
0 Likes
1,137

Hi,

how can i obtain exactly values for arithmetical operations? SAP round values... but i don't want to round values.

Here is an example:

8.89 * 0.25 = 2.245 -> SAP rounds to 2.25

is there a way (FM, or something) that for this operation the result to be 2.24 ??

Thank you.

Hi,

how can i obtain exactly values for arithmetical operations? SAP round values... but i don't want to round values.

Here is an example:

8.89 * 0.25 = 2.245 -> SAP rounds to 2.25

is there a way (FM, or something) that for this operation the result to be 2.24 ??

Thank you.

9 REPLIES 9
Read only

Former Member
0 Likes
1,090

hi

use the data type of p

hope it will work

with regards

s.janagar

Read only

0 Likes
1,090

hi

use the data type of p

hope it will work

with regards

s.janagar

no, this is not working, i've try

Read only

0 Likes
1,090

hi,

i have given u the hint in the sense , u know to declare

try this

parameters: v1 type p decimals 3.

parameters: v2 type p decimals 3.

data: v3 type p decimals 8.

v3 = v1 * v2 .

write:/ v3.

it will work for sure

Read only

0 Likes
1,090

report Z_PO_EMAIL line-count 6.

data: pv type p decimals 3 value '124.157'.

data: pn type p decimals 0.

pn = pv.

write:/ pv.

write:/ pn . "rounded value

Read only

0 Likes
1,090

hi,

i have given u the hint in the sense , u know to declare

try this

parameters: v1 type p decimals 3.

parameters: v2 type p decimals 3.

data: v3 type p decimals 8.

v3 = v1 * v2 .

write:/ v3.

it will work for sure

yes janagar sundaramoorthy , this work but i want the result only with 2 decimals

if i declare v3 with two decimals in this way will not work.

Read only

valter_oliveira
Active Contributor
0 Likes
1,090

What kind of variables did you define for that operation?

8.89 * 0.25 = 2.245 -> SAP rounds to 2.25

If result is the var that is getting 2.25, try defining liek this:


DATA: result type p decimals 3.

Regards,

Valter Oliveira.

Read only

Former Member
0 Likes
1,090

Hi,

you can use FLOOR or CEIL...

Regards,

deepthi.

Read only

Former Member
0 Likes
1,090

hi,

use these operators.

CEIL

Smallest integer value that is not less than x

FLOOR

Largest integer value that is not greater than x

data : wa_val type p decimals 2,

wa_ans type i.

wa_val = '32.22'.

wa_ans = abs( wa_val ).

write : / wa_ans.

wa_val = ceil ( wa_val ).

write:/ wa_val.

Read only

Former Member
0 Likes
1,090

just use ceil flor.

then you can get exat values which you want

Jithendra