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: 

Exception problem

Former Member
0 Kudos

Hi Everyone,

I tried a lot but dont which exception to use in this case, the code is like below and i want to catch the exception and throw up a message can anyone help me please. In this case it again throws the runtime error.

<b>CONVT_OVERFLOW

CX_SY_CONVERSION_OVERFLOW

Overflow when converting from "2.35589e+35"</b>

<b>data a(16) type p decimals 4.

data max_value(16) type p value 999999999999.

PARAMETER b(16) type p decimals 2.

PARAMETER no_rb RADIOBUTTON GROUP RAD1.

PARAMETER year_rb RADIOBUTTON GROUP RAD1.

if year_rb = 'X'.

CATCH SYSTEM-EXCEPTIONS ARITHMETIC_ERRORS = 1.

a = b ** 365. <---- error line

ENDCATCH.

IF sy-subrc = 1.

a = max_value.

message i100.

else.

write: AT 2'SY-SUBRC', AT 25'A'.

write:/ sy-subrc, a.

endif.

endif.</b>

Can anyone please give a solution to handle this exception i tried a lot but nothing works.

Prashant

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Use <b><u>convt_overflow</u></b>. If you take out your CATCH, ENDCATCH portion and run your computation alone, you will get a dump. The very first statement of the dump will tell you what the system exception is. You have to use that one. In this case it is convt_overflow.

16 REPLIES 16

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

It is actually catching the error quite well for me. What are you putting into the parameter B when executing.

Regards,

Rich Heilman

0 Kudos

Hi,

I give a value 1.25 and any number with decimal point it not working.

Regards,

Prashant.

0 Kudos

Does you B field have to be define with 16, defining as 8, I believe this will fix your problem.

Regards,

Rich Heilman

0 Kudos

Hi Rich,

No i changed the b from 16 to 8 but still the same problem.

It throws the same error.

What could be done.

Any solution.

Thanks,

Prashant.

0 Kudos

What version are you on?

Regards,

Rich Heilman

0 Kudos

Yes, now I'm seeing the same, it worked before.

Regards,

Rich Heilman

Former Member
0 Kudos

If I use convt_overflow, it worked for me. What version of SAP are you on?

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Lets try a diffent system exceptions. This is now working for me.



  <b>catch system-exceptions convt_overflow = 1.</b>
*  catch system-exceptions arithmetic_errors = 1.
    a = b ** 365. "<---- error line
  endcatch.



Regards,

Rich Heilman

Former Member
0 Kudos

This works for me.


DATA a(16) TYPE p DECIMALS 4.
DATA max_value(16) TYPE p VALUE 999999999999.


PARAMETER b(16) TYPE p DECIMALS 2.

PARAMETER no_rb RADIOBUTTON GROUP rad1.
PARAMETER year_rb RADIOBUTTON GROUP rad1.

IF year_rb = 'X'.
  CATCH SYSTEM-EXCEPTIONS convt_overflow = 1.
    a = b ** 365.
  ENDCATCH.
  IF sy-subrc = 1.
    a = max_value.
  ENDIF.
ENDIF.

MESSAGE i100.
WRITE: AT 2'SY-SUBRC', AT 25'A'.
WRITE:/ sy-subrc, a.

Former Member
0 Kudos

Use <b><u>convt_overflow</u></b>. If you take out your CATCH, ENDCATCH portion and run your computation alone, you will get a dump. The very first statement of the dump will tell you what the system exception is. You have to use that one. In this case it is convt_overflow.

0 Kudos

Hi Everyone,

thanks for all your replies it works when i change the exception to cont_overflow. But again when u give a value 12.35 or so it throws up a error

Overflow or underflow with exponentiation.

compute_pow_range

cx_sy_arithmetic_overflow.

How do I capture all the exception.

Is there where I can specify when others exception and capture them so that I need not specify a particular exception.

Any help on this will be of great use to me.

thanks,

Prashant.

0 Kudos

Catch both of them.

<b>  catch system-exceptions convt_overflow = 1.
    catch system-exceptions arithmetic_errors = 2.
      a = b ** 365. "<---- error line
    endcatch.
  endcatch.</b>

Regards,

Rich Heilman

0 Kudos

Hi,

i tried giving as u have done, but when u specify the b value as 12.35 the value of a is 00. whereas it has to calculate and put the value, but instead it gives a zero.

what can be done????????

thanks,

Prashant.

0 Kudos

Try this.


DATA a(16) TYPE p DECIMALS 4.
DATA max_value(16) TYPE p VALUE 999999999999.


PARAMETER b(16) TYPE p DECIMALS 2.

PARAMETER no_rb RADIOBUTTON GROUP rad1.
PARAMETER year_rb RADIOBUTTON GROUP rad1.

IF year_rb = 'X'.
  CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 1
                          conversion_errors = 2.
    a = b ** 365.
  ENDCATCH.
  IF sy-subrc <> 0.
    a = max_value.
  ENDIF.
ENDIF.

MESSAGE i100.
WRITE: AT 2'SY-SUBRC', AT 25'A'.
WRITE:/ sy-subrc, a.

0 Kudos

Thanks sreeni finally it worked.

thanks everyone for all your answers.

Regards,

Prashant.

0 Kudos

Good work. Make sure that you mark this post as solved.

REgards,

Rich Heilman