2015 Jun 22 6:02 AM
Hello All,
Question, Class A has super class B. A method defined in B is called in A which has an exception raised. If we use cleanup statement in class A will the exception is cleared.
Code is like this:
Class A:
Try.
Call Method B1
Clean up.
EndTry.
Class B:
Try.
If sy-subrc NE 0.
raise exception type cx_os_object_not_found
----------
Endtry.
Please provide your thoughts. Currently it dumps with UNCAUGHT_EXCEPTION.
2015 Jun 22 8:22 AM
You are missing CATCH exception in "outer" TRY - ENDTRY (in class A).
EDIT: Matthew was faster 🙂
2015 Jun 22 7:15 AM
Hi ,
share actual code instead of pseudo code which is bit confusing.
2015 Jun 22 7:19 AM
Here you go:
In Class - CA_PT_ARQ_DEDUCTION
At line 90 method pm_load_and_set_attributes is called which is implemented in Super class CB_PT_ARQ_DEDUCTION.
TRY.
CALL METHOD pm_load_and_set_attributes
EXPORTING
i_business_key = business_key.
CLEANUP.
CALL METHOD os_internal_undo.
CALL METHOD os_clear_current.
CLEAR current_special_object_info.
ENDTRY.
In method - pm_load_and_set_attributes, an exception
cx_os_object_not_found is raised at line 60
* * 2. Load from Database
try.
append BUSINESS_KEY to BUSINESS_KEY_TAB.
call method MAP_LOAD_FROM_DATABASE_KEY
exporting I_BUSINESS_KEY_TAB = BUSINESS_KEY_TAB
receiving result = OBJECT_DATA_TAB.
catch cx_os_db_select into ex_os_db_select.
class cx_os_object_not_found definition load.
raise exception type cx_os_object_not_found
exporting
bkey = ex_os_db_select->bkey
textid = cx_os_object_not_found=>by_bkey.
endtry.
2015 Jun 22 8:01 AM
Can I recommend using functional syntax - it's much less verbose. Or are you on a very old version of ABAP?
At line 90 method pm_load_and_set_attributes is called which is implemented in Super class CB_PT_ARQ_DEDUCTION.
TRY.
pm_load_and_set_attributes( business_key ).
CLEANUP.
os_internal_undo( ).
os_clear_current( ).
CLEAR current_special_object_info.
ENDTRY.
In method - pm_load_and_set_attributes, an exception
cx_os_object_not_found is raised at line 60
* * 2. Load from Database
try.
append BUSINESS_KEY to BUSINESS_KEY_TAB.
OBJECT_DATA_TAB = MAP_LOAD_FROM_DATABASE_KEY( BUSINESS_KEY_TAB ).
catch cx_os_db_select into ex_os_db_select.
class cx_os_object_not_found definition load. "<----- Do you really need this?
raise exception type cx_os_object_not_found
exporting
bkey = ex_os_db_select->bkey
textid = cx_os_object_not_found=>by_bkey.
endtry.
Cleanup doesn't work in the way you seem to be trying to use it. The cleanup works in nested trys. If an exception occurs in the inner try that's not caught by in the inner catch, but is caught by the outer catch, then the cleanup will execute.
TRY.
TRY.
do something that raises A.
CATCH B.
process exception B.
CLEANUP.
this will be executed for A.
ENDTRY.
CATCH A.
process exception A.
ENDTRY:
Example here: http://help.sap.com/saphelp_470/helpdata/en/a9/b8eef8fe9411d4b2ee0050dadfb92b/content.htm
2015 Jun 22 8:22 AM
You are missing CATCH exception in "outer" TRY - ENDTRY (in class A).
EDIT: Matthew was faster 🙂
2015 Jun 23 12:11 AM
Thanks for the response.
This is happening in SAP standard code, so can't able to change it accordingly.
Raised an OSS message, unfortunately asked for steps to replicate the issue.
We are trying to see possibility of reproducing the dump but no luck yet.
I will keep you posted on SAP response.