‎2008 Oct 28 7:06 AM
Hi
How to catch BCS Exceptions raised by FM in the calling program.
I tried Sy-subrc but unable to do so.
Can anyone sample code for the same
‎2008 Oct 28 10:53 AM
Hello Nihi
Either you catch the BCS exception within the function module (as shown above) or you forward (THROW) the exception to the calling program. In this case you need to define the exception class as exception of the fm interface.
Regards
Uwe
‎2008 Oct 28 10:07 AM
Hi Nihi,
Like this...
DATA eo_bcs TYPE REF TO cx_bcs.
TRY.
" write ur code here....
CATCH cx_bcs INTO eo_bcs.
" error handling code...
ENDTRY.Cheers,
Jose.
‎2008 Oct 28 10:53 AM
Hello Nihi
Either you catch the BCS exception within the function module (as shown above) or you forward (THROW) the exception to the calling program. In this case you need to define the exception class as exception of the fm interface.
Regards
Uwe
‎2008 Oct 28 9:24 PM
HI Uwe and Jose,
I am raising the exception in FM as below.
I am having problem in catching them in the program.
i defined cx_bcs in the FM(Exceptions Tab) too.
DATA eo_bcs TYPE REF TO cx_bcs.
TRY.
" write ur code here....
CATCH cx_bcs INTO eo_bcs.
RAISE eo_bcs.
ENDTRY.
‎2008 Oct 29 3:58 AM
HI,
I am raising the exception from custom FM as below.
i have declared cx_bcd uder exceptions tab too and checked exception classes too..
DATA eo_bcs TYPE REF TO cx_bcs.
TRY.
" my process
CATCH cx_bcs INTO eo_bcs.
RAISE eo_bcs.
ENDTRY.
I am calling the FM from my custom program. i am having trouble in coding to catch the exceptions(class-based) raised by the custom FM.
My program is working fine if everythign is alright but getting dump if get any exception from FM.i need to handle those kind of scenarios.
Does any one help me in this regard.
‎2008 Oct 29 4:05 AM
Hi
One more thing is when i do source extended check i am getting this message..
The exception CX_BCS is neither caught nor is it declared in the RAISING clause of "FM_SEND_EMAIL".
what does it indicate! any ideas..
‎2008 Oct 29 4:33 AM
Hello Nihi
You misunderstood the meaning of defining the class-based exception in the fm signature. Have a look at sample report ZUS_SDN_CX_EXCEPTION_RAISE which demonstrates how to throw and catch class-based exceptions.
Custom function module with class-based exception in its signature:
FUNCTION zus_sdn_cx_exception_raise.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(ID_FLAG) TYPE BOOLE_D DEFAULT SPACE
*" RAISING
*" CX_BCS " <<< Flag 'Exceptn. Class' checked
*"----------------------------------------------------------------------
IF ( id_flag = 'X' ).
" Simulate exception raised by class cl_bcs
RAISE EXCEPTION TYPE cx_send_req_bcs
EXPORTING
error_type = cx_send_req_bcs=>allready_released.
ENDIF.
" NOTE: Here we do not catch the exception but throw it,
" i.e. the class-based exception is defined at the
" fm signature which causes the exception to be propagated
" to the caller.
ENDFUNCTION.
And here is the sample report:
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_CX_EXCEPTION_RAISE
*&
*&---------------------------------------------------------------------*
*& Thread: BCS Exceptions
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1104287"></a>
*&---------------------------------------------------------------------*
REPORT zus_sdn_cx_exception_raise.
DATA: go_error TYPE REF TO cx_bcs.
PARAMETERS:
p_flag TYPE boole_d DEFAULT ' '.
START-OF-SELECTION.
BREAK-POINT.
TRY.
CALL FUNCTION 'ZUS_SDN_CX_EXCEPTION_RAISE'
EXPORTING
id_flag = p_flag.
CATCH cx_bcs INTO go_error.
MESSAGE 'Exception Raised -> Thrown -> Caught' TYPE 'I'.
LEAVE PROGRAM.
ENDTRY.
MESSAGE 'No exception raised' TYPE 'S'.
END-OF-SELECTION.
Regards
Uwe
‎2008 Oct 29 5:58 AM
God Bless Uwi..
Learnt lesson and resolved my long standing issue.