Skip to Content
0
Former Member
Dec 09, 2011 at 07:27 PM

Raising and catching exceptions...between try and entry....

1560 Views

Hi Team,

I have created onc z exception class ..i have few doubts regarding raising exceptions ...

my code is like this..

PARAMETERS: myamount TYPE i.

DATA: mysavings TYPE i VALUE 5000,

plannedbalance TYPE i,

ex TYPE REF TO ZCX_DEMO_EXCEPTION_TEST,

mes TYPE string.

START-OF-SELECTION.

RAISE EXCEPTION TYPE ZCX_DEMO_EXCEPTION_TEST EXPORTING amnt = myamount

saving = mysavings.

TRY.

plannedbalance = mysavings - myamount.

IF plannedbalance < 0.

. ENDIF.

CATCH zCX_DEMO_EXCEPTION_TEST INTO ex.

mes = ex->get_text( ).

MESSAGE mes TYPE 'I'.

ENDTRY.

...........my doubt is why we cant abel to cach the exception ..even we i catched them in TRY and entry.....for above code system is giving warning message...

but if we keep raise and catch statement between try and entry ...then no issues....it is working fine.

Please calrify me..

<removed by moderator>

Regards

Ramaky

Edited by: Thomas Zloch on Dec 9, 2011 8:36 PM