- SAP Community
- Groups
- Interest Groups
- Application Development
- Discussions
- Wrong amount in calculation in ABAP code.

Application Development Discussions

Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Wrong amount in calculation in ABAP code.

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

12-24-2014 10:38 AM

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

- SAP Managed Tags:
- ABAP Development

1 ACCEPTED SOLUTION

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

12-24-2014 11:04 AM

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

- SAP Managed Tags:
- ABAP Development

5 REPLIES 5

Former Member

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

12-24-2014 10:53 AM

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

- SAP Managed Tags:
- ABAP Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

12-24-2014 11:13 AM

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

- SAP Managed Tags:
- ABAP Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

12-24-2014 11:27 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

12-24-2014 11:04 AM

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

- SAP Managed Tags:
- ABAP Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

12-24-2014 11:26 AM

Hi Pavan,

Yeah now working fine.. Thanks for your suggestion.

Regards,

Thangam.P

- SAP Managed Tags:
- ABAP Development