Solution Development using SAP .NET Connector in Visual Studio .NET


The document basically goes through a brief description of the solution of an application we had worked on. The part explained in this article has been successfully executed and tested.

This document mainly goes through some important points which would help the programmer to successfully implement an application using SAP & ASP.NET. C# has been used as a programming language for an application to interface connection with SAP and consume its function.


The SAP .NET Connector tool enables .NET portal components to connect to SAP systems. It allows portal component developers to call the functions of SAP systems. These functions are called RFCs (Remote Function Call), or BAPIs (Business Application Program Interface). These functions are written in ABAP and are an integral part of SAP systems, but a customer can add his own functions, using ABAP development tool.

The SAP .Net Connector 2.0 is especially designed for .NET developers working inside VS2003. It allows the developer the means to easily create SAP Proxies to the required functions (C# or VB.NET), and later integrate these proxies to his project. These proxies connect to the SAP system and call the RFC functions using SAP RFC protocol or SOAP. This software can be downloaded from SAP site.

After downloading, install the software.

Initially it has to start with the installation of the SAP .Net Connector 2.0 on the system.

After installation, open the Visual Studio 2003 and add a new SAP application server. Follow the steps listed below for adding the new SAP application server:

  1. Open Server Explorer.
  2. Expand SAP and right click on application servers.
  3. Click on "Add Application Server" and following dialog box will be opened.
  4. Change the destination type to Custom Login Settings and then enter the username, client, password, AppServerHost.


On clicking of OK button, the SAP application server will be added in the server explorer as follows.

Expand the tab to see the SAP functions:



Then, we can use the RFCs (Remote Function Call), or BAPIs (Business Application Program Interface) in Visual Studio 2003.

For consuming RFCs and BAPIs in Visual Studio 2003, follow the steps below:

Step 1
  1. Open Visual Studio 2003
  2. Create New Project and Select Class Library and give appropriate name to it.


Step 2

Then the reference to the SAP Connector needs to be added.
  1. Right Click on Project and select Add References.
  2. Click on .Net tab and add the two references, SAP.Connector.dll and SAP.Connector.Rfc as follows:


Step 3

After the creation of class library project, we will need to create a SAP Connector Proxy item as shown below.

Right Click the Project and Click on Add New Item
  1. Select SAP Connector Proxy
  2. Give appropriate name for the file. (Extension of the file will be sapwsdl)


Step 4

Open the sapwsdl file in Design view. Add the functions from the server explorers by dragging and dropping the functions from server explorer as follows:



After dragging and dropping the functions from the server explorer, the SAPProxy.sapwsdl file will look like following:

  1. Declare an object for the SAPProxy.sapwsdl as follows and create a property for it also:

    private SAPProxy proxy
    public SAPProxy Proxy
    get { return proxy; }
    set { proxy = value; }
  2. Get the connection string from the web.config as follows:

    connectionString = ConfigurationSettings.AppSettings["ConnectionString"];
  3. Create an instance of SAPProxy.sapwsdl as follows:
    proxy = new SAPProxy(connectionString);
  4. Consume the function as follows:

    Proxy.function(parameter names);
  5. You can catch RFC specific exceptions using the RfcException class.
  6. The proxy instance can be destroyed as the following:

    proxy.Connection = null;

All the functions pointed out are case-sensitive and are to be used in proper order.

The above mentioned code lines are used in our solution which are successfully tested.


The document provides brief information regarding the connection procedure of .NET framework with SAP and how to consume SAP functions. Small code lines give an idea to the reader how to get started with the process. More importantly the description will help the reader not just to code but to understand the classes, components and the methods provided.

Up Next
    Ebook Download
    View all
    View all