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

operation division rounding

Former Member
0 Likes
4,073

Hi

I have a rounding error when I run the following code:

divider'235 'dividend and'3'. Then in the presence of odd numbers.

Could you give me a recommendation?

Thanks in advance,

9 REPLIES 9
Read only

Former Member
0 Likes
2,256

hi,

if i undestand ur quistion correctly, if this is ABAP code plase remove flower brackets and use write command to print output..

Read only

Former Member
0 Likes
2,256

Hi

report Z_div.

PARAMETERS: p_divi TYPE p ,

p_divid TYPE p DECIMALS 2.

data: f1_divi TYPE f .

DATA: f2_divid TYPE f .

data: value TYPE f.

move p_divi to f1_divi.

move p_divid to f2_divid.

data: value2 TYPE p DECIMALS 2.

value = f1_divi / f2_divid.

*valore = valore * 100 / 100.

value2 = value .

write value2.

Ty .

Read only

0 Likes
2,256

Hello

But what must be a result?

Read only

0 Likes
2,256

Hi

the result is correct but not rounded, for example writing 235 / 3, the result is 78.33 verify if the result I get 234.99 ... How can round off the result.

Thank you very much.

Read only

0 Likes
2,256

Hello

You get 234.99 because value2 was declared as TYPE p.

Declare this as integer.

Read only

0 Likes
2,256

Thank you very much!

I solved in another way, can I control between the past is the final result at the end add or subtract the aggregate.

The speech is a little more complicated than a simple division, we speak of Budget and Finance: D! Thanks again.

Massimo

Read only

0 Likes
2,256

Hi

It's not very clear what you need u should decided how to round off the result and how many decimals have to be used.

There are some particular fm to obtain it (for ex. FIMA_NUMERICAL_VALUE_ROUND)

Max

Read only

0 Likes
2,256

Thanks for all,

i'm resolved my problem.

Read only

Former Member
0 Likes
2,256

You can try ROUND

Write var to target_var round 0.

Regards,

Mohaiyuddin