- SAP Community
- Groups
- Interest Groups
- Application Development
- Discussions
- Inconsistency in SD Discount in Pricing in VOFM >F...

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

Inconsistency in SD Discount in Pricing in VOFM >Formulas >Condition Values

Former Member

Options

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

03-20-2006 9:19 PM

Hello All,

We are facing a strange issue with rounding in the pricing. and would like to hear from someone who might have faced a similar problem and how they went about in fixing it.

Here is the code we are using in the VOFM for Formulas > condition value.

**----**

data: z_kwert(16) type p decimals 2, "round the numbers to 2 decimals

z_disc_int type i,

z_disc_rem type i.

Calculate Discount per Unit

z_kwert = komp-netpr * xkomv-kbetr / 1000.

Separate whole number and decimal portions of discount

compute z_disc_rem = z_kwert mod 100.

z_disc_int = ( z_kwert + z_disc_rem ) / 100.

Adjust discount amout if necessary (force rounding on disc)

if z_disc_rem > 50.

xkwert = ( ( z_disc_int + 1 ) * komp-mgame ) / 1000.

else.

xkwert = ( z_disc_int * komp-mgame ) / 1000.

endif.

*} INSERT

endform.

**----**

Something funky seems to be happening with the values and the rounding.

Z_KWERT 62.50-

KOMP-NETPR 12.50

XKOMV-KBETR 50.00-

Z_DISC_INT 62-

Z_DISC_REM 50

XKWERT 4.34-

KOMP-MGAME 7.000

- SAP Managed Tags:
- ABAP Development

1 ACCEPTED SOLUTION

Former Member

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

03-20-2006 10:21 PM

Hi Suresh. I've had some problems in the past with formulas and decimlas. For some reason, the decimals are handled somewhat different, i mean, a number that should be 2,4 is actually 0,024 for example. The solution i found then was to make the calculations on an external routine. For example:

PERFORM calculate_something USING xkwert CHANGING xkwert IN PROGRAM zsomething.

Hope it helps

- SAP Managed Tags:
- ABAP Development

4 REPLIES 4

Former Member

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

03-20-2006 10:21 PM

Hi Suresh. I've had some problems in the past with formulas and decimlas. For some reason, the decimals are handled somewhat different, i mean, a number that should be 2,4 is actually 0,024 for example. The solution i found then was to make the calculations on an external routine. For example:

PERFORM calculate_something USING xkwert CHANGING xkwert IN PROGRAM zsomething.

Hope it helps

- SAP Managed Tags:
- ABAP Development

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

03-20-2006 10:57 PM

Hello Jesus,

Let me try that. Right now have got it working except it behaves strangely with the MOD. 2,60 splits into 2 and 40 instead of 2 and 60. So have to see if it would be okay in an external program. Can you tell me if you have the Fixed Point Arithmetic checked for your program.

Regards,

Suresh

- SAP Managed Tags:
- ABAP Development

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

03-21-2006 2:17 PM

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

03-21-2006 2:48 PM

That's the point: the formula's include is not checked with "Fixed Point Arithmetic". It makes all calculations wrong.

Just call an externar routine or a FM that solve the problems.

Regards.

- SAP Managed Tags:
- ABAP Development