cancel
Showing results for 
Search instead for 
Did you mean: 

How to fail a synchronous message in MONI?

Former Member
0 Kudos

Hi, all

I am trying to fail a synchronous message in MONI within the proxy code. Here is how my interface looks like:

Here is what I tried in the proxy code:

  if lv_resp-LVBAL_RESP_SAP_MT-EMPLID = '0'.

    standard_exception-FAULT_TEXT = 'The interface failed.'.

    standard_exception-fault_url = 'http://rcmp.com'.

    exception_detail-url = 'http//rcmp.com'.

    exception_detail-SEVERITY = 'error'.

    exception_detail-id = '02'.

    exception_detail-TEXT = 'The interface failed.'.

    append exception_detail to standard_exception-FAULT_DETAIL.

    raise exception type /RCMP/CX_LVBAL_FAULT

      exporting

        STANDARD = standard_exception.

  endif.

The code above does cause an exception in ST22, but the sync message did not fail in MONI. Can you please advise?

Thanks,

Jonathan.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi, Raghu

If I fail the message in the mapping, how do you pass the mapping error back to the business system(ECC)? I did try to search in the forum but came up empty.

Thanks,

Jonathan.

engswee
Active Contributor
0 Kudos

Hi Jonathan

For outbound proxy based interfaces, you cannot force the message to an application error state from the calling program - therefore meaning it's not possible to set the SXMB_MONI message to error from the calling program.

Raising application errors are only applicable in a receiver/target system, therefore this can be done in an inbound proxy program.

For sender systems, you can only CATCH application errors that were raised in the target. In your case, the target responded fine, it's just that some value in the response do not meet your specific business requirement. From an interface perspective and MONI perspective, there were no application errors in the target.

Instead you need to handle this exception in your calling program, if it is an interactive program then return a message to the user. If it is a background program, either log it somewhere or raise an alert email.

Rgds

Eng Swee

Former Member
0 Kudos

Eng Swee, thank you for the detailed explanation. I guess we would have to use something like SLG1 to track the data issue coming from the interface. We could put an error message to the user. But we also need to track if there is a problem happening since the user may not report it.

Former Member
0 Kudos

Hi, all

Anyone else has idea? Your help is much appreciated.

Thanks,

Jonathan.

RaghuVamseedhar
Active Contributor
0 Kudos

You can write a UDF (Java function) in response message mapping in SAP PI. To fail a message in Moni of SAP PI.

Sample code


if (EMPLID == 0){

                throw new RuntimeException("Employee id is zero");

            }else{

                return EMPLID;

            }

Former Member
0 Kudos

Hi, Raghu

Thanks for your input. Our PI system is java stack only. But you are right that we could fail the PI message within the mapping. However, the business users want to fail it in MONI of ECC as a business requirement. The reason is that they have their business logic in ECC to find out if a message should be successful or fail based on certain business condition on the data returned in the interface.

I am trying to see what is the possibility. Theoretically, we can also code the business logic as a BAPI and call it within the mapping. However, they may not like it.

Regards

Jonathan.


che_eky
Active Contributor
0 Kudos

What you could do is build an interface which is used solely for raising alerts. When your sync scenario fails in ECC you call the Alerts interface passing it any useful information which could be used to trace the actual interface that failed and why.

Take a look at this blog from Michal on how to set this up:

Che

Former Member
0 Kudos

Hi Che

Thanks. But the link doesn't work for us. The interface is synchronous and the abap program needs to capture the reason of the mapping error to make a business decision. Note that it is an interactive WDA program that calls the interface. If we are going to fail the message in the PI mapping, we need to somehow pass the error message back to the WDA.

I cannot think of a way to do this. Please advise if you have any idea.

Thanks,

Jonathan.


che_eky
Active Contributor
0 Kudos

The link works for me.

I don't know how you can fail the actual sync message. What the solution offers is the ability to raise an alert from Inside the business condition but outside sproxy. You maybe better off trying to log the error on the ABAP stack.

Not sure what you mean by "If we are going to fail the message in the PI mapping".

Che

Former Member
0 Kudos

Hi, Che

What I meant is that instead of checking the data in the WDA in ECC, I put the logic in a BAPI and call it in the mapping. If an error condition is met, I will throw an exception with a UDF and fail the sync message directly in PI. This is what Raghu suggested.

However, I am not sure how to catch the exception text in the WDA. Eg:

     catch cx_ai_system_fault INTO lo_sys_exception.
      exception_text = lo_sys_exception->GET_TEXT( ).

The exception_text is something like 'PARSING.GENERAL'. What I don't know is how to capture the error text thrown from my UDF in the mapping.

Thanks,

Jonathan.

che_eky
Active Contributor
0 Kudos

Good point, I am not sure how you would capture the exception in the WDA.

Take a look at these threads, they are not recent though:

Also check the help for statement StreamTransformationException("your message");

Sorry I cannot be of any further assistance.

Che

Former Member
0 Kudos

Hi, Che

Thanks for the links but they don't really apply to us. They are talking about raising exceptions in PI. But the question is how to capture the exception text in the business system(ECC).

Thanks

Jonathan.


Former Member
0 Kudos

By the way, the code above is written in a normal abap program, not within the sproxy. The interface is initiated from ECC <-> PI <-> SOAP. I already tried to change the outbound proxy within sproxy and it is telling me "You cannot edit proxy/MDRS objects".

I have done a look of searches but all docs I found are for async interfaces.

Thanks,

Jonathan.

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Are u raising an exception in the SPROXY method for your business condition?

Former Member
0 Kudos

Hi, Baskar.

Inside a business condition but outside sproxy. The interface is initiated from a portal WDA program. Based on a condition of the data returned from the interface(outbound proxy), I am trying to fail the sync message in MONI. Is this possible?

This is a bit different from asynch interfaces when we can raise the exception directly inside the sproxy abap code. The benefit is monitoring as we can track when something fails in the sync interface in MONI. Surely we can code the WDA to log the failed message in SLG1. But I am hoping we can make good use of sxmb_moni.

Thanks,

Jonathan.