2008 Jul 12 11:17 AM
Hi,
I have a requiement of deviding the packed (type p ) fields.
and moving the result into packed field.
data :pack(5) type p decimals 4 ,
a(5) type p decimals 4 value '1000.3',
b(5) type p decimals 4 value '00.5',
c(5) type p decimals 4 value '00.2457',
d(5) type p decimals 4 value '2000.765'.
pack = ( ( a / b ) / ( c / d ) ).
write : / pack.
while moving the result I am getting dump because of overflow.
resultant value field should be of type P and decimals 4.
Can anyone suggest me how to avoid dump.
Are there any exceptions that I need to handle
if u have code for this please let me know
Thanks
2008 Jul 12 12:10 PM
hi,
do it in this manner
data :pack type p decimals 4 ,
a type p decimals 4 value '1000.3',
b type p decimals 4 value '00.5',
c type p decimals 4 value '00.2457',
d type p decimals 4 value '2000.765'.
pack = ( ( a / b ) / ( c / d ) ).
write : / pack.
2008 Jul 12 11:23 AM
Hi Devi,
Declare pack as below..
As you get 16,291,129.2593 after computaion...
you change the declaration as below.
data :pack type p decimals 4.So that pack will have value with decimals 4..
hope this solve your problem..
Any issue still revert back.
Regards
Narin Nandivada
2008 Jul 12 11:31 AM
Hi Rama devi,
Let me wxplain why this dump came.
The calculated value here is 16,291,129.2593. We are trying to place this in field of length 5 and decimals 4. Number of digits before decimal is more than defined lenth.(5) So it is not able to place this data and can't truncate since decimals are there.
So it don't know what to do. Thats why dump.
Always remember one thing, If u r going to calculate some thing then define the length of resultant variable to the max possible extent to avoid such dumps. There is no other way.
If u declare pack variable as type c length 5 then u will get result as --1129--. Here this * indicates ur data was truncated.* In this case u can avoid dump at least. But data will be truncated.
Thanks,
Vinod.
2008 Jul 12 12:10 PM
hi,
do it in this manner
data :pack type p decimals 4 ,
a type p decimals 4 value '1000.3',
b type p decimals 4 value '00.5',
c type p decimals 4 value '00.2457',
d type p decimals 4 value '2000.765'.
pack = ( ( a / b ) / ( c / d ) ).
write : / pack.