This article explains that how we can connect third party applications with SAP using .NET connector (NCO). This is crucial in today’s world as system landscape consist of heterogeneous applications. These third party applications are as crucial as SAP. Examples of this are eCommerce applications. You may need prices, taxes, minimum order quantity and other system validations to come from SAP. Another example for integration is CRM application where you may want to enable sales representatives to submit accurate quote to the end customer.

Integrating applications eliminate manual steps and improve efficiency. Look at below video on how we have integrated order to cash cycle from an eCommerce application named Magento with SAP.

Now lets get to know how we can push data from and to SAP in a real time manner. For this we have taken an example to showcase how we can pull information using remote function call.  However before we go on to that lets understand a few basic things first.

Technology Stack

SAP .Net connector connects Microsoft .Net application and SAP systems by using the SAP RFC. This is called as NCo. We can connect by using the Java, which is called the JCO. We will go with the .Net connector. Before moving forward these are prerequisites to understanding the process easily. Must have basic knowledge of development using C# and ASP.Net For developing the connector you will require the following Dll’s. There are 32 bit (x86) and 64-bit versions are available.

  • sapnco.dll
  • sapnco_utils.dll

SAP Integration Services by Veon Contact Banner

Where to get NCO 3.0

The SAP .NET Connector 3.0.20 can be downloaded from the SAP Service Marketplace.

  • Navigate to SAP Connector for Microsoft .NET
  • Download SAP Connector for Microsoft .NET Version 3.0

This will require a username and password. If you are a .net developer, probably you do not have it. Ask Your SAP Basis team to download and get it for you because they have the access to SAP marketplace.

Key fields

Given below are the key fields you will need to generate a remote session with SAP. These are available with the SAP Basis team or the system administrators.


Getting Started – Launch the Visual Studio

So now that we have all the credentials and requirements fulfilled, lets get started with the development of a sample integration program.

  • Create a web application SAP_NCO_ConnectionDemo and add reference of sapnco.dll and sapnco_utils.dll
  • Add a new class called RfcConfig that you will use to read the configuration(created this class in Utils folder)
  • Add SAP.Middleware.Connector namespace to this class which comes from the dll’s that you just added as a reference in your project
To read the destination, SAP Connector provides an interface called IDestinationConfiguration. This interface provides a method called GetParameters. Inherit IDestinationConfiguration to your class and right click on it to implement an interface. In the below, we have made some changes after the implementation of the interface.GetParameters method returns RfcConfigParameters which is a class in SAP Connector DLL. Update the code to read the config values.Now we are able to get the configuration, next step is to test the connection. It can be called in a class where you would connect to the SAP. But the SAP connector has a method called RegisterDestinationConfiguration. All the destinations that have been needed to be registered first before connecting to the SAP.

You can do this step just before connecting to the SAP. For this Create one more class as RfcClient. Register the SAP configuration using the RegisterDestinationConfiguration. If the destination comes as null handle the exceptions.

Now define a method to test the connection. In this method, we are sending a request to Standard SAP bapi request.

In the testconnection method, we have called the PullRequestTo SAPrfc function which will create an rfc request packet, sends the request to the SAP and returns the SAP response. This is shown in below.

Create an instance of RFCRepository which has all the functions into it.

Using this repository call the method CreateFunction and provide the RFC name of SAP that you need to call. You need to make sure that the exact function name is available in SAP.

In PrepareXMLrfcfrom method we have converted the Rfc request to XML format.