Ehbit ninja's blog

Our IT ninja's blog about their professional experiences with IT technologies

SAP calling RFC hosted in BizTalk

 I’ve configured a SAP receive port in BizTalk. However when trying to enable the receive location I got some errors in the error log saying ‘ ‘saprfc.ini’ failed: ‘No such file or directory’ ‘.  Here is the full error message:

The Messaging Engine failed to add a receive location “RECEIVE MIXED ERIKS SAP” with URL “sap://CLIENT=900;LANG=EN;@a/SAPSERVER/00?GWSERV=sapgw00&ListenerDest=TRADCOMSAPDEST&ListenerGwServ=sapgw00&ListenerGwHost=” to the adapter “WCF-SAP”. Reason: “Microsoft.Adapters.SAP.RFCException: Details: ErrorCode=RFC_OK. ErrorGroup=RFC_ERROR_SYSTEM_FAILURE. SapErrorMessage=Open file ‘saprfc.ini’ failed: ‘No such file or directory’.  AdapterErrorMessage=Error accepting incoming connection. RfcAccept returned RFC_HANDLE_NULL..

Apparently this file is used in the RFC library of SAP:
“The RFC library will read the saprfc.ini file to find out the connection type and all RFC-specific parameters needed to connect to an SAP system, or to register an RFC server program at an SAP gateway and wait for RFC calls from any SAP system.”

How to solve this issue?

First of all you’ll need to create a System Variable called RFC_INI. To manage the Environment Variables you’ll need to open the system properties and select ‘Environment Variables…’, as shown below.

Then create the new system variable RFC_INI with a filepath as value, for example C:SAPINIsaprfc.ini.

Next we need to add the contents to our saprfc.ini file.  The values that I needed to provide include: 
Field Value description
DEST TRADCOMSAPDEST In this case, this is the name of the RFC Destination that our BASIS team created for us from SM59.  More details here.
TYPE R Type R is for RFC server programs or for a client program working with another external program as RFC server program which is already registered at an SAP gateway.
GWHOST SAP_HOST_NAME In my case, this is the name of the physical server that his hosting the SAP Gateway.
GWSERVER SAP_GATEWAY_NAME The name of the SAP Gateway.  A standard naming convention is: SAPGW## where ## is the system number for the SAP instance that you are working on.
PROGID TRADCOMSAPPROG This is the name of the Program ID that has also been provided by BASIS.  

When you compare the data between the Receive Location and the saprfc.ini file, you’ll see a certain symmetry between the two.  However, the values in the ini file take precedence.<br />

You’ll need a restart of the BizTalk host instance, the one defined on the SAP adapter, for the changes to take effect.
This should be all to resolve the issue.

Source: Kent Weare’s BizTalk Blog: SAP calling RFC hosted in BizTalk