cancel
Showing results for 
Search instead for 
Did you mean: 

RFC/BAPI Exception in PI 7.0

Former Member
0 Kudos
224

Hi there,

  currently we have a scenario where the message come from middleware and pass through PI to POSDM system via RFC.

my target structue is an BAPI .

  for some reason if the BAPI execution gets failed on POSDM system then the BAPI should return some exception back to PI system,

  can this be achived only by just adding the fault message type (ExchangeFaultData) in Inbound MI, whill this setting sufficient to get any error info from BAPI to PI via rfc, or do we need to do some exception mapping? if so can some one explain/

.

Accepted Solutions (0)

Answers (2)

Answers (2)

turmoll
Active Contributor
0 Kudos

No it can't be achieved 'just by adding fault' as long as you want to make use as target interface BAPI since BAPI does not allow exceptions.

/Jakub

.

Former Member
0 Kudos

Jakub,

Normally if we do not want hardcoded exceptions then we use the export parameters of BAPIRETURN in BAPI. They was visible as the checked flag in SXMB_MONI.

But there are certain requirements of the client where they strictly want exception and need to raise a red flag and not the checked flag in MONI. That is where we use exceptions and not export parameters.

Former Member
0 Kudos

Thanks Jakub, I just defined the fault msg type in inbound MI ( assigning BAPI structure as XSD) .

when tested and the BAPI execution failes I'm not getting any error msg in MONI.

can you pls break down with steps to understand pls.

turmoll
Active Contributor
0 Kudos

BAPI does not return exception otherwise it's not BAPI.

Sethuraman makes use BAPI as target interface so exception is not a solution. Furthermore, I assume that Sethuraman makes use standard SAP POSDM interface then modification (by adding exception) is not too smart, isn't it ?

/Jakub

turmoll
Active Contributor
0 Kudos

Sethuraman,


you will not get any exception propagated to SAP PI unless you change/modify BAPI on target system. If it's standard SAP BAPI. I do not recommend.


/Jakub

Former Member
0 Kudos

Hi Sethuraman,

You will only get those exceptions in the PI which are mapped/created in the BAPI under the exceptions tab. If any of the exception is not listed under the exception tab of BAPI, the will not be get back to PI as a fault message.

So do correct exception mapping for all the exceptions that you want to raise in the BAPI with the help of ABAP guys if it a custom BAPI.

If you are using a standard one, call the same into your custom BAPI and then raise exceptions.

Former Member
0 Kudos

Thanks Monika,

There is one exception created in the exception tab.

Should I do any mapping to get this exception to PI? pls advice or pls let me know how to achive this?

turmoll
Active Contributor
0 Kudos

Monika,


RFM that pretends to be a BAPI has to follow a few strict rules. Some of them are :

- BAPI is called always synchronously and are always successful i.e. errors are returned in EXPORT parameter (so  no matter if BAPI created some document/posting or not is successful!)

- it does not return exceptions!

so you should not advise to make use exceptions ...  otherwise it will not be a BAPI


The one of possible solution is to wrap BAPI either using proxy or RFM and then you can propagate exceptions to SAP PI.


/Jakub





iaki_vila
Active Contributor
0 Kudos

Hi Tamilarsan,

Yes, you should to map the exception as well.

Personally, i don't like to work with the exception tab, i prefer to control the functional errors in the RFC with an structure type bapireturn, in the RFC export parameters. Obviously, i need sometimes to wrap the standard function with a Z one.

Regards.

Former Member
0 Kudos

Hi Sethuraman,

First please let me know which output of BAPI you want to use. Whether you are getting something in the exporting parameters like in standard BAPI's we get BAPIRETURN or you have certain hardcoded exceptions i.e. if this is the issue raise this or if that is the issue raise that.

In the first case, no need to use exceptions. Just map the exporting parameters of your BAPI with the Output/Response structure.

In the second case, make a separate message mapping apart from request and response message mapping. In this exception message mapping map the exception parameters of BAPI (source) with the exchange Fault data MT (target). Map the name parameter of BAPI with the fault text of the target MT. Then in operation mapping, you will get three tabs- request, response and fault. Assign the message mapping accordingly.

Former Member
0 Kudos

Hi,

Yes I'm using a standard BAPI and assigned the hardcode exception modified by a BADI.

possibly I'll try to follow the option 2 provided by monika, since I used the std bapi , I'll try then.

Former Member
0 Kudos

I'm in version 7.0 I have done MM with BAPI fault structure(not the hardcoded exception) with the fault msg type structure and added to IM, will just this populate the exception or  do we need to add anything on config side?

This is the exception structue.

Former Member
0 Kudos

This might work fine. Please go ahead with the ID configuration and revert after testing in case you get any issues.

Also in SXMB_MONI, you will get these types of flags in case the exception is raised.

turmoll
Active Contributor
0 Kudos

Hello,

I assume you have modified SAP standard BAPI by adding exception NB. that is not BAPI any more.

The MM an IM you did is ok, however, you need to modify FM to 'throw' exception.

I still encourage you to either make use proxy or RFM that wrap standard SAP BAPI instead the solution you went for ... in future during upgrade it might stop working ...

/Jakub Turmiński

Former Member
0 Kudos

Hi Sethuraman,

Jakub is correct that you should not modify standard BAPI (i.e should not add exceptions in it). I have suggested in the previous posts that if you want to add exceptions, please create a remote function module and then call the standard BAPI in it.

It will work fine and will not event create problems during upgrade.