23 June 2007

Using the .NET Connector for SAP

Many enterprise organizations use SAP for their business critical processes. Application written in .NET often require data stored in SAP systems. In this article I'd like to present the interoperability between a .NET application and a SAP system using the .NET connector for SAP.

Installing the .NET Connector for SAP

First of all we need a plugin for Visual Studio.NET 2003. This software can be downloaded at the SAP website. Download the 2.0.1 version. You'll need a service account for this. Typically the SAP administrators in your organization can supply you with one. The Connector software is only available for Visual Studio.NET 2003 and thus will not work with Visual Studio 2005. In this example we're going to compile an assembly with the connector functionality and use this assembly in a 2005 solution.

Click here to download the .NET Connector for SAP

Create the .NET assembly

After downloading and installing the software start Visual Studio.NET 2003. Notice the SAP Connector plugin in the splash screen or in the Help, Info screen.


Create a new project (File, New, Project) of the type Empty Project. Add a new item to the project of the type SAP Connector.


Proxy and 2 references (SAP.Connector and SAP.Connector.Rfc) will be added to the solution.


Open the Proxy we just created and open the Server Explorer. Notice that there's a new node available named SAP. Right click on the Application Servers node and choose Add Application Server. The "Add new SAP Application Server" window opens. Fill in the following settings:

  • DestinationType: Custom Login Settings

  • Client: The SAP logon client

  • Username: The SAP Logon user

  • Password: The SAP Logon password

  • AppServerHost: The IP Address or Hostname of the SAP system

  • SystemNumber: The R/3 system number
Open the newly created node and add a new Functions Filter by clicking the right mousebutton on the Functions folder. The NameFilter property is *. This is a wildcard which implies that all SAP functions will be listed for this filter. Open the filter and the functionlist will appear.

Drag and drop a function on the opened SAP Proxy file. In this example we'll use the standard BAPI called Bapi_Salesorder_Getlist. Compile the project and congratulations, you just finished the second step by creating an assembly.


Let's interact with SAP!


Start Visual Studio 2005 and create a new webproject. Add references to the compiled assembly and to the in step 1 installed SAP.Connector and SAP.Connector.Rfc.

Create a new Web Form and supply this webform with a GridView. On the Page_Load event use the following code.



Run the application and you'll see that the information is extracted from the SAP system and shown in the GridView.

7 comments:

Anonymous said...

Has anyone checked out this tool? http://www.softwise.com.ar/products.php?pid=SWSE.

It seems Softwise has a component that enables the creation of proxy classes directly from Visual Studio 2005.

Regards,

John

Anonymous said...

Hello,
Thanks for this post. I was just looking for something like this.

Regards
Nihad

Anonymous said...

I cannot download SAP.NET connector because I cannot obtain all the user ID's, passwords and installation numbers required, even though I am SAP customer. This SAP company is simply a crazy place. It is impossible to get the connector out of them!

Can anybody help me to download this thing. I have been trying for 6 months now!

Anonymous said...

thanks for the information

Chinna, MCAD (.NET)

Anonymous said...

Great work.

bashi said...

Great post man.. i was searching for 3 days n jst found this one... this is the only one i found with the correct n specific info..
thanx a lot ..
keep it up

Anonymous said...

You may also check this series of products from Aconcagua IT: http://www.aconcaguait.com/explorerproxygen2008.php

A VS package that can be used from Visual Studio 2008 and 2010. I've using the trial with our R/3 environments and it worked just fine.

Anyone has tried it?