You might have observed that in outbound scenarios, for example while calling an RFC, if something goes wrong, an exception is thrown to the user. This does not happen in the same manner for inbound scenarios, for example when receiving an RFC or an iDoc. Let us see what this difference is.
When an outbound call is made to SAP, the (simplified) scenario looks like this:
User code issues a request, and the response is sent by SAP. Any exceptions that occur in SAP or the adapter are propagated to the user. However, the inbound scenario looks like this:
The User code sends response to SAP’s request. All exceptions are thrown to SAP except the ones that occur while the user code reads data – after all SAP is the party that issues the request in this case. This is the reason why we don’t see exceptions when something goes wrong in inbound scenarios.
Now, is there a way to see the exceptions being passed to SAP?
Yes! Tracing is the answer. We recommend that you enable Error and Warning level tracing for adapters. The exceptions that are thrown to SAP are also traced and will find a place in the trace log if tracing is enabled. However, trace logs tend to grow huge – and picking out new entries manually can be daunting. Using the System.Diagnostics.EventLogTraceListner class instead of the XMLWriterTraceListener class, you can redirect your traces to the event viewer – the one stop solution to monitor your applications and services.
If you’re working with the WCF service model, add the following to the configuration section of your app.config file. If you’re working with Biztalk applications, add the following to the configuration section of your BizTalk configuration file, BTSNTvc.exe.config which is present under <system drive>:\Program Files\Microsoft BizTalk Server 2006:
<source name=“Microsoft.ServiceModel.Channels“ switchValue=“Warning“>
<add name=“eventlog“ />
<source name=“Microsoft.Adapters.SAP“ switchValue=“Warning“>
<add name=“eventlog“ />
<add name=“eventlog“ type=“System.Diagnostics.EventLogTraceListener“ initializeData=“APPLICATION_NAME“/>
<trace autoflush=“false“ />
This will enable Warning level tracing (Errors + Warnings). Replace APPLICATION_NAME with the name of your application as you want it to appear in the event viewer. Now you can see the errors and warnings – even the ones that were thrown to SAP – in the event viewer. Neat!