cancel
Showing results for 
Search instead for 
Did you mean: 

Catch an error in inbound ABAP Proxy

Marçal_Oliveras
Active Contributor
0 Kudos

Hi,

I'm using an ABAP Proxy to file->PI->ECC(proxy) scenario and I found an error in my sxi_monitor on ECC side:

<SAP:Stack>Error during proxy processing An exception with the type CX_SY_REF_IS_INITIAL occurred, but was neither handled locally, nor declared in a RAISING clause</SAP:Stack>

I actually solved the error, but I still don't know how to pass to the MONI the message error catching the exception instead of that "standard" error that y pasted.

How can I get the exception error and then RAISE it to the MONI?

Edited by: Marshal on Jun 9, 2009 12:37 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member181962
Active Contributor
0 Kudos
Marçal_Oliveras
Active Contributor
0 Kudos

Thanks Ravi, the article it's interesting and helped me to understand some things.

I finally solved the problem but I needed more than the article so I give you "very helpful answer"

Edited by: Marshal on Jun 9, 2009 4:05 PM

aditya_nawathe
Explorer
0 Kudos

Marshal,

Could you detail how you solved the problem? I am curious because I am facing a similar issue.

Others may also benefit.

Aditya

Marçal_Oliveras
Active Contributor
0 Kudos

Ok, I'm talking about PI 7.1, I'm not sure if it's the same for older versions:

1 - Create a Fault Message Type (with standard error data types that PI generates automatically when you create the Fault MT) and add it to your inbound Service Interface (or Message Interface in previous PI versions).

2 - Regenerate the proxy.

3 - Now in the proxy class method related to your SI there is an exception you have to possible kind of errors to catch, the 1st one is a short dump than you can catch with a TRY. CATCH. ENDTRY structure, the 2nd one is a situation that isn't a dump but you want the proxy to return an error.

3.1 - Catch Short dump code:


DATA:  lo_cx_root TYPE REF TO CX_ROOT,
             l_pi_fault_data TYPE ZPI_EXCHANGE_FAULT_DATA. "Exception message

TRY.

***********YOUR PROXY CODE

CATCH cx_root INTO lo_cx_root.

*     GET ERROR TEXT
      lo_cx_root->if_message~get_longtext(
        RECEIVING result = l_pi_fault_data-fault_text ).

*    GENERATE ERROR THAT YOU WILL SEE ON SXI_MONITOR (IN ECC!!)
      RAISE EXCEPTION TYPE "YOUR_EXEPCTION_MESSAGE_TYPE"
        EXPORTING standard = l_pi_fault_data.


ENDTRY.

3.2 Raise an error when you found an error situation for example an error message after BAPI calll:



   DATA: lt_return TYPE STANDARD TABLE OF bapiret2.

*  Call any BAPI function....always return bapiret2 table with messages
   CALL FUNCTION 'BAPI_XXXXX'
   TABLES lt_retun.

*  Look for an Error message
    READ TABLE lt_return INTO lwa_return WITH KEY type = 'E'.
    IF sy-subrc = 0.
      CALL METHOD cl_proxy_fault=>raise
        EXPORTING
          exception_class_name   = 'YOUR_EXCEPTION_MESSAGE_TYPE'
          bapireturn_tab         = lt_return.
    ENDIF.

I hope it helps

aditya_nawathe
Explorer
0 Kudos

Thanks for your info.

In the mean time I found another article and decided to give that method a try. Here is the link:

/people/shabarish.vijayakumar/blog/2006/11/02/fault-message-types--a-demo-part-1

Marçal_Oliveras
Active Contributor
0 Kudos

Nice blog Aditya, what a pity I didn't find it before!

It's the same that I've explained to you but obviously much better and with images