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

Wrong amount in calculation in ABAP code.

thangam_perumal
Contributor
0 Likes
3,588

Dear Friends,

                   Here i am facing one issue on ABAP multiplication code.

for your reference you can see below.

code is:

it_ekpo-netwr = 741.67

dkwert           = 10.00

g_excise1 = ( it_ekpo-netwr / 100 )  * dkwert.

when i execute above line the answer should come  g_excise1  = 74.20 but instead of 74.20 answer coming 7420.00.

.actually all the variables are same data types.  kindly anyone suggest me what is the reason behind this? above program type is executable program.

but  another program ( Type Subroutine pool ) same logic and same block is working well. only Program type is difference.

Regards,

  Thangam.P

1 ACCEPTED SOLUTION
Read only

pavanm592
Contributor
0 Likes
2,380

Hi Perumal,

Check you program attributes->Fixed point Arithmetic  Check box should be checked otherwise the calculations will not be accurate.

I tried an example like below.

Case1 : Fixed point Arithmetic Checked

data : lv_netwr TYPE BPREI VALUE '741.67'.

DATA : lv_drk TYPE BPREI VALUE '10.00'.

DATA : lv_val TYPE BPREI.

lv_val = ( lv_netwr / 100 ) * lv_drk.

WRITE : / lv_val.

OUTPUT :  74.17

Case2 : Fixed point Arithmetic UnChecked

OUTPUT :  7,420.00

Once check and revert.

Regards,

Pavan

5 REPLIES 5
Read only

Former Member
0 Likes
2,380

Hi Thangam,

Whenever we multiply or divide anything with the Condition value (KWERT) the decimals always behave like this. To overcome this issue, usually it happens in pricing routines, we adjust the value by multiplying/divide with multiples of 10. This adjusts the decimal points correctly.

Regards,

Aashika

Read only

0 Likes
2,380

Hi Ashika,

             Thanks for your immediate reply and also i agree with your point . but if kwert having decimal issue mean it should behave same as everywhere but one of the subroutine pool program same logic and same input it calculates correct and exact values. My question is what might be problem of this issue. for more details Please look on the below screen shots.

 

I cant determine the Root cause.

Regards,

  Thangam.P

Read only

0 Likes
2,380

Dear Aashika,

                   Thanks for your suggestion too..

Regards,

Thangam.P

Read only

pavanm592
Contributor
0 Likes
2,381

Hi Perumal,

Check you program attributes->Fixed point Arithmetic  Check box should be checked otherwise the calculations will not be accurate.

I tried an example like below.

Case1 : Fixed point Arithmetic Checked

data : lv_netwr TYPE BPREI VALUE '741.67'.

DATA : lv_drk TYPE BPREI VALUE '10.00'.

DATA : lv_val TYPE BPREI.

lv_val = ( lv_netwr / 100 ) * lv_drk.

WRITE : / lv_val.

OUTPUT :  74.17

Case2 : Fixed point Arithmetic UnChecked

OUTPUT :  7,420.00

Once check and revert.

Regards,

Pavan

Read only

thangam_perumal
Contributor
0 Likes
2,380

Hi Pavan,

              Yeah now working fine.. Thanks for your suggestion.

Regards,

Thangam.P