Application Development and Automation 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: 
Read only

oveflow for type p fields

Former Member
0 Likes
689

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
645

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.

3 REPLIES 3
Read only

Former Member
0 Likes
645

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

Read only

vinod_vemuru2
Active Contributor
0 Likes
645

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.

Read only

Former Member
0 Likes
646

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.