Using the SAP .Net Connector in Visual Studio 2008

Overview

This blog post describes how to use an SAP .Net Connector proxy, created in a VS 2003 project, in a Visual Studio 2008 C# solution.

[Editor's Note]
This blog is third in a multi-part series describing how to use the SAP .NET Connector:

  1. Introduction to the SAP .Net Connector
  2. Building an SAP .NET Connector Proxy
  3. Using the SAP .Net Connector in Visual Studio 2008

Introduction

Our previous post described how to use Visual Studio 2003 and the SAP .Net Connector to create a Dynamic Link Library containing the desired SAP functionality. The DLL contains proxies for each SAP function that we want to utilize.

We will reference that DLL in a Visual Studio 2008, and use it to retrieve system information from an SAP host.

As a demonstration, we are creating the TLA System, which exists solely to demonstrate certain SAP .Net Connector programming techniques.

Using the SAP .Net Connector Proxy

Now we are ready to put our SAP .Net Connector Proxy to work. This will allow us to use the SAP .Net Connector in the modern Visual Studio environment.

Start a Visual Studio 2008 Project

Start a new Visual Studio 2008 Project. Use the Console Application template, and name the solution TlaSapRfcClient.

Creating a new console application

Creating a new console application

Add a Reference to the TLA SAP Proxy

Now we need to add a reference to the DLL we created earlier.

In the Solution Explorer, right click References and choose Add Reference. Using the Browse tab, find the TlaSapProxy.dll file from the TlaSapProxy project. Typically, this will be in the bin\debug folder of the TlaSapProxy folder. Click the OK button to add the reference to your project.

Adding a reference to the proxy

Adding a reference to the proxy

C# Code

Here is a Visual Studio 2008 C# program that uses the SAP .Net Connector proxy that we built earlier using Visual Studio 2003.

C# program listing

C# program listing

When we create an instance of the proxy in line 11, we pass in an SAP connection string. We create an object of type SAPProxy1 because that is what we named it in our Visual Studio 2003 project.

In line 20, we create an object of type RFCSI, because that is what our RFC call to Rfc_Get_System_Info will return. The type definition for RFCSI was also included in the proxy.

In line 22 we make the RFC call to the SAP host. We get full IntelliSense support that describes the parameters required.

Summary

The SAP .Net Connector is built for Visual Studio 2003. By using Visual Studio 2003 to create a DLL, we can use the SAP .Net Connector in Visual Studio 2008 (or later).

Here we have described how to use that DLL in a Visual Studio 2008 project.

Comments

  1. Hi,
    Can you share the dll for me?

  2. The SAP .NET Connector is available from the SAP Service Marketplace: http://service.sap.com/connectors. You must have access to the SAP Service Marketplace to download. Unfortunately, we are unable to redistribute the installation file.

  3. Thanks for this detailled explanation. it really will help me.

  4. any instruction to use webservice using visual studio 2010 and dot net 4

  5. Mike Parker says:

    After this process is complete will the resulting .exe require the .NET 1.1 runtime?

    We are running into this issue with WIN2K8. It will not allow .NET 1.1 to be installed.

    This technique would be great for us if it does not required the 1.1 runtime.

  6. justice says:

    I am unable to see the .Net Connector from the VS Templates, I am using the VS 2008. Please assist on how to get it shown on the VS Templates. I have installed the .Net Connector 3.0 successfully but it doesnt show when I go to Add new Items.

Trackbacks

  1. [...] We will use Visual Studio 2003 to create a DLL that manages the interactions with the SAP host. The SAP .Net Connector version 2.0 works with Visual Studio 2003 or 2005. To use the .Net Connector in our preferred environment of Visual Studio 2008, we will create the proxy DLL in 2003 and add that to our 2008 project. The techniques are described in our earlier post, Using the SAP .Net Connector in Visual Studio 2008. [...]

Add Comment Register



Speak Your Mind

*