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

Rounding off to 3 decimals

Former Member
0 Likes
2,651

Hi all,

please help me in the issue . i am calculating the contion value in one of the rouitne value xkomv-kbetr(11 dec 2) is rounded off to 2 due to which i am getting difference in final value . i want it rounded off to 3 decimals how can i acheive it.

THanks in advance,

1 ACCEPTED SOLUTION
Read only

Abhijit74
Active Contributor
0 Likes
2,112

Hi,

For that it's better to use any z data element. You can use your own with 3 decimals.

Thanks

10 REPLIES 10
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,112

What is the formula you are using & what is the definition of he variables used?

If it is a custom code you can change the output variable to

TYPE p DECIMALS 3

BR,

Suhas

Read only

Former Member
0 Likes
2,112

output varaible is xkomv-kbetr which is standard and its length is 11 with 2 decimals.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,112

Hello Eric,

Are you doing the calculation in some custom report or in some enhancement ?

BR,

Suhas

Read only

neelavraj_duara2
Explorer
0 Likes
2,112

Please note that Std SAP accepts only 2 decimals. In case you are calculating values in a routine or user exit, the total calues mught not match.

Read only

0 Likes
2,112

Hi,

I am using routine to get the value and passing it to xkomv-kbetr(11 length 2 deci) so how do i roundoff it to 3 decimals

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,112

Hello,

Can you be more specific in explaining your requirement ?

Anyways if you can change the export param( TYPE xkomv-kbetr), i don't think you have much option here.

BR,

Suhas

Read only

Abhijit74
Active Contributor
0 Likes
2,113

Hi,

For that it's better to use any z data element. You can use your own with 3 decimals.

Thanks

Read only

Former Member
0 Likes
2,112

Hi

Your target field should have 3 decimals to get the accurate value.

Regards

Gaurav

Read only

Former Member
0 Likes
2,112

From your post, I'm assuming that you don't need the result as 3 decimal places but just the intermediate calculations.

For example, when creating a percentage, you can use either of the following formulas:

a = ( b / c ) * 100.

a = ( b * 100 ) / c.

Assuming a, b and c are all two decimal place variables.

The first example will have rounding issues.

The second example will give the desired results.

So in your results, you can either use local variables to do calculations or perhaps arrange the formula (as shown in the example) so significant digits aren't truncated.

Read only

Former Member
0 Likes
2,112

solved