cancel
Showing results for 
Search instead for 
Did you mean: 

exception handling with fault message type not working

former_member474221
Participant
0 Kudos

Hi,

I have a sync proxy to proxy scenario and I have created a fault MT and specified in the outbound and Inbound service interface...

*In Inbound proxy I have the following code--*......

.....

RAISE EXCEPTION TYPE z_cx_test_fault

EXPORTING

standard = l_standard_data.

In the sender side abap code which calls the outbound proxy I have the follwing code -

.....

CATCH cx_ai_system_fault INTO lo_cx_ai_system_fault.

txt = lo_cx_ai_system_fault->get_text( ).

WRITE txt.

CATCH z_cx_test_fault INTO lo_cx_test_fault.

txt = lo_cx_standard_message_fault->get_text( ).

WRITE txt.

CATCH cx_ai_application_fault INTO lo_cx_ai_application_fault.

txt = lo_cx_ai_application_fault->get_text( ).

WRITE txt.

when i test the inbound proxy separately I get the custom fault message properly...

however when i run the proxy to proxy sync scenario and the custom exceptionz_cx_test_fault is raised inside the receiver proxy .......control goes to CATCH cx_ai_application_fault and not CATCH z_cx_test_fault .

I understand that cx_ai_application_fault is the super class of all the exception class but why does control go to its exception handling when a custom exception is raised...

Edited by: hema T on Feb 26, 2012 1:16 PM

Edited by: hema T on Feb 26, 2012 1:17 PM

Accepted Solutions (1)

Accepted Solutions (1)

former_member206439
Contributor
0 Kudos

Hi Hema,

Please check your fault message class name

You may copied the other object fault class name here.

You have to assign the faulty class assosiated to your Proxy class.

RAISE EXCEPTION TYPE z_cx_test_fault

Answers (2)

Answers (2)

former_member184681
Active Contributor
0 Kudos

Hi Hema,

You can always try downcasting the more generic exception to an object of your exception type. Try with the following code:

CATCH cx_ai_system_fault INTO lo_cx_ai_system_fault.
lo_cx_test_fault ?= lo_cx_ai_system_fault.
IF sy-subrc = 0.
   txt = lo_cx_test_fault->get_text( ).
ELSE.
   txt = lo_cx_ai_system_fault->get_text( ).
ENDIF.
WRITE txt.

I have also just spotted an error in your initial code:

CATCH z_cx_test_fault INTO lo_cx_test_fault.

txt = lo_cx_standard_message_fault ->get_text( ).

You use different error object than the one you catch the error into (bolded above).

Hope this helps,

Greg

former_member474221
Participant
0 Kudos

Hi experts,

I actually did not activate the fault class and hence the problem .....now the control is going to my custom catch block but it is not writing the custom ( fault detail /fault text message ) ....but it is only writing the text - "application error" why is that so??

CATCH z_cx_test_fault INTO lo_cx_test_fault.

txt = lo_cx_test_fault->get_text( ).

WRITE txt

former_member474221
Participant
0 Kudos

any help on this pls?

former_member184681
Active Contributor
0 Kudos

Hi Hema,

Try using the other method of the error class (GET_LONGTEXT) to get a more detailed error description.

Hope this helps,

Greg

former_member474221
Participant
0 Kudos

i tried get_longtext but it is giving blank ouput

former_member184681
Active Contributor
0 Kudos

Just to make sure: you do have a mapping of the error structure from your receiver proxy, to the error structure of the sender proxy in PI, don't you?

former_member474221
Participant
0 Kudos

yes i do have a fault message mapping specified in the OM

sudarshan_b
Participant
0 Kudos

Hello Hema,

I have the similar issue of not getting the fault in my custom class. I am still struggling for the resolution.

However, I do have answer for you since you are now getting the fault in your custom fault class. In you custom fault class 'Attributes' you should notice a table called 'STANDARD'. The actual error message from the proxy is returned in this table. Read this table and you should get the actual error message. GET_TEXT( ) or GET_LONGTEXT( ) will not work here.

Do let me know how you resolved the custom fault class issue

Thank you.

Sud..

former_member184681
Active Contributor
0 Kudos

Hi Hema,

Try changing the sequence of the CATCH blocks, so that the block for your custom z_cx_test_fault exception was before the standard one. I think this might solve your problem. Most probably the sequence does matter when catching the exception, and the reason for your strange behaviour is that SAP only goes into the first CATCH block on the list that matches the type of the error raised (not ALL of the matching CATCH blocks, which is what you expect I think).

Hope this helps,

Greg

former_member474221
Participant
0 Kudos

Hi

I tried changing the sequence also but it did not work...

I can see an appropriate response coming from the receiver in SXMB_MONI of PI...this response has the "fault response "

"fault detail" data that I want.....however when the control goes to the sender why does it go to CATCH CX_AI_APPLICATION_FAULT and not not my CATCH z_cx_test_fault .

My observation - If I change the scenario to SOAP to Proxy sync..then the sender SOAP client gets the appropriate custom fault message back.

Edited by: hema T on Feb 27, 2012 1:17 PM

Edited by: hema T on Feb 27, 2012 1:17 PM

former_member474221
Participant
0 Kudos

Any help on this?

Former Member
0 Kudos

Fault messages comes under Application Error category, hence all Fault messages will fall in CATCH CX_AI_APPLICATION_FAULT

former_member474221
Participant
0 Kudos

Hi Sourabh,

If all the fault MT come under CX_AI_APPLICATION FAULT then why do people use fault MT.....why do not they directly RAISE CX_AI_APPLICATION_FAULT..

Hi Naresh,

I have used the right fault MT class...still there is a problem

Edited by: hema T on Feb 27, 2012 4:43 PM

former_member206439
Contributor
0 Kudos

I got the same issue once.

I copied the logic of the one interface to another and forgot to change the Fault message class name.

Once I fixe dthat I resolved this issue.