Sunday 21 December 2014

OO ABAP Exception classes [About Using CX_STATIC_CHECK] Multiple Catch & Clean Up

-------------------------------------------------------------------------------------------------------------------------------------------
MULTIPLE CATCH in single [TRY .. ENDTRY] block
Step1. So here we have the program with two exception classes. based on some condition two different exceptions are raised in the VALIDATE_INPUT method. The exception is handled in  where the VALIDATE_INPUT method is called with Multiple CATCH statement in the TRY ENDTRY block. Run the program with different sets of inputs.


Step2. Input number as 50.

Step3. No exception is raised and we have the output.

Step4. Run with 0 .

Step5. We have the first exception handled and the Code after the particular CATCH statement is executed.

Step6. So here we have another input number. Execute it.


Step7. Here the Second exception handled and the Code after the particular CATCH statement is executed.




CLEANUP- The context of the TRY & ENDTRY block can be cleaned up in the CLEANUP block. As exception leads to end the program prematurely, cleanup block can be used to release external resources which an external resources no longer has access.

Step8. Here is the program When the exception is raised then the code under the CLEANUP block is executed. Execute the program.

Step9. Here when the exception is raised then the cleanup block is executed. Here we are clearing some variables or we can free the memory and then the exception is catched.


Step10. So here we have the output.














---------------------------------------------------------------------------------------------------------------------------------------

No comments:

Comments system

Disqus Shortname