How to handle CX_AI_SYSTEM_FAULT in RFC

Author: name as link to Business Card
Submitted: <date>
Related Links:

Description

Courtesy of OLE from the above thread.
This is very useful when calling a Client Proxy.
The SAP help isn't very clear on how to handle system exceptions in an RFC.
I was getting the warning "The exception CX_AI_SYSTEM_FAULT is neither caught nor is declared in the RASING clause of <function>"
when I checked the function in SE37.

data: lo_system_ex type ref to cx_ai_system_fault,
lo_app_ex type ref to cx_ai_application_fault,
l_sys_exc TYPE REF TO cx_ai_system_fault,
l_app_exc TYPE REF TO cx_ai_application_fault,
l_exception_msg type string.
 
 
try.
create object l_wsproxy.
 
try.
call method l_wsproxy->execute_synchronous
exporting
output = ****
importing
input = ****.
catch cx_ai_system_fault into l_sys_exc.
catch cx_ai_application_fault into l_app_exc.
endtry.
 
catch cx_ai_system_fault into l_sys_exc.
endtry.
l_exception_msg = l_sys_exc->get_text( ).
write l_exception_msg.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.