Applications To SAP: Home Quick Answers Discussions Features Community Help Articles
Applications To SAP: Home Quick Answers Discussions Features Community Help Articles
Applications To SAP: Home Quick Answers Discussions Features Community Help Articles
help
An article about using the SAP.NET connector to connect your .NET applications to SAP
Overview
This article will show how to establish a connection to SAP and how to call an ABAP function on SAP and pass data to
the function and receive data back from the function all via the SAP .NET Connector.
Introduction
If you are a .NET Software Developer, it's almost a given that you have been tasked at one time or another to interact
with various ERP systems. Sometimes, this task can be completed simply because you may be granted access directly
to the back end databases, however often, you need to communicate directly with the business logic layer of the ERP
system. This is often the case when working with SAP because of the powerful ABAP functions which reside within the
business logic layer of the system. Fortunately, SAP and Microsoft have teamed up to provide developers with the
SAP.NET Connector.
The SAP Connector for Microsoft .NET is a programming environment 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 and C#. This article will demonstrate how to get connected to SAP and how to call an ABAP function
and pass data to and from SAP. So, without further ado, let's get to the code!
1 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
After you add the proxy, you will notice that the system automatically adds the necessary references to your project as
well as creates a WSDL file called SAPProxy1.wsdl. This file will show up as a blank screen in Visual Studio, as shown
in figure 2 below:
2 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
Once the proxy has been added, it's time to add the SAP Server to your project. Click View, then click Server Explorer
and you will see that an option for SAP is included in the list. Click the SAP entry and it will expand and show
"Application Servers". Right click this and select "Add Application Server". A dialog box similar to Figure 3 below will
appear:
This is where you will need to set your parameters for establishing a connection to your SAP server. Change the
3 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
Destination Type property to “Custom”, then add the necessary values for the following properties:
User Name
Password
AppServerHost
SAPRouterString
HTTP Port
Client
System Number
These variables will depend on your SAP installation. Check with your SAP Administrator for the specific settings in
your environment.
Once you have the properties set, you can then establish your connection to SAP. Expand the new server, then expand
the Functions entry. This will provide a list of all ABAP functions that are contained in your SAP environment. See figure
4 below:
The next step is to locate the function that you wish to call. When you find it, simply drag and drop it onto the
SAPProxy1.sapwsdl file. It will automatically create several objects and even code files that relate to your particular
function (note that you need to be viewing all files in your project to see the code files that the process creates):
4 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
Once this step is created, the rest is quite easy. To demonstrate, my sample uses a very simple ABAP function that
takes a contract number and a line item number and returns an invoice. I have created a form with 1 button and a
textbox. The code behind my button will do the following:
Here is the code listing (note that I have removed the actual connection values – you need to substitute the values with
your connection parameters):
Try
'params are contract # and line item
BAPI.Zsdus_Get_Invoice_Number("0045001126", "000010", SAPtbl, Ret)
Catch ex As Exception
MsgBox(ex.Message)
End Try
5 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
TextBox1.Text = (SAPtbl.Item(0).Vbeln.ToString)
End Sub
As you can see, the function call returned a data table with invoice information. I have chosen to only display one field
for simplicity sake, but the actual data returned is all the contents of the invoice. We could have loaded this information
to a data grid, for example.
Conclusion
This article shows a real world example of connection to SAP and calling an ABAP function from .NET via the SAP.NET
connector. As you can see, by using the connector as a client to SAP, we can easily connect to the SAP server and
invoke any function that we have permissions to execute. This ability add tremendous flexibility to your .NET
applications when you need to integrate with SAP.
6 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
License
This article, along with any associated source code and
files, is licensed under The Code Project Open License
(CPOL)
Share
TWITTER
No Biography provided
Search Comments
7 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
Thanks!
Explanation is good
Where can I get the connector from without having to log into sap?
Has anyone tried the above example? Andreas Kasapleris 6-Mar-13 12:16
I want to ask if anyone has tried the above. Although I have installed SAP Connector with VS2010
nothing of the above example seems to work. SAP Proxy does not even appear as on option!
Re: Has anyone tried the above Jim F. Johnson 14-Jan-15 18:34
example?
Not sure about the current options for RFC integration from VS2010. Has anyone tried with other
tools? Is SAP Connector 3.0 working with the VS 2010 IDE?
---
D.
8 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
Hi Andy,
Hope your doing good. I was doing some research on google and came across one of your articles.
We are working on a Windows application which is a c sharp.net application which connects to SAP and does
some transactions. Currently we use the .net connector to connect to SAP. Here user needs to enter the user
name and password in order to log in to the system. Now we have a requirement where user doesn't want to
enter the credentials. They want us to connect to SAP using windows authentication. Single Sign on is already
configured in SAP. I just want to know how can i connect to SAP using the windows login details.
Please help me out as i need to do a prototype and confirm that this is possible.
Hi Andy ,
This is a great article , I have a requirement to login to SAP using Single Sign on , Will you be able to help me
out. IF you can please send me a mail on [email protected] , thanks
I tried to download the source code of this article....but when I download the file attached occurs that this .rar
file contains a set of images, and scripts but doesn't have the source code....
please help!!!!!!!!!!111
Error I::001 Only available with the RFC Alexey120 18-Jan-10 1:07
library from 4.0C onwa
I develop .net application which download a document via SAP-RFC_CALL. Inside this RFC I use standard
BAPI’s for check out, eg BAPI_DOCUMENT_CHECKOUTVIEW2 but I get an error in out RETURN parameter -
I::001 Only available with the RFC library from 4.0C onwa
Please, help if you know how to solve this issue.
Best regards,
Alex
9 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
Here it is, but you'll need dotnetFramework 1.1 and Visual Studio 2003...
http://www.megaupload.com/?d=GUZ76550[^]
http://rapidshare.de/files/48781419/SAP.Net.Setup_2.0.rar.html[^]
It also seems to be using the latest version of librfc32.dll (allowing more than 8-chars passwords, etc)
Cheers!
PK.
Thanks,
I am getting the above error when i am dragging and droping an ABAP function from the server explorer
window onto the sapproxy designer.The full details of the error window are as given below.
10 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
Hi,
Did you get a solution to your problem. I too am facing a similar problem. I am connecting to the SAP server
of our client from my machine via VPN. We are using VS.Net 2003 with SAP .Net Connector 2.01. We are
able to connect to the SAP server and view the functions. Only when I drag and drop the function onto the
designer get the following message
I was wondering if you found a solution to your problem. I am aware you faced this long time back but if you
could recall and help me, I would be very happy.
Regards
Navin
11 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
System(Client=0,System=1) [modified]
Hi,
Regards
Navin
12 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
So I looked at what port the SAP logon connects to and notice it was a different one : 3216 instead of 3316.
13 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
VERSION 37
RC -10
MODULE nixxi_r.cpp
LINE 8724
DETAIL NiPConnect2
SYSTEM CALL SiPeekPendConn
ERRNO 10061
ERRNO TEXT WSAECONNREFUSED: Connection ref
Re: Can't connect to Server SAP to Check here to remove 1-Dec-08 22:09
your current profile picture
get the functions
In the later check if you have the correct port number for the sap service.
You can check which port would be by running the dos command 'netstat -a' while running SAPGui.
Hi,
I have installed Sap Net Connector, and I added the Proxy as new Item, but when it came to see the Server
Explorer the SAP option did not appear at all.
What do you think?
14 de 15 26/9/18 2:56
Using the SAP.NET Connector to Connect your ... https://www.codeproject.com/Articles/24161/Us...
I am facing problem when I try to use the SAP.NET connector on 64bit processor:
Error:An attempt was made to load a program with an incorrect format. (Exception from HRESULT:
0x8007000B)
I guess the dependent components like "sap.connector.dll","sap.connector.rfc.dll" and/or "librfc32.dll" are 32bit
compliant. What is the workaround for this?
Last Visit: 31-Dec-99 18:00 Last Update: 25-Sep-18 14:52 Refresh 1 2 Next »
15 de 15 26/9/18 2:56