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: 

Avoid Rounding off numbers

Former Member
0 Kudos

Hi Experts,

I have declared my internal table with variables using like bsak-dmbtr as below :

data : begin of itab occurs 0,

salpb like bsak-dmbtr,

solbm like bsak-dmbtr,

salhb like bsak-dmbtr,

end of itab.

Now While using SUM, the values in internal table gets rounded off .

I want to <b>avoid</b> rounding the numbers and display the amoutn as it is

i.e 9,712.97 should be shown as 9,712.97 and not 9712 or 9713.

The problem is the same when i declare the variables of <b>type p decimals 2</b>.

Could anyone please suggest me a solution.

Thanks

Dan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI

Instead of refering Data dictionary, try to delcare the field with type p decimals 2.

Ex

data : begin of itab occurs 0,

salpb type p decimals 2,

solbm type p decimals 2,

salhb type p decimals 2,

end of itab

and then find the sume for this field.

i hope this will solve ur problem

Need ur reward points.

Regards

Ravi

7 REPLIES 7

Former Member
0 Kudos

Hi

Check the attribute of your report, perhaps you've not checked the flag "Fixed Point Arthimetic"

Max

Former Member
0 Kudos

Hi Dan,

I am not sure if this problem is related to the SUM keyword or the program attributes.

Please check your program attributes and make sure the attribute (checkbox) "Fixed Point Arithmetic" is checked. If this is not checked, all your calculations will be rounded.

Hope this helps,

Sumant.

Former Member
0 Kudos

Hi,

If you dont have Fixed point arithmetic turned on , the rounding will happen

Kindly reward points if helpful.

Regards,

gaurav

Former Member
0 Kudos

Hi Dan,

Declare a variable of type DMBTR and inside the loop add the value to the decalred variable. This time after the loop the value will not bo rounded of. Means the value will come upto 2 decimal places.

e.g.:



DATA: v  type DMBTR.

Loop at itab.

v = v + bsak-dmbtr.

endloop.

Ashvender

0 Kudos

Hi All,

Yes the fixed point airthemtic box id checked. I am on version 4.0.

But still not solved.

Ashvender Kumar - can u elaborate that?

DATA: v type DMBTR.

should be DATA: v like bsak-DMBTR..Isn't it?

thanks

0 Kudos

Odd - would you try running this? It works as expected with fixed point arithmetic on or off:


REPORT ztemp LINE-SIZE 80 MESSAGE-ID 00.

DATA: bseg_int TYPE TABLE OF bseg WITH HEADER LINE.

SELECT * FROM bseg
  INTO TABLE bseg_int UP TO 10 ROWS.

LOOP AT bseg_int.
  WRITE /001 bseg_int-dmbtr.
  AT LAST.
    SUM.
    WRITE /001 bseg_int-dmbtr.
  ENDAT.
ENDLOOP.

Rob

Former Member
0 Kudos

HI

Instead of refering Data dictionary, try to delcare the field with type p decimals 2.

Ex

data : begin of itab occurs 0,

salpb type p decimals 2,

solbm type p decimals 2,

salhb type p decimals 2,

end of itab

and then find the sume for this field.

i hope this will solve ur problem

Need ur reward points.

Regards

Ravi