Reporting and Handling Errors
The options for error handling depend on the type of communication chosen:
●
Asynchronous
Communication: On the sender
side, the application can only handle errors that occur when the message is
being sent (for example, the outbound queue is full). You can catch and
persist these errors by using the exception class CX_AI_SYSTEM_FAULT. On the receiver side, as in the synchronous
case, you can define fault messages, which are then only forwarded to monitoring (and
not to the sender).
If you want to define how the sender is to process asynchronous errors, see
the Acknowledgments section. The Web service
runtime only supports synchronous communication.
● Synchronous Communication: You can use fault messages to handle errors that have occurred on the receiver side. To confirm an error, the proxy runtime sends the fault message from the receiver back to the sender, which can then respond to it.
The example used here works with the XI runtime standardized structure. When using the Web service runtime, follow the same procedure to trigger an exception on the receiver side and handle it on the sender side (indicated in the source text by the comments with a hash symbol (#)). The fault message structure is defined by the WSDL description in both cases and is found in the exception class.
Troubleshooting Example
Call at the Sender and Error Handling |
Service Called at the Receiver |
DATA: lo_mes TYPE REF TO l_sys_exc TYPE REF TO CREATE OBJECT lo_mes. TRY. CALL METHOD [...] CATCH cx_ai_system_fault * handle system
error CATCH cx_fault_1 * handle application error 1 [...] * ############################ CATCH cx_fault_n * ############################ * handle application error n CATCH cx_ai_application_fault * handle other ENDTRY. |
METHOD EXECUTE_SYNCHRONOUS. DATA: l_standard_data [...] l_additional_data_n [...] IF [Error Condition n]. l_standard_data-fault_text
= ... APPEND
l_detail_data l_additional_data_n = ... * #################################### RAISE EXCEPTION TYPE
CX_FAULT_N * #################################### ENDIF. |
...
1. If an application on the receiver side triggers an error, the ABAP proxy runtime converts the corresponding exception class to a fault message and transfers it to the sender system.
2. In the sender system, the ABAP proxy runtime interprets the fault message and triggers the exception for the consumer proxy.
3. In the sender system, the application can catch and handle the exception using a Try/Catch block. Using the super exception class CX_AI_APPLICATION_FAULT you can - in a similar way to the statement WHEN OTHERS in a CASE statement - catch all remaining application errors.