‎2006 Nov 15 5:00 PM
Hi All,
I am trying to raise an exception and use a throw statement after catch inside try endtry in ABAP objects. Later i understood that there is no throw statement defined in ABAP objects. Could anyone help me out to understand the equivalent throw statement in ABAP and how to use in raise exception. I am pasting my code below for reference.
try.
-
---
CATCH Zxx_EXCEPTION into err.
write:/ err->local_text.
message err->LOCAL_TEXT type 'I'.
if err->local_text = ZIF_XXXX~BUSOBJLOCKED.
throw CX_AI_APPLICATION_FAULT.
endtry.
Thanks
Deno
‎2006 Nov 15 5:14 PM
‎2006 Nov 15 7:51 PM
Hello Deno
The TRY/CATCH logic of ABAP-OO is pretty much the same like in Java. Instead of throwing exception we have to raise them.
Method execute somewhere raise an exception of class zcx_myexception.
method execute.
if ( condition = abap_true ).
...
else.
RAISE EXCEPTION TYPE zcx_myexception
EXPORTING
textid = ...
<parameter> = ...
endif.
endmethod.TRY.
call method go->execute( ).
CATCH zcx_myexception INTO lo_error.
* Do error handling
ENDTRY.If the method that calls go->execute does not surround the method call by TRY/CATCH then it must define the exception class in its interface and, thereby, propagate the exception to the next higher level calling method.
Regards
Uwe
‎2006 Nov 15 10:22 PM
Just on slight addition to Uwe how to propagte Instances of exception classes in the signature of methods depends wether they inherit from
CX_NO_CHECK
CX_DYNAMIC_CHECK
CX_STATIC_CHECK
you will find some documentation attached to these classes.
Best Regards
Klaus
‎2006 Nov 15 10:45 PM
Hello Klaus
I appreciate very much your refinements and corrections because they help me to proceed from the (still) beginner level to the advanced ABAP-OO developer.
Best Regards (from Zürich)
Uwe
‎2006 Nov 16 6:23 AM
‎2006 Nov 16 6:50 AM
Hi,
Thanks for all ur replies. In my scenario, once i get an exception Business object locked, I have to throw the CX_AI_Application_fault message again to send the process to queue. So that there is no manual intervention required to restart. Once the business object lock problem gets over, automatically the queue opens and message flow resumes without any manual intervention. So please let me know how this can be achieved here.
Thanks
Deno