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 Try
End Sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值