Click here to Skip to main content
11,924,800 members (53,466 online)
Click here to Skip to main content
Add your own
alternative version


35 bookmarked

SAP connector for Microsoft.NET

, 18 Apr 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Connect SAP with .NET


The article describes with the help of a web application how SAP can be integrated with .NET using SAP.NET connector.


The SAP .NET Connector is a programming environment inside of Visual Studio .NET that enables communication between the Microsoft .NET platform and SAP Systems. It supports SAP Remote Function Calls (RFC) and Web services, and allows you to write various Applications, for example, Web form, Windows form, and console applications within Microsoft Visual Studio .NET. You can use all Common Language Runtime (CLR) programming languages such as Visual Basic .NET, C#, or Managed C++.

At runtime, the SAP proxies communicate with the SAP system by either the SAP RFC protocol (librfc32.dll) or via SOAP. SAP systems up to release 46D do not have SOAP support while SAP systems starting from 6.20 can use either SOAP or RFC. Non-SAP systems can be connected using SOAP. The SAP client solution is derived from the Microsoft SoapHttpClientProtocol class. The SoapHttpClientProtocol class is part of the Microsoft .NET framework and specifies the class proxies derive from when using SOAP.

This base class for SAP clients provides .NET developers with a familiar way to use SAP functionality.


Development System

• Windows 2000 or Windows XP

• Microsoft Visual Studio .NET

• Java Runtime Environment (JRE)

You can download JRE version 1.3 or later from

• SAP.Net.Setup.msi

Execute this file.

Deployment System

• Windows 2000 or Windows XP

• Microsoft .NET Framework

Download this file from

• LIBRFC32.dll, Release 6.20 or higher

• SAP.NET.Connector.dll

Create an ASP.NET Web Application using SAP Connector.

The example uses the function module RFC_CUSTOMER_GET, which requires that customer

data exist in the target SAP System.


1. Open Microsoft Visual Studio .NET.

2. Create a new C# Web form project:

Choose New New Project Visual C# Projects ASP .NET Web Application.

You can also create a project in any other common programming language

for .NET, for example, in Visual Basic .NET. In this case, you must add the

SAP connector for Microsoft .NET proxy classes as a separate project in the

Microsoft Visual Studio .NET solution.

3. Rename the form Webform1.aspx to Default.aspx.

4. Add Web controls to your Web form.

In our example, we add a TextBox, a Button and a DataGrid control.

5. Add proxy classes to connect the Web applications to your SAP server.

a. In the Solution Explorer, right-click on your project.

b. Choose Add Add new item.

c. Select Web Project Items SAP Connector Class and choose Open.

The Wizard for SAP connector for Microsoft .NET opens.

d. Decide from where you want to generate the proxy classes.

You can create proxies from:

− Web Services Description Language (WSDL) files that originate in an SAP

interface repository (IFR)

− An SAP server

− Standard WSDL files

e. Select the client proxy object type and select beautify names option.

f. Select the Remote Function Modules (RFM) you want to use in your proxy object.

You can use search filters to look for the Remote Function Modules. In the example,

enter the search argument RFC_CUST* in Name-Filter and select


g. Add the modules to your proxy object and choose next.

The proxy classes for the referenced table and structure types are automatically

created and added to the project.

6. Build the solution with Build Build Solution.

7. Create an SAPLogin page to support user name and password authentication

a. In the Solution Explorer, right-click on your project.

b. Choose Add Add New item.

c. Select Web Project Items SAP Login Form

Leave the name as SAPLogin1.aspx.

8. Set the system connection information in the destination object of the SAPLogin1.aspx page:

a. In the Solution Explorer window find the item SAPLogin1.aspx and double-click on it to bring it up in the designer.

b. Look for the component destination1 on the bottom of the form.

c. Click on the destination component and set the properties for connecting to your SAP

system (for example AppServerHost and SystemNumber). The other properties like client, Password and username will be set from the login page .

9. Data bind the data grid to BRFCKNA1Table: BRFCKNA1Table is the parameter of RFC_CUSTOMER_GET that contains the list of customers.

a. Select SAP Table Wizard from the SAP proxy toolbox and Drag&Drop it to your working area. In the dialog box, select BRFCKNA1Table.

b. Select the data grid, and under Properties change DataSource to BRFCKNA1Table using the drop down list.

c. Customize the list of columns displayed on the data grid by modifying the Columns collection property.

10. On the default.aspx page, double-click the Button control you added earlier to create an event handler for the control.

11. Add the connect code to your project:

a. Select Connect code from the SAP proxy toolbox.

b. Drag&Drop it in the source code of your event handler.

A fragment of sample code is then inserted. It connects to the SAP server using the authorization settings from the Proxy Wizard. Normally, you must change these settings.

The code should look something like this


//private void btnSearch_Click(object sender, System.EventArgs e)


// Declare parameters here

//SAPProxy1 <code>proxy = new SAPProxy1();



//proxy.Connection =


// Call methods here

//proxy.Rfc_Customer_Get("", txtCust.Text, ref brfcknA1Table1);

// Now update Data Bindings. On WinForms this will be automatic, on //

//WebForms call the following line



//catch(Exception ex)


// If SAPLoginProvider.GetSAPConnection(this) cannot get a connection,

// we might get an error.

// Normally this can be ignored as it will automatically will force a //



12. Build and run the application. The browser window opens and you are redirected to your SAPLogin1.aspx login page.

13. Enter connection data (for example user, password and client). If you select Save this login information will be stored as an encrypted cookie on your computer and will provide an alternative single sign-on capability the next time you wish to access the site. If you do not select Save, the login information will still be saved in the ASP .NET session state but will be lost once the browser is closed.

14. Enter a search argument, for example A* in the TextBox field and choose Search.

Your application connects to the SAP System and displays the requested data in the DataGrid.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ved murti
Web Developer
India India
I am currently working in a product developement and outsourcing company ,PROTEANS SOFTWARE SOLUTIONS LTD. as a Sr. software developer. The company is based in Bangalore and is a global leader in product outsourcing.We are working on Microsoft .NET technologies.

You may also be interested in...

Comments and Discussions

GeneralUsing SAP Connector with Visual Studio 2005 Pin
RameshwerE27-Apr-09 2:51
memberRameshwerE27-Apr-09 2:51 
GeneralRe: Using SAP Connector with Visual Studio 2005 Pin
MartinSwart28-Apr-09 22:12
memberMartinSwart28-Apr-09 22:12 
GeneralRe: Using SAP Connector with Visual Studio 2005 Pin
Zhixuen11-Aug-09 17:01
memberZhixuen11-Aug-09 17:01 
GeneralRe: Using SAP Connector with Visual Studio 2005 Pin
srinivasanrajeshkumar29-Mar-10 1:21
membersrinivasanrajeshkumar29-Mar-10 1:21 
GeneralRe: Using SAP Connector with Visual Studio 2005 Pin
peterklausen16-Oct-09 14:06
memberpeterklausen16-Oct-09 14:06 
GeneralRe: Using SAP Connector with Visual Studio 2005 Pin
peterklausen21-Feb-10 14:24
memberpeterklausen21-Feb-10 14:24 
GeneralPushing Data into SAP through .Net application Pin
Sunil_Pawar27-Nov-08 3:03
memberSunil_Pawar27-Nov-08 3:03 
GeneralThank You Very Much Pin
biggolo_o8-Oct-08 18:44
memberbiggolo_o8-Oct-08 18:44 
QuestionUsing :NET Connector on a 64 bit Windows Server 2003 Pin
fibula15-Apr-08 2:47
memberfibula15-Apr-08 2:47 
AnswerRe: Using :NET Connector on a 64 bit Windows Server 2003 Pin
fibula4-Feb-10 8:35
memberfibula4-Feb-10 8:35 
GeneralDataGrid Only shows the column names [modified] Pin
Sunil_Pawar25-Oct-07 20:15
memberSunil_Pawar25-Oct-07 20:15 
QuestionCalling VB Functions/Dlls in ABAP Programming Pin
amarsp18-Oct-07 4:11
memberamarsp18-Oct-07 4:11 
GeneralPocket PC 2002 and .NET Connector Pin
Isidoro!3-May-07 2:46
memberIsidoro!3-May-07 2:46 
AnswerRe: Pocket PC 2002 and .NET Connector Pin
ved murti3-May-07 3:11
memberved murti3-May-07 3:11 
GeneralRe: Pocket PC 2002 and .NET Connector Pin
Isidoro!3-May-07 3:36
memberIsidoro!3-May-07 3:36 
GeneralRe: Pocket PC 2002 and .NET Connector Pin
noelse18-May-07 6:31
membernoelse18-May-07 6:31 
GeneralRe: Pocket PC 2002 and .NET Connector Pin
warrnet15-Apr-08 11:08
memberwarrnet15-Apr-08 11:08 
GeneralRe: Pocket PC 2002 and .NET Connector Pin
huseyin_yildiz3-Jul-08 11:23
memberhuseyin_yildiz3-Jul-08 11:23 
GeneralRe: Pocket PC 2002 and .NET Connector Pin
MartinSwart20-Nov-08 20:41
memberMartinSwart20-Nov-08 20:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151125.3 | Last Updated 18 Apr 2007
Article Copyright 2007 by ved murti
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid