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

Catch CONVT_OVERFLOW

Former Member
0 Likes
884

Hi All,

I want below code (if sy-subrc = 😎 to work when the CONVT_OVERFLOW is fired.

However, here <b>CONVT_OVERFLOW</b> is not being catched in catch ...endcatch.

Any clues what shall I do.

catch system-exceptions CONVT_OVERFLOW = 8

delete t_vtbez from z_vtbez.

endcatch.

IF SY-SUBRC EQ 8.

DELETE TABLE T_VTBEZ WITH TABLE KEY vtbez = z_vtbez-vtbez

index_i = z_vtbez-index_i.

ENDIF.

Also How do I find out system-exception number for various system exceptions which might occur.

For Ex : CONVT_OVERFLOW system exception no is 8

Thank you.

2 REPLIES 2
Read only

Former Member
0 Likes
505

HI,

Catchable runtime errors are handled with CATCH SYSTEM-EXCEPTIONSusing the name of the runtime error. To detect semantically related runtime errors using a common name, they are combined into exception groups.

You can handle catchable runtime errors in an ABAP program using the following control statements:

CATCH SYSTEM-EXCEPTIONS exc1 = rc1 ... excn = rcn.

...

ENDCATCH

Check the sample code to handle the exceptions.

REPORT ZTEST.

PARAMETERS number TYPE i.

DATA: result TYPE p DECIMALS 2,

oref TYPE REF TO cx_root,

text TYPE string.

TRY.

IF ABS( number ) > 100.

RAISE EXCEPTION TYPE cx_demo_abs_too_large.

ENDIF.

PERFORM calculation USING number

CHANGING result

text.

CATCH cx_sy_arithmetic_error INTO oref.

text = oref->get_text( ).

CATCH cx_root INTO oref.

text = oref->get_text( ).

ENDTRY.

IF NOT text IS INITIAL.

WRITE / text.

ENDIF.

WRITE: / 'Final result:', result.

FORM calculation USING p_number LIKE number

CHANGING p_result LIKE result

p_text LIKE text

RAISING cx_sy_arithmetic_error.

DATA l_oref TYPE REF TO cx_root.

TRY.

p_result = 1 / p_number.

WRITE: / 'Result of division:', p_result.

p_result = SQRT( p_number ).

WRITE: / 'Result of square root:', p_result.

CATCH cx_sy_zerodivide INTO l_oref.

p_text = l_oref->get_text( ).

CLEANUP.

CLEAR p_result.

ENDTRY.

ENDFORM.

<b>Reward points</b>

Regards

Read only

RaymondGiuseppi
Active Contributor
0 Likes
505

(1) Is VTBEZ packed, if yes CONVT_OVERFLOW cannot be catched.

(2) You choose the exception number in the CATCH instruction,

catch system-exceptions CONVT_OVERFLOW = 1. would have worked in a similar way

Regards