2013 Jun 18 8:36 PM
Hi Experts,
I need some advice on why my exception is not getting caught. Here are the details.
Exception Class: ZCX_BW_SD_CODE
class ZCX_BW_SD_CODE
definition
public
inheriting from CX_STATIC_CHECK
final
create public .
public section.
*"* public components of class ZCX_BW_SD_CODE
*"* do not include other source files here!!!
constants ZCX_BW_SD_CODE type SOTR_CONC value '1F47B9514EDAE054E1000000AC13310E'.
"#EC NOTEXT
constants NO_DATA_SP type SOTR_CONC value '1F49B9514EDAE054E1000000AC13310E'. "#EC
NOTEXT
constants NO_ORDER_DATA_SP type SOTR_CONC value '2248B9514EDAE054E1000000AC13310E'.
"#EC NOTEXT
data REQUEST type RSREQUEST .
data PACKET type RSDATAPID .
data RECORD type RSARECORD .
data SDORDER type /BI0/OIDOC_NUMBER .
data SDORDERLINE type /BI0/OIS_ORD_ITEM .
data GT_BSARKSD type /BI0/OIGT_BSARKSD .
data DISTR_CHAN type /BI0/OIDISTR_CHAN .
Exception is raised in a method ZCL_BW_SD_CODE->GET_ORDERS
methods GET_ORDERS
importing
!I_T_SP type ANY TABLE
!I_PACKET type RSDATAPID
raising
resumable(ZCX_BW_SD_CODE) .
METHOD get_orders.
...
IF i_t_sp IS INITIAL.
RAISE EXCEPTION TYPE zcx_bw_sd_code
EXPORTING
textid = zcx_bw_sd_code=>no_data_sp
packet = i_packet.
ELSE.
...
ENDMETHOD.
I'm calling this method in the start routine of a BW 7.0 Transformation.
...
DATA: gl_cx TYPE REF TO zcx_bw_sd_code,
gcl_sdcode TYPE REF TO zcl_bw_sd_code.
DATA: gv_text TYPE string.
....
* Load Sale Order
lookup table in SD code class
TRY.
CALL METHOD gcl_sdcode->get_orders
EXPORTING
i_t_sp = SOURCE_PACKAGE[]
i_packet = datapackid.
* If there is no SD Order data selected than raise an error.
*Always need to have reference SD order data and data in Source Package.
CATCH zcx_bw_sd_code INTO gl_cx. <-----NOT CATCHING THE EXCEPTION HERE
gv_text = gl_cx->get_text( ).
monitor_rec-msgid = 'Z001'.
monitor_rec-msgty = 'I'.
monitor_rec-msgno = 040.
monitor_rec-msgv1 = gv_text.
APPEND monitor_rec TO MONITOR
RAISE EXCEPTION TYPE CX_RSROUT_ABORT.
ENDTRY.
...
If I type gl_cx as cx_root the it catches but I'm not sure why it won't catch zcx_bw_sd_code. Thank you in advance for any help.
Regards,
Dae Jin
2013 Jun 18 9:38 PM
Hi Dae,
Check the exception raised by program is type of ZCX_BW_SD_CODE in debugger.I hope exception raised is different type.
Regards,
Sreeniavs.
2013 Jun 18 9:57 PM
Hi Sreeniavs,
The exception is never caught at "CATCH zcx_bw_sd_code INTO gl_cx.". It get's caught in the calling method of the start routine as cx_root. I have my code in the start routine of a BW transformation. Basically an exit in a SAP BW generated program where user code can be added. So the calling method is:
...
TRY.
i_r_log->add_substep( 'ROUTS' ).
*<<< Rule ID: '47'.
_curr_rule-ruleid = '47'.
* Step ID: '1', Type: 'ROUTINE'.
_curr_rule-stepid = '1'.
CALL METHOD me->start_routine <-----This method is where I write my code.
EXPORTING
request = l_request
datapackid = i_r_inbound->n_datapakid
IMPORTING
monitor = _lt_msg_s
CHANGING
SOURCE_PACKAGE = <_yt_SC_1>.
...
CATCH cx_root INTO lr_cx_root. <---This is where the exception gets caught.
If I change my declaration of gl_cx to "type ref to cx_root", and the catch line to "CATCH cx_root INTO gl_cx." then the line catches the exception but as errid "UNCAUGHT_EXCEPTION".
Regards,
Dae Jin
2013 Jun 18 11:02 PM
Hi Dae,
Change the exception class type as CX_NO_CHECK if possible or remove the raising clause in Get_order method definition.
for more details
http://help.sap.com/saphelp_nw04/helpdata/en/83/636d1712fc11d5991e00508b5d5211/frameset.htm
Regards,
Sreenivas.
2013 Jun 18 10:10 PM
I wonder if it is in fact catching the zcx_bw_sd_code exception and your uncaught exception is the one you're raising within the catch:
CATCH zcx_bw_sd_code INTO gl_cx.
gv_text = gl_cx->get_text( ).
monitor_rec-msgid = 'Z001'.
monitor_rec-msgty = 'I'.
monitor_rec-msgno = 040.
monitor_rec-msgv1 = gv_text.
APPEND monitor_rec TO MONITOR
RAISE EXCEPTION TYPE CX_RSROUT_ABORT.
ENDTRY.
2013 Jun 18 11:25 PM
Hi,
The code works. For some reason when I debugged the 5 times it didn't catch the exception. I then logged off and logged back on and then debugged again and the exception was caught. I'm guessing something in the compiler, runtime and/or buffer?
Thanks,
Dae Jin