06-06-2006 10:29 PM
Hi Everyone,
this is an urgent issue, I have certains whose datatype is Packed decimal.
For certain numerical calculations i.e to calculate the variable to the power of 30 and power of 365 it throws up this abap runtime error.
All the variables have declared as packed decimal with 2 decimal places.
How can I fix this issue. Can anyone help me please,
Its really urgent.
Thanks in advance,
Prashant.
06-06-2006 11:44 PM
hi kumar,
for performing scientific operations like power etc it is alwayz prefer to use type f instead of type p.so jus replace all your type p with type f.
Cheers,
Abdul Hakim
Mark all useful answers..
06-06-2006 10:47 PM
06-06-2006 11:44 PM
hi kumar,
for performing scientific operations like power etc it is alwayz prefer to use type f instead of type p.so jus replace all your type p with type f.
Cheers,
Abdul Hakim
Mark all useful answers..
06-07-2006 12:39 AM
Hi,
I'm displaying the results in the form of percentage, so using floating point makes the result look a bit not so good.
Any suggestions please do let me know.
thanks,
Prashant.
06-07-2006 12:41 AM
hi kumar,
you cannot achive matissa and exponent scenario with type p you should you type f...
Cheers,
Abdul Hakim
Mark all useful answers..
06-07-2006 1:22 AM
Prashant,
as the guys have said, to stop overflow you're going to have to use float internally.
You could move this number to a char variable and then split it into the exponent and mantissa and then construct a display variable from these components. But even 2 ** 365 is 7.515336264876E+109 which means to show it as a character string will almost fill an average report line, and I think most users will not find looking at that very nice either.
The reality is you're dealing with huge numbers and the best way to represent them is the exponential style.
Another thing you could do is set overflow numbers to the biggest number available in the packed format.
eg, something like
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 1.
result = a ** b.
ENDCATCH.
if there is overflow...
IF sy-subrc = 1.
it must be..
result = c_max_value.
ENDIF.
06-15-2006 12:12 AM
Hi Everyone,
As you have suggested, if it is a large number i try to catch the exception as u have said, but it does not catch instead throws the same abap runtime error.
Here is the sample code, where i am catching the exception.
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 1.
a = b * 365.
ENDCATCH.
IF sy-subrc = 1.
a = max_value.
ENDIF.
Any help will be of great use to me.
Thanks,
Prashant.
06-15-2006 12:56 AM
Prashant,
how are a and b declared and what values do they have?
exactly what runtime error are you getting?
and how is max_value declared? If this is bigger than the allowed amount in 'a' then this will cause the overflow itself! Max_value has to be set to no more than the biggest number that 'a' can hold.
06-15-2006 5:28 PM
Hi,
I declared it maxvalue as type f. but still i get the overflow error.
How do else i try and catch this exception.
It throws me the same overflow error. it is not catching the exception.
Any help will be of great use to me its really urgent.
Thanks,
Prashant.
06-15-2006 5:40 PM
Prashant - are you saying that your final percentage is 1.09425e+11, or is at intermediate number?
Rob
06-15-2006 5:45 PM
Hi,
Within the catch and endcatch block, I have assigned the maxvalue to a, and declared this max value as type f.
For that its not catching the exception. instead again it throws the runtime overflow error.
I was to capture this exception and in the result i want to assign some string saying maxvalue if the value is huge i.e overflowing.
Any help will be appreciated.
Thanks,
Prashant.
06-15-2006 5:54 PM
Hi,
Try using within
Try ...ENDTRY.
<b>
TRY.
.........try ur logic.
CATCH cx_ai_system_fault . " ur exception name
WRITE 😕 o_fault->errortext.
ENDTRY.</b>
06-16-2006 12:31 AM
Prashant,
max_value HAS TO BE TYPE P. If it is type F with a bigger value than type P can hold THEN OF COURSE IT WILL OVERFLOW.
The overflow you are now getting is not within the catch but on the 'a = max_value' statement.
eg this works,
data a(15) type p.
data b(15) type p value 20000000000000.
data max_value(15) type p value 999999999999
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 1.
a = b ** 365.
ENDCATCH.
IF sy-subrc = 1.
a = max_value.
write:/ sy-subrc,a.
endif.
06-16-2006 8:39 AM
Hi,
you can try this ....
i just added to Neils suggestion....
changed the EXCEPTION name.
data a(15) type p.
data b(15) type p value 20000000000000.
data max_value(15) type p value 999999999999.
CATCH SYSTEM-EXCEPTIONS <b>COMPUTE_POW_RANGE</b> = 1.
a = b ** 365.
ENDCATCH.
IF sy-subrc = 1.
a = max_value.
write:/ sy-subrc,a.
endif.
Regards
vijay
06-16-2006 8:05 PM
Hey Guys,
See As how u have suggested I have given the code but still it doesn't pop up a message based on the checkbox.
I perform this only when a checkbox for year is pressed and based on this I have to pop up a message saying it is huge cannot be displayed and get back to the screen. how to I achieve this.
Any help will of great use to me.
if year = 'X'.
CATCH SYSTEM-EXCEPTIONS COMPUTE_POW_RANGE = 1.
a = b ** 365.
ENDCATCH.
IF sy-subrc = 1.
a = max_value.
MESSAGE a001.
ENDIF.
06-16-2006 8:21 PM
Do not issue an 'A'bend message. Try issusing a 'W'arning message.
MESSAGE w001
06-16-2006 8:29 PM
Also, see what exception you are getting in your runtime dump and use that exception.
06-17-2006 4:58 AM
Prashant, the 'A' type message forces an abend. Change it to an 'I' which will op it up in a seperate box or an 'S' mesaage which will just show it at the bottom of the next screen you show.
Also, did you try 'arithmetic error'. Why did you use compute_pow_range?