StingyJack
StingyJack

Reputation: 19469

How to report failures from RfcServerFunction methods?

I'm using the SAP .NET Connector 3.0 to receive inbound IDocs. I can get them fine most of the time, but sometimes there is a problem in receipt (disk full/DB connection down, etc), and there does not appear to be a way to report back to the sender that the receipt failed.

Throwing an exception still results in a status "3" (Good) for the IDoc in SAP.

Does anyone know how to report back to the caller that the receipt was not successful?

Example...

[RfcServerFunction(Name = "IDOC_INBOUND_ASYNCHRONOUS")]
public void ReceiveInboundIdocAsync(RfcServerContext context, IRfcFunction function)
{      
     throw new Exception("SM59 still reports status 3 for this idoc");
}

Upvotes: 1

Views: 525

Answers (1)

Lanzelot
Lanzelot

Reputation: 16595

You need to distinguish between the "tRFC status" and the "ALE status".

If you throw an exception from your server function, the tRFC status should be set to "Rolled Back", and you should be able to verify this in transaction SM58. Can you please check this?

However, that does not influence the ALE status... ALE is basically asynchronous and does not wait for the tRFC, which transports the IDoc, to finish. So the ALE status "03" only means "IDoc transferred to communication layer successfully". Whether the communication layer (the tRFC layer in this case) has actually succeeded in delivering the IDoc or is still trying, is not reported back to the IDoc monitor...

If you want to do that, you have two options:

  1. There is an ALE report that can be scheduled periodically in the SAP system: RBDMOIND. This report scans the tRFC monitor and sets all IDocs, for which the corresponding TID has finished successfully, to status "12". (The IDocs, for which the tRFC is still executing or is currently in status "Rolled Back" remain in status "03".)
  2. Your program can periodically send SYSTAT01 IDocs back to the SAP system. This IDoc can be used to update the IDoc status monitor. Just fill it with a set of IDoc DOCNUMs, some info of your "EDI subsystem" and the desired status for each DOCNUM. The following four status should be used: "11" (Error during dispatch), "12" (Dispatch ok), "13" (Retransmission ok), "23" (Error during retransmission) In order to process these SYSTAT01 IDocs, the SAP system needs to be setup accordingly: a logical system and a partner profile need to be created for your "EDI subsystem". The "Message type" in that partner profile needs to be "STATUS" and the "Process code" needs to be "STA1". An administrator can then filter the ALE monitor (WE05) for IDocs that ended up in status 11/23 and look into them manually. (And retransmit as necessary.)

Upvotes: 1

Related Questions