Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
AlwinPut
Active Participant
This blog post contains code templates for quickly adding code for catching ZCX_RETURN2 exceptions.

For more information on exception class ZCX_RETURN2, see blog post:

https://blogs.sap.com/2020/05/11/abap-exception-class-zcx_return2/

Overview




ZEXC_CATCH_OO - Catch in OO method


    TRY.

"Execute methods
"...

"Commit
"zca_db_transaction->commit( ).

CATCH zcx_return2 INTO DATA(lx_return).

"zca_db_transaction->roll_back( ).

"Handle exception lx_return
RAISE EXCEPTION lx_return.

ENDTRY.

 

ZEXC_CATCH_GATEWAY - Catch in SAP Gateway (SEGW)


    TRY.

"...instiantiate object and call methods

"Commit work (if needed)
"zca_db_transaction->commit( ).

CATCH zcx_return2 INTO DATA(lx_return).

"Roll back (if needed)
"zca_db_transaction->rollback( ).

"Handle exception
DATA(ls_return) = lx_return->get_bapiret2_struc( ).

DATA(ls_message) = VALUE scx_t100key(
msgid = ls_return-id
msgno = ls_return-number
attr1 = ls_return-message_v1
attr2 = ls_return-message_v2
attr3 = ls_return-message_v3
attr4 = ls_return-message_v4 ).

RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
EXPORTING
textid = ls_message.

ENDTRY.

ZEXC_CATCH_ABAP_PROX - Catch in ABAP Proxy


    TRY.

"...

"Commit work (if needed)
"zca_db_transaction->commit( ).

CATCH zcx_return2 INTO DATA(lx_return).

"Roll back (if needed)
"zca_db_transaction->rollback( ).

"Fill proxy exception message
DATA(lt_bapiret2) = lx_return->get_bapiret2_table( ).

cl_proxy_fault=>raise(
EXPORTING
exception_class_name = 'ZWMSCX_EXCHANGE_FAULT3' "Change
bapireturn_tab = lt_bapiret2 ).

ENDTRY.

ZEXC_CATCH_RFC - Catch in RFC Function Module


    TRY.

"...instiantiate object and call methods

"Commit work (if needed)
"zca_db_transaction->commit( ).

CATCH zcx_return2 INTO DATA(lx_return).

"Roll back (if needed)
"zca_db_transaction->rollback( ).

DATA(ls_return) = lx_return->get_bapiret2_struc( ).

MESSAGE
ID ls_return-id
TYPE ls_return-type
NUMBER ls_return-number
RAISING error
WITH ls_return-message_v1
ls_return-message_v2
ls_return-message_v3
ls_return-message_v4.

ENDTRY.

ZEXC_CATCH_BAPI - Catch in BAPI


    TRY.

"...

"Commit work (if needed)
"zca_db_transaction->commit( ).

CATCH zcx_return2 INTO DATA(lx_return).

"Roll back (if needed)
"zca_db_transaction->rollback( ).

"Fill return table
et_return = lx_return->get_bapiret2_table( ).

ENDTRY.

ZEXC_CATCH_MESSAGE - Catch, raise by MESSAGE statement


    TRY.

"...

CATCH zcx_return2 INTO DATA(lx_return).

DATA(ls_return) = lx_return->get_bapiret2_struc( ).

MESSAGE
ID ls_return-id
TYPE ls_return-type
NUMBER ls_return-number
WITH ls_return-message_v1
ls_return-message_v2
ls_return-message_v3
ls_return-message_v4.

ENDTRY.

ZEXC_CATCH_OLD_RETUR - Convert old RETURN exception to new RETURN exception


    TRY.

"...

CATCH zcx_return INTO DATA(lx_return).

DATA(lx_return2) = zcx_return2=>create_by_bapiret2_table( lx_return->get_bapiret2_table( ) ).

RAISE EXCEPTION lx_return2.

ENDTRY.