Using The SAP .NET Connector
Using The SAP .NET Connector
3)
Prepared by: Jay Kladiva version 1.0
USES: Allows RFC and BAPI calls from .NET applications and can also be used to
submit pre-generated IDOCs to SAP
NOTES: The SAP .NET Connector must be obtained from the download section of the
SAP website. BizTalk 2004 is only compatible with the 1.0.3 version of the SAP .NET
Connector, other .NET projects can use newer versions of the SAP .NET Connector. The
SAP .NET Connector must be installed on the server that the .NET application will be
running on.
Open Visual Studio.NET 2003 and under C# Projects, select SAP Connector, then select
SAP server from the dialog box:
Enter the connection information for SAP and keep the defaults, you want to create a
client proxy:
Enter part or all of the name of the RFC you wish to call, then select the RFC you are
interested in and click the Add button:
The wizard will create a client proxy which will be utilized to call the RFC:
Rename this project with a suitable name and namespace and re-compile the project.
This assembly can now be called from one or more .NET projects.
Open your .NET project and set a reference to the assembly that was just created above
and also set a reference to Energizer.SAP(this component can be pulled from Visual
SourceSafe under the Components directory).
Implement a method which calls the RFC(see code example from WMSC Wal-Mart
Open Orders project:
''' This Method is used to get PO Data from SAP. using the SAP
Connector
'''
The SAP .NET Connector can be utilized to submit IDOCs from any .NET application.
We currently utilize this in BizTalk to get a transaction ID from SAP(TID) from a given
IDOC submission.
'// We call this method to submit the Idoc and return the TID value.
We need to pass in all the
'// SAP communication information in order for this to occur. The
returned value is the string
'// TID.
Public Function SubmitIDOC(ByVal Host As String, ByVal Client As
Int32, ByVal SystemNumber As Int32, _
ByVal User As String, ByVal Password As String, ByVal IDOCPath
As String) As String
Try
'// we needed to write in this delay loop because we were
frequently trying to
'// submit the Idoc before it was written to file by the
send from the orchestration.
Do While Not System.IO.File.Exists(IDOCPath)
If iCount < 2 Then
System.Threading.Thread.CurrentThread.Sleep(1000)
Else
Throw New ApplicationException("Unable to locate the
IDOC file: " & IDOCPath)
End If
iCount += 1
Loop
End Function
Return sapConnection
End Function
End Class
BizTalk Orchestration that utilizes the SAP .NET Connector: