cancel
Showing results for 
Search instead for 
Did you mean: 

How to test Proxy exceptions?Please help

gopalkrishna_baliga
Participant
0 Kudos

Hi Experts,

   I have a scenario where SAP R/3 system calls PI  via ABAP Proxy.

  In my SAP R/3 code, I have code to initialize proxy object and call proxy method.

  Now I want to test if my code throws any system exception. For this I have deactivated the RFC destination for PI system in my SAP R/3 system.

  But what is happening is that my R/3 proxy code is not getting system exception and program successfully executes. But message is stuck in queue (SMQ2).

  Why is that my proxy code does not get system exception?

  What is the alternative to test the same?

   IF x_prxy IS NOT INITIAL.
     TRY.
*   create proxy object
         CREATE OBJECT v_o_proxy.
       CATCH cx_ai_system_fault INTO v_o_fault.
         v_err_msg = v_o_fault->get_text( ).             "#EC NO_HANDLER
     ENDTRY.

* Set the Queue
     TRY.
         v_o_async_mess ?= v_o_proxy->get_protocol( if_wsprotocol=>async_messaging ).
         v_o_async_mess->set_serialization_context( c_queue_id ).

* Call the proxy method
         CALL METHOD v_o_proxy->proxy_method
           EXPORTING
             output = x_prxy.
*Commit the transaction
         CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
           EXPORTING
             wait = c_x.

       CATCH cx_ai_system_fault INTO v_o_fault.
         v_err_msg = v_o_fault->get_text( ).

       CATCH cx_ai_application_fault INTO v_o_app_fault.
         v_err_msg = v_o_app_fault->get_text( ).

      ENDTRY.
   ENDIF.

Thanks

Gopal

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hi Gopal,

The System exception (cx_ai_system_fault) only occurs on Outbound interface when the Integration Engine is not configured. This configuration need be done at each SAP ECC client (mandt).

But if the message are stopped on SMQ2 probably the queues aren´t activated or registered. You can do it using SXMS_QREG transaction.

Best regards,

Josieudes

former_member184681
Active Contributor
0 Kudos

Hi Gopal,

That's the nature of asynchronous communication . You have a few options here:

1. Switch to sync, that will immediately notify you about the connection error with your existing code (just a slight change because of proxy class regeneration in sync mode). Just bear in mind the disadvantages of sync processing (work processes blocked when no errors, and so on).

2. Use acknowledgements to be notified of such errors. You can extend your ABAP code with commit & retrieving the ack, or create a separate program that will evaluate the acknowledgements for multiple messages.

Regards,

Greg

gopalkrishna_baliga
Participant
0 Kudos

Hi Greg,

   You mean for Async calls cx_ai_system_fault exception is never thrown?

   Are you sure?

   What if the remote PI system is actually down? Even in that case cx_ai_system_fault exception is never thrown?

   Is there any possibility for cx_ai_application_fault exception to be thrown in Async?

   In what cases cx_ai_application_fault exception will be thrown?

Thanks

Gopal

former_member184681
Active Contributor
0 Kudos

Dear Gopal,

I wouldn't go that far with conclusions. My suggestions were rather related to that particular situation you described, I mean, when the message is put in a queue for being delivered, and stays there for a longer period of time. As far as I remember, this exception is thrown for instance when the user credentials are incorrect in the RFC destination (so when the connection to PI is successfully called, but then an error occurs).

Regards,

Greg