cancel
Showing results for 
Search instead for 
Did you mean: 

Raising Exception-Proxy

former_member188791
Participant
0 Kudos

Hi Group,

Can any body suggest how to raise exception in ABAP proxy with custom message and I want to fail message in SXMB_MONI .

-Rajiv

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Rajiv,

you define an exception type and raise this exception in the server proxy with the respective exception message. Find example coding here:

Reporting and Handling Errors - Enabling Application-to-Application Processes - SAP Library

Regards,

Jörg

former_member188791
Participant
0 Kudos

Hi Jorg,

Thank you for you message, according to that link I need to define fault message type/Data type in ESR then only I can raise, without defining fault message type is there any way I can raise exception.

My simple condition is based on sy-subrc <>0 I need to raise exception and send message in to Error

Former Member
0 Kudos

Hello Rajiv,

you can raise an exception, but it will result in a red flag and (probably) won't display your fault message. Better do it as specified in the help page. Define the exception type and in your code make the sy-subrc check and raise the exception. This will result in a clean application fault and you'll see an error message. Better monitoring, clearer status and almost no additional effort.

Regards,

Jörg

engswee
Active Contributor
0 Kudos

Hi Rajiv

In addition to the code provided by Jorg's link above, you can also use the RAISE static method in class CL_PROXY_FAULT. This is useful if you already have error messages in the common BAPI return table.


  cl_proxy_fault=>raise( exception_class_name = 'ZCL_YOUR_EXCEPTION_CLASS'

                                          bapireturn_tab                 = t_bapiret2 ).

Do note that as mentioned by Jorg, you still need to define the fault message, which then causes your error to appear as an "Application Error" in the monitor. ZCL_YOUR_EXCEPTION_CLASS is subclass of CX_AI_APPLICATION_FAULT, and would be automatically generated from the fault message when you generate your proxy.


Rgds

Eng Swee