‎2007 Jul 27 5:51 AM
Hi experts
I am using this field
bdmng LIKE resb-bdmng, * 0.010
iamng LIKE afpo-iamng, * 150
it_final-iamng = it_final-bdmng / it_final-psmng.
when i do calculations in program the result of iamng
is supposed to 6.66667E-05, but it assigns iamng = 0.
but iamng takes Zero, i don't know why, is this problem with packed type.
how to solve this problem and declare this decimal places.
Thanks in advance.
Regards
Rajaram
‎2007 Jul 27 6:00 AM
Hi
All these are QUAN type field with 3 decimals
If you want integer as output for IAMNG field declare another variable of TYPE I and then move this IAMNG to that variable and display
check the values of the fields in debug mode and see
if not it_final-psmng is initial.
it_final-iamng = it_final-bdmng / it_final-psmng.
endif.
<b>Reward points for useful Answers</b>
Regards
Anji
‎2007 Jul 27 6:24 AM
Its ok but again it give the following error yar
An internal table field is too short.
CX_SY_ARITHMETIC_OVERFLOW'
The name of the field is "BDMNG".
how to solve this.
‎2007 Jul 27 6:10 AM
actual value of 6.66667E-05 is 0.0000666667 so when you are taking in iamng( which has decimals 3) it only takes first 3 digit after the decimal and gives you the value 0.000. so as per your requirement you have to assign some typ p variable with decimals 5 or more to get the value.
by default iamng is of decimals 3.. so you declare like that
data : result type p decimals 6.
result = it_final-bdmng / it_final-psmng.
write : / result.
and before doing the calculation check it_final-psmng is non zero value as said by anji.
regards
shiba dutta
‎2007 Jul 27 6:32 AM
thank you very much yar
and bdmng also gives dump with the following error.
CX_SY_ARITHMETIC_OVERFLOW'
when i try the collect stmt.
how to solve this.
‎2007 Jul 27 6:33 AM
this is the error description.
An internal table field is too short.
‎2007 Jul 27 6:34 AM
i think you are not clearing properly your field. In somecases it may added or multiply with other value and give you this error just check it ... and if possible please paste the code..
regards
shiba dutta
‎2007 Jul 27 6:38 AM
when i treid this code, am getting the error.
loop at itab1.
move-corresponding itab1 to it_final.
collect it_final.
endloop.
again problem with bdmng, what could be.
‎2007 Jul 27 6:47 AM
its may be for the collect statement because it is adding the bdmng field every time when the key field of your int table is repeated. So if it is necessary to add tose bdmng then i think it is not possible by quantity field . If your quantity field does not contain any decimal value(e.g. if your qty 12 whole number) then you have to take it in type n field . If it contains decimal value then you have to assign the sum in a character field. But for both the cases collect will not work you have to do the sum manually.
regards
shiba dutta
‎2007 Jul 27 6:57 AM
no collect is working for some data with quan field ,
but some of the cases it is not working, i don't know why.
see this error description.
An exception occurred. This exception will be dealt with in more detail
below. The exception, assigned to the class 'CX_SY_ARITHMETIC_OVERFLOW', was
not caught, which
led to a runtime error. The reason for this exception is:
The COLLECT statement stores totals in the internal table
"\PROGRAM=Z_PGM\DATA=IT_FINAL[]",
but the values are too large for the type P field intended to store them
.
The name of the field is "BDMNG".
‎2007 Jul 27 7:05 AM
as per my previous thread i have told due to collect the addition of bdmng is overflowing the capacity of type p variable..
so declare a inttable like that..
data : begin of itab,
aufnr like afpo-aufnr,
sum(40).
end of itab.
now suppose your data is present in iafpo with aufnr posnr and bdmng.
sort iafpo by aufnr posnr.
loop at iafpo.
itab-sum = itab-sum + iafpo-bdmng.
itab-aufnr = iafpo-aufnr.
at end of aufnr.
append itab.
endat.
endloop.
i think because of collect statement the error is coming...
just try like the above code (make adjustment as per need that is only an idea)...
regards
shiba dutta
‎2007 Jul 27 8:09 AM
ok yar
thank you very much, let me check and revert back you soon.
Regards
Rajaram