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: 

Problem with Decimal Places

Former Member
0 Kudos

Hi,

When I debug the code the following is what I get;

subtotal_price = wa_subtotl-J_3AFKIMG * grade_A_price.

wa_subtotl-J_3AFKIMG -> 15.000 (TYPE p DECIMALS 3 / This field is for Quantity and 3 decimal places is a must)

grade_A_price -> 2.20 (TYPE p DECIMALS 2 / This is Price)

subtotal_price -> 33000.00 (TYPE p DECIMALS 2 / Multiplication of Qty and Price)

Why the "subtotal_price" appear as "33000.00" when it should be "33", how ro solve this issue?

Thanks,

Kishan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Did u debug and check what value each fields are taking

wa_subtotl-J_3AFKIMG * grade_A_price.

Check it in debugging mode so that u will get an idea.

It has to come as 33.00 as u have defined as type p 2 decimals.

6 REPLIES 6

Former Member
0 Kudos

Hi,

Did u debug and check what value each fields are taking

wa_subtotl-J_3AFKIMG * grade_A_price.

Check it in debugging mode so that u will get an idea.

It has to come as 33.00 as u have defined as type p 2 decimals.

0 Kudos

Hi Kishan,

pls set field "fixed point arithmetic" (=x)

in attributes of your prg.

Andreas

Message was edited by: Andreas Mann

0 Kudos

Hi Judith,

The Values that I have shown are from the dubugger.

Thanks,

Kishan

0 Kudos

Hi Kishan,

Is it possible for you to paste us a bit more of your code? I made a small test with your values and it works fine (result is 33,00):

REPORT  Z_TEST.

data: subtotal_price type p decimals 2,
      grade_A_price  type p decimals 2,
      wa_subtotl     type p decimals 3.

grade_A_price = '15.000'.
wa_subtotl = '2.20'.

subtotal_price = wa_subtotl * grade_A_price.

write: / subtotal_price.

Regards,

Ville

0 Kudos

Hi,

Try this example

TYPES: myamount   TYPE p DECIMALS 2,
       amt1       TYPE p decimals 3,
       amt2       TYPE p decimals 3.

DATA: amount      TYPE myamount,
      damt1     TYPE amt1,
      damt2  type amt2.

damt1 = '15.000'.
damt2 = '2.20'.


amount = damt1 * damt2.
WRITE:  amount.

Output is 33.00

Former Member
0 Kudos

Hi,

Look at the following Pgm.It works fine for me.


REPORT  YTEST_VEN1.
 data: x type p decimals 3,
       y type p decimals 2,
       z type p decimals 2.

x = '15.000'.
y = '2.20'.

z = x * y.

write:/ z.

Regs,

Venkat Ramanan