在VB中调用SAP function及SAP RFC的例子 |
在VB中调用SAP function及调用SAP RFC的例子: Dim Functions As Object Dim SAPFunction1 As SAPFunctions Dim SAPFunction As Object Dim oFunc As Object Dim Connect As Object Dim colX As ColumnHeader Dim itmX As ListItem Dim Column1 As Integer Dim rows1 As Integer Dim Column2 As Integer Dim rows2 As Integer Private Sub Form_Load() Set Connect = SAPLogonControl1.NewConnection Connect.System = "P13" Connect.ApplicationServer = "200.200.0.32" Connect.SystemNumber = 0 Connect.User = "用户名" Connect.Password = "密码" Connect.Client = "096" Connect.Language = "EN" If Connect.Logon(Form1.hWnd, True) = False Then MsgBox "联接SAP失败!" Exit Sub End If Call list End Sub Private Sub list() ListView.ListItems.Clear ListView.ColumnHeaders.Clear Set colX = ListView.ColumnHeaders.Add() colX.Text = "序号" colX.Width = 300 Set colX = ListView.ColumnHeaders.Add() colX.Text = "IDOC号" colX.Width = 1600 Set colX = ListView.ColumnHeaders.Add() colX.Text = "状态" colX.Width = 400 Set colX = ListView.ColumnHeaders.Add() colX.Text = "描述" colX.Width = 4000 Set colX = ListView.ColumnHeaders.Add() colX.Text = "日期" colX.Width = 900 Set colX = ListView.ColumnHeaders.Add() colX.Text = "时间" colX.Width = 1200 Set SAPFunction = CreateObject("SAP.Functions") Set SAPFunction.Connection = Connect Set oFunc = SAPFunction.Add("ZREAD_IDOC_DATA") If Not oFunc.Call Then Exit Sub End If oFunc.Tables("I_EDIDC").Views.Add SAPTableView1.object oFunc.Tables("I_EDIDC").Refresh SAPTableView1.ColumnAutoWidth 1, SAPTableView1.ColumnCount Column1 = SAPTableView1.ColumnCount rows1 = SAPTableView1.RowCount oFunc.Tables("I_EDIS").Views.Add SAPTableView2.object oFunc.Tables("I_EDIS").Refresh SAPTableView2.ColumnAutoWidth 1, SAPTableView2.ColumnCount Column2 = SAPTableView2.ColumnCount rows2 = SAPTableView2.RowCount For i = 1 To rows1 Set itmX = ListView.ListItems.Add() itmX.Selected = True itmX.Text = i itmX.SubItems(1) = SAPTableView1.Cell(i, 2) 'idoc number itmX.SubItems(2) = SAPTableView1.Cell(i, 4) 'status For j = 1 To rows2 If SAPTableView2.Cell(j, 1) = SAPTableView1.Cell(i, 4) Then If SAPTableView2.Cell(j, 2) = "E" Then itmX.SubItems(3) = SAPTableView2.Cell(j, 3) 'desp End If End If Next j itmX.SubItems(4) = SAPTableView1.Cell(i, 38) 'date itmX.SubItems(5) = SAPTableView1.Cell(i, 39) 'time Next i StatusBar1.SimpleText = "共计:" & rows1 End Sub 另:VB调用RFC的函数 Set SAPFun = CreateObject("SAP.Functions") '---连接到SAP Set RFCFun = SAPFun.Add("RFC_READ_TABLE") '---SAP用户认证 |
在VB中调用SAP function及SAP RFC的例子
最新推荐文章于 2023-02-18 13:46:04 发布