VB.NET通过SAP.Connector调用SAP的RFC

前端之家收集整理的这篇文章主要介绍了VB.NET通过SAP.Connector调用SAP的RFC前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

'调用RFC
Dim myDest As New SAP.Connector.Destination
Dim myProx As New DEMO_GetData.SAPProxy1


Public Function SapStr(ByVal stype As Integer) As String
Dim str As String

'测试机
str = "用户名,密码,系统号,客户端号,IP地址"

Return str
End Function


Private Sub Main_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load

Try
myProx.Connection = SAP.Connector.Connection.GetConnection(myDest)
If (myProx.Connection.IsOpen = False) Then
Dim saps() As String = Split(SapStr(stype),",")
myDest.Username = saps(0)
myDest.Password = saps(1)
myDest.SystemNumber = saps(2)
myDest.Client = saps(3)
myDest.AppServerHost = saps(4)
myProx.Connection.Open()
End If
Catch ex As Exception
WriteTxt("",ex.ToString)
End Try

Call Button5_Click(send,e)
End Sub

Private Sub Button5_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button5.Click
Dim partner As String = TxtCustId.Text.ToString.Trim'参数
Try
'执行语句
Dim strID As String = ""
Dim strSyncState As String = ""


Dim rtTable As New Ecsms_GetData.YHYSDCSMS01Table'RFC上定义的表
myProx.POP_DEMOTEST(strID,rtTable,strSyncState)'执行RFC函数

'strSyncState 为Y表示RFC执行成功
If strSyncState = "Y" Then
Dim dtTable As New DataTable
dtTable = rtTable.ToADODataTable

Dim i As Integer
Dim sqllist As New ArrayList
Dim sql as string
For i = 0 To dtTable.Rows.Count - 1
sqllist.Add(sql)
Next

If execTrans(sqllist) = True Then LabNote.Text = "获取成功" Else LabNote.Text = "获取失败" End If Else LabNote.Text = "WRONG" End If '语句执行完毕 Catch ex As Exception WriteTxt("",ex.ToString) End TryEnd Sub

猜你在找的VB相关文章