‎2008 Nov 26 2:16 AM
I have some interesting scenarios:
There is already a classic BADI and now a new method is to be added to the interface.
For the implementation class, they, for sure, don't implement the new method, however no syntax errors occur.Yet when runtime error 'CALL_METHOD_NOT_IMPLEMENTED' is raised when the new method is called via a variable of the interface.
CATCH SYSTEM-EXCEPTIONS CALL_METHOD_NOT_IMPLEMENTED = 4.
CALL METHOD g_badi->test.
* do nothing as customer don't necessarily implement the inteface
ENDCATCH.
Even I have try catch statement blocks surrounding the method call, the exception is still raised.
How can I handle it to catch the exception to avoid any short dumps?
‎2008 Nov 26 7:16 AM
Hi Xin,
Instead of catching SYSTEM-EXCEPTIONS try like below..
DATA : go_exception TYPE REF TO cx_sy_dyn_call_illegal_method, " Exception object
gv_reason TYPE string. " Reason for Exception
TRY.
CALL METHOD g_badi->test.
CATCH cx_sy_dyn_call_illegal_method INTO go_exception.
gv_reason = go_exception->if_message~get_text( ).
" gv_reason has the reason/cause for exception..
ENDTRY.Cheers,
Jose.
‎2008 Nov 26 7:16 AM
Hi Xin,
Instead of catching SYSTEM-EXCEPTIONS try like below..
DATA : go_exception TYPE REF TO cx_sy_dyn_call_illegal_method, " Exception object
gv_reason TYPE string. " Reason for Exception
TRY.
CALL METHOD g_badi->test.
CATCH cx_sy_dyn_call_illegal_method INTO go_exception.
gv_reason = go_exception->if_message~get_text( ).
" gv_reason has the reason/cause for exception..
ENDTRY.Cheers,
Jose.
‎2008 Dec 03 8:18 AM
HI, Jose
After I use the try catch block, the exception is still thrown out.
Are there any other ways to handle that?
Thanks
Xin
‎2008 Dec 03 8:53 AM
Hi Xin,
What does this ( 'exception is still thrown out' ) mean? a short-dump??
If yes, search for the raised exception object's type( starts with CX_ ) in the short-dump
and use that instead of cx_sy_dyn_call_illegal_method....
Coding like below is the most generic way and ll catch any class based exception.
TRY.
CALL METHOD g_badi->test. " ur method call
CATCH cx_root.
"Handler code.
ENDTRY.If u r still getting a short-dump, then probably the exception is being raised somewhere else.......
Cheers,
Jose.