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.
This blog is third in a multi-part series describing how to use the SAP .NET Connector:
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.
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.
Here is a Visual Studio 2008 C# program that uses the SAP .Net Connector proxy that we built earlier using Visual Studio 2003.
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.
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.