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.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

Suresh, the flag is cheked for the external program.

Regards

0 Kudos

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.