zl程序教程

您现在的位置是:首页 >  其他

当前栏目

SAP ABAP 系统同微软 Office 套件进行 Desktop Integration 的工作原理

SAP系统微软原理 进行 工作 ABAP Office
2023-09-14 09:02:43 时间

SAP 集成技术允许开发人员将与 OLE 兼容的桌面应用程序(例如 Microsoft Office、Lotus SmartSuite 或 Visio)集成到 SAP 系统中。

通信和数据传输工作原理如下:

SAP GUI( Presentation 服务器)和 SAP 应用程序服务器之间的通信在 4.0 版中得到了扩展。这使得在 SAP GUI(控制框架)中包含 ActiveX 控件成为可能。

以 Office Excel 为例,在 Options -> Customize Ribbon 里将 Developer 标签配置出来:

Desktop Office 集成将此接口用于特殊控件(SAP Document Container Control 和 SAP Data Provider),它们是 SAP 系统和 Desktop Office 应用程序之间的通信通道。

SAP Document Container Control 使用方法和属性与使用 OLE2 接口的桌面应用程序进行通信。

SAP Data Provider 是不同格式数据的容器和转换器。开发人员导入应用程序的数据将转换为基于 Internet 标准 MIME 的可读格式。 SAP 数据提供者缓冲在 SAP 系统中管理的文档数据。它还缓冲 SAP 数据,这些数据可以使用 R/3 链接插入到文档中。

然后在 Developer 标签页里就可以插入 ActiveX 控件了,比如 button:

这些按钮上面可以编写简单的 VBScript:

Private Sub CommandButton1_Click()
Set R3 = CreateObject("SAP.Functions")
    Set myConnction = R3.Connection
    myConnction.ApplicationServer = "ag3"
    myConnction.SystemNumber = 54
    myConnction.Client = "001"
    myConnction.user = "WANGJER"
    myConnction.Password = "your password"
    
    If myConnction.Logon(0, True) <> True Then
      MsgBox "Logon failed"
      Exit Sub
    End If
    
    Dim callFunctionModule As Object
        
    Set callFunctionModule = R3.Add("TH_USER_LIST")
    callFunctionModule.Call

    If callFunctionModule.Exception <> "" Then
        MsgBox callFunctionModule.Exception
    End If

    If callFunctionModule.Call = True Then
        Dim result As Object
        Set result = callFunctionModule.tables("USRLIST")
        Dim aSheet As Worksheet
        Dim sheetCol As New Collection
        sheetCol.Add ActiveWorkbook.Sheets(1)
        For Each aSheet In sheetCol
            Dim i As Integer
            i = 1
            For Each user In result.Rows
                
                Client = user(2)
                UserName = user(3)
                Terminal = user(5)
                IP = user(16)
                aSheet.Cells(i, 1) = Client
                aSheet.Cells(i, 2) = UserName
                aSheet.Cells(i, 3) = Terminal
                aSheet.Cells(i, 4) = IP
                
                i = i + 1
            Next
        Next
    Else
        MsgBox " Call Failed! error: "
    End If
'log off
    myConnction.logoff
End Sub

这两个控件都有一个到 SAP 系统的接口。 SAP Data Provider 的接口是使用功能模块实现的。桌面办公室集成的 ABAP 类和接口提供了到 SAP 文档容器控件的接口。