'调用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
原文链接:https://www.f2er.com/vb/261905.html