Share via


Enable SAP NCo library logging/tracing for Azure On-Premises Data Gateway and the SAP Connector

Issues with the SAP Connector can be tricky to troubleshoot. To facilitate the troubleshooting the more logging you can get the better. Besides the high-level error response visible in the Logic App run history details (see /en-us/azure/logic-apps/logic-apps-monitor-your-logic-apps#view-runs-and-trigger-history-for-your-logic-app), and the On-Premises Data Gateway exportable logs (see /en-us/power-bi/service-gateway-onprem-tshoot#tools-for-troubleshooting), you can further enable SAP NCo library logging/tracing.

To do this you need to edit the application configuration file Microsoft.PowerBI.EnterpriseGateway.exe.config located in the installation of the On-Premises Data Gateway, by default C:\Program Files\On-premises data gateway. Note that there are multiple application configuration files in this folder and it is important that you do the following changes specifically to the configuration file for the Microsoft.PowerBI.EnterpriseGateway.exe executable which is the executable of the On-Premises Data Gateway service. The file is by default protected for writing with administrator privileges so you need to run your text editor of choice in elevated mode. You need to add the following green section:

 <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <sectionGroup name="SAP.Middleware.Connector">
      <section name="GeneralSettings" type="SAP.Middleware.Connector.RfcGeneralConfiguration, sapnco, Version=3.0.0.42, Culture=neutral, PublicKeyToken=50436dca5c7f7d23" />
    </sectionGroup>
  </configSections>
  <SAP.Middleware.Connector>
    <GeneralSettings defaultTraceLevel="4" traceDir="C:\Temp" traceEncoding="UTF-8" traceType="PROCESS" />
  </SAP.Middleware.Connector>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
  </startup>
  <system.diagnostics>
  ...

In black are elements of the existing configuration file so you see where to insert the additional elements.

This will create log files in C:\Temp. Note that you may change the path to your preference but you do need to create this directory as well.

The trace level used in this example is the most verbose of 4. You select the level anywhere between 1 and 4. The resulting dev_nco_rfc.log file below will contain details of the trace level meaning.

After the configuration file changes are saved, you need to restart the On-Premises Data Gateway service using the gateway configurator

After you make your next call to send a message to SAP using the connector and this gateway, you should see two or more SAP NCo log files appear:

The dev_nco_rfc.log is a good place to start and will contain this for example (some data has been replaced with star characters '*'):

 

 **** Log file opened by process 4812 at 2018-03-26 10:07:01 (UTC-07:00 Pacific Daylight Time)

SAP .NET Connector 3.0 with file version 3.0.20.0 running on 64-bit .NET Framework 4.0.30319.42000
Program: C:\Program Files\On-premises data gateway\Microsoft.PowerBI.EnterpriseGateway.exe
Working directory: C:\WINDOWS\system32
Operating system: Windows 10 Enterprise 64-bit 
Processor: 12x AMD64 (or x64)
SAP release: 721, Kernel release: 721, Kernel patch level: 1011
Hostname: ****, IP address: ****, IP_v6 address:

Default trace level: RemoteFunctionCall

>> Error entry 2018-03-26 10:07:01.925 [Thread 7]
[MSHOST=*** MSSERV=**** SYSID=*** GROUP=**** USER=**** PASSWD=******** CLIENT=*** LANG=EN NAME=**** IDLE_TIMEOUT=120 POOL_IDLE_TIMEOUT=120 MAX_POOL_SIZE=100]
SAP.Middleware.Connector.RfcAbapMessageException: Inconsistent IDocs passed: Data records or control records missing.
 at SAP.Middleware.Connector.RfcConnection.ThrowRfcErrorMsg()
 at SAP.Middleware.Connector.RfcConnection.ReadBytes(Byte* buffer, Int32 count)
 at SAP.Middleware.Connector.RfcConnection.ReadRfcIDBegin(Int32& length)
 at SAP.Middleware.Connector.RfcConnection.ReadUpTo(RFCGET readState, RfcFunction function, RFCID toRid)
 at SAP.Middleware.Connector.RfcConnection.RfcReceive(RfcFunction function)
 at SAP.Middleware.Connector.RfcFunction.RfcDeserialize(RfcConnection conn, IRfcIOStream stream)
 at SAP.Middleware.Connector.RfcFunction.RfcCallReceive(RfcConnection conn, IRfcIOStream stream, RFCID rid)
 at SAP.Middleware.Connector.RfcTransaction.Commit(RfcConnection conn)
 at SAP.Middleware.Connector.RfcTransaction.Commit(RfcDestination destination)

**** Log file opened by process 10028 at 2018-03-26 10:08:45 (UTC-07:00 Pacific Daylight Time)

SAP .NET Connector 3.0 with file version 3.0.20.0 running on 64-bit .NET Framework 4.0.30319.42000
Program: C:\Program Files\On-premises data gateway\Microsoft.PowerBI.EnterpriseGateway.exe
Working directory: C:\WINDOWS\system32
Operating system: Windows 10 Enterprise 64-bit 
Processor: 12x AMD64 (or x64)
SAP release: 721, Kernel release: 721, Kernel patch level: 1011
Hostname: ****, IP address: ****, IP_v6 address:

Default trace level: RemoteFunctionCall,PublicAPI,InternalAPI,RfcData

>> Error entry 2018-03-26 10:08:45.061 [Thread 28]
SAP.Middleware.Connector.RfcCommunicationException
 at SAP.Middleware.Connector.CpicConnection.ThrowCpicErrorMsg(Int32 length, Int32 dataReceived)
 at SAP.Middleware.Connector.CpicConnection.CpicReceive(Int32 timeout)
>> Error entry 2018-03-26 10:08:45.183 [Thread 28]
[MSHOST=**** MSSERV=**** SYSID=*** GROUP=**** USER=**** PASSWD=******** CLIENT=*** LANG=EN NAME=**** IDLE_TIMEOUT=120 POOL_IDLE_TIMEOUT=120 MAX_POOL_SIZE=100]
SAP.Middleware.Connector.RfcAbapMessageException: Inconsistent IDocs passed: Data records or control records missing.
 at SAP.Middleware.Connector.RfcConnection.ThrowRfcErrorMsg()
 at SAP.Middleware.Connector.RfcConnection.ReadBytes(Byte* buffer, Int32 count)
 at SAP.Middleware.Connector.RfcConnection.ReadRfcIDBegin(Int32& length)
 at SAP.Middleware.Connector.RfcConnection.ReadUpTo(RFCGET readState, RfcFunction function, RFCID toRid)
 at SAP.Middleware.Connector.RfcConnection.RfcReceive(RfcFunction function)
 at SAP.Middleware.Connector.RfcFunction.RfcDeserialize(RfcConnection conn, IRfcIOStream stream)
 at SAP.Middleware.Connector.RfcFunction.RfcCallReceive(RfcConnection conn, IRfcIOStream stream, RFCID rid)
 at SAP.Middleware.Connector.RfcTransaction.Commit(RfcConnection conn)
 at SAP.Middleware.Connector.RfcTransaction.Commit(RfcDestination destination)

This above shows a couple of logging sessions, the first time with a trace level of 1, the second time with a trace level of 4.

The *.trc files in the same folder will contain the detailed traces, including in case of level 4 the capture of the data sent over the network. This gives you full visibility as to the communication happening between the gateway and SAP.

After you have completed your troubleshooting, you should remove the added elements from the configuration file and restart the gateway again to stop the tracing. Note that while NCo tracing is enabled there will be a significant performance impact - I observed calls taking 3 to 5 times longer than usual.

[These steps are based on the SAP .NET Connector 3.0 Programming Guide, reduce to the purpose of logging/tracing only and specifically for the On-Premises Data Gateway.]

Update and note: when contacting SAP for support, you may be requested to follow this SAP KB article 1610818. The steps above permit you this.

Comments

  • Anonymous
    June 20, 2019
    This blog has been moved off the MSDN platform. Find further content and update at https://www.linkedin.com/today/author/daviburgComments are locked as part of the blog migration, so please reach out to your customer support contact for assistance with Microsoft products and services.