<ph type="x-smartling-placeholder"></ph> 请参阅 Application Integration 支持的连接器

SAP ERP 触发器

SAP ERP 触发器是一种连接器事件触发器;借助 SAP ERP 连接器,您可以对 SAP ERP 数据执行插入、删除、更新和读取操作。

准备工作

  • 如果您计划为 SAP ERP 触发器创建或配置新连接,请确保您拥有项目的以下 IAM 角色: <ph type="x-smartling-placeholder">
      </ph>
    • 连接器管理员 (roles/connectors.admin)
    • 如需了解如何授予角色,请参阅管理访问权限

  • 向您要用于 SAP ERP 触发器的服务账号授予以下 IAM 角色: <ph type="x-smartling-placeholder">
  • 添加 SAP ERP 触发器

    如需将 SAP ERP 触发器添加到集成中,请执行以下步骤:

    1. 在 Google Cloud 控制台中,前往 Application Integration 页面。

      转到 Application Integration

    2. 在导航菜单中,点击集成

      系统会显示集成列表页面,其中列出了 Google Cloud 项目中可用的所有集成。

    3. 选择现有集成,或点击创建集成以创建新的集成。

      要创建新的集成,请执行以下操作:

      1. 创建集成窗格中输入名称和说明。
      2. 为集成选择一个区域。
      3. 为集成选择服务账号。您随时可以在集成工具栏的 集成摘要窗格中更改或更新集成的服务账号详细信息。
      4. 点击创建

      系统随即会在集成编辑器中打开该集成。

    4. 集成编辑器导航栏中,点击触发器查看可用触发器的列表。
    5. 点击 SAP ERP 触发器元素并将其放置到集成编辑器中。
    6. 如需配置 SAP ERP 触发器,您可以使用 Integration Connectors 中提供的现有 SAP ERP 连接,也可以使用内嵌连接创建选项创建新的 SAP ERP 连接。

    使用现有连接配置 SAP ERP 触发器

    SAP ERP 触发器连接器事件触发器,因此,您只能使用启用了事件订阅的 SAP ERP 连接来配置触发器。

    如需了解如何使用新的 SAP ERP 连接配置 SAP ERP 触发器,请参阅使用新连接配置 SAP ERP 触发器

    如需使用现有 SAP ERP 连接配置 SAP ERP 触发器,请执行以下步骤:

    1. 点击集成编辑器中的 SAP ERP 触发器元素,打开触发器配置窗格。
    2. 点击配置触发器
    3. 连接器事件触发器编辑器页面中提供以下配置详细信息: <ph type="x-smartling-placeholder">
        </ph>
      1. 区域:选择 SAP ERP 连接所在的区域。
      2. Connection(连接):选择您要使用的 SAP ERP 连接。

        Application Integration 仅显示活跃且已启用事件订阅的 SAP ERP 连接。

      3. 输入事件类型字段名称。此字段标识事件类型 与传入事件请求相关联。
        {
            "event_type": "user.created",
            ...
            // other request fields
            ...
            }
      4. 服务账号:选择具有 SAP ERP 触发器所需 IAM 角色的服务账号。
    4. 点击完成以完成触发器配置并关闭页面。

    使用新连接配置 SAP ERP 触发器

    1. 点击集成编辑器中的 SAP ERP 触发器元素,打开触发器配置窗格。
    2. 点击配置触发器
    3. 跳过区域字段。
    4. 点击连接,然后从下拉菜单中选择创建连接选项。
    5. Connection Details 部分中,完成以下操作: <ph type="x-smartling-placeholder">
        </ph>
      1. 连接器:从可用连接器下拉列表中选择 SAP ERP
      2. 连接器版本:从可用版本的下拉列表中选择连接器版本。
      3. Connection Name 字段中,输入连接实例的名称。

        连接名称必须满足以下条件:

        • 连接名称可以使用字母、数字或连字符。
        • 字母必须小写。
        • 连接名称必须以字母开头,以字母或数字结尾。
        • 连接名称不能超过 63 个字符。
      4. (可选)输入连接的说明
      5. (可选)启用 Cloud Logging
      6. 服务账号:选择具有所需角色的服务账号。
      7. 如需将连接用于事件订阅,请选择启用事件订阅。正在选择 时,系统会显示以下选项: <ph type="x-smartling-placeholder">
          </ph>
        • Enable event subscription with entity and actions(启用包含实体和操作的事件订阅):选择此选项可以 将连接用于事件订阅和连接器操作(实体和操作)。
        • 仅启用事件订阅:选择此选项可使用连接 仅适用于事件订阅。如果您选择此选项,请点击下一步,然后 配置事件订阅
      8. 客户端:向 SAP 系统进行身份验证的客户端。
      9. System Id:SAP 系统的 System Id 或 R3Name 是一个字符串,最多包含 3 个字符。它通常用于负载均衡连接。
      10. 系统编号:定义目标系统所用的编号。在设置主机连接属性时使用。
      11. 项目 ID:包含 SAP JCo jar 的 GCS 存储桶所在的 Google Cloud 项目的 ID。
      12. 存储桶:包含 sapjco3.jar 和 libsapjco3.so 文件的存储桶的名称。
      13. Jaco jar 对象 ID:JCo jar 的对象 ID。
      14. libsapjco3 对象 ID:libsapjco3 jar 的对象 ID。
      15. 表模式:选择要显示为视图的 SAP 表。
      16. SNC_LIB 对象 ID:SNC 库的对象 ID。
      17. PSE 名称:适用的个人安全环境 (PSE) 文件的名称 。PSE 文件以 ASN.1 结构存储公钥和私钥对以及 X.509 证书。
      18. 群组:用于登录的群组名称。这通常是在 SAP 系统 使用负载平衡器
      19. 消息服务器:连接到使用负载平衡器的 SAP 系统时使用的消息服务器的名称。
      20. 读取表格函数:要用于读取表格的函数名称。有关 相关信息,请参阅使用自定义读取表函数
      21. 连接方案:选择用于连接到 SAP 系统的连接方案。
      22. 系统 ID:SAP 系统的系统 ID 或 R3Name。您最多可以输入 3 个字符。
      23. SNC 密码:选择 SNC 库密码的 Secret Manager 密钥。
      24. Secret 版本:选择 Secret 版本。
      25. SNC 模式:选择此选项可启用 SNC,以便在 Application Integration 和 SAP 系统之间进行身份验证。
      26. SNC 名称:输入 SNC 连接的名称。
      27. SNC qop:选择保护级别。支持的级别如下: <ph type="x-smartling-placeholder">
          </ph>
        • 1 - 仅应用身份验证。
        • 2 - 应用完整性保护。这也包括身份验证保护。
        • 3 - 采取隐私保护措施。这也包括完整性和身份验证保护。
        • 8 - 应用默认保护。
        • 9 - 应用最高保护措施。
      28. SNC 合作伙伴名称:输入应用服务器的 SNC 名称。
      29. 查询模式:选择应将哪些 SAP 表显示为视图。
      30. 可浏览视图:输入要显示的视图列表(以英文逗号分隔)。 例如 ViewA,ViewB,ViewC
      31. 详细程度级别:输入日志记录的详细程度级别。支持的 值介于 1 到 5 之间。值越高,表示可获取的详细信息就越多 日志中。
      32. (可选)配置连接节点设置

        • 节点数下限:输入连接节点数下限。
        • 节点数上限:输入连接节点数上限。

        节点是处理事务的连接单元(或副本)。 连接处理越多事务就需要越多节点,相反,处理越少事务需要越少节点。 如需了解节点如何影响连接器价格,请参阅连接节点的价格。如果未输入任何值,则默认情况下,节点数下限设置为 2(以便提高可用性),节点数上限设置为 50。

      33. (可选)点击 + 添加标签,以键值对的形式向连接添加标签。
      34. 点击下一步
    6. 目标位置部分,输入您要连接的远程主机(后端系统)的详细信息。
      1. 目的地类型:选择目的地类型
        • 从列表中选择主机地址,以指定目的地的主机名或 IP 地址。
        • 如果要与后端系统建立专用连接,请从列表中选择端点连接,然后从端点连接列表中选择所需的端点连接。

        如果要与后端系统建立公共连接以提高安全性,您可以考虑为连接配置静态出站 IP 地址,然后将防火墙规则配置为仅将特定静态 IP 地址列入许可名单。

        要输入其他目的地,请点击 +添加目的地

      2. 点击下一步
    7. Authentication(身份验证)部分中,输入身份验证详细信息。
      1. 选择身份验证类型,然后输入相关详情。

        SAP ERP 连接支持以下身份验证类型:

        • 用户名和密码
      2. 如需了解如何配置这些身份验证类型,请参阅配置身份验证

      3. 点击下一步
    8. 如果您已启用事件订阅,则连接创建页面上会显示事件订阅详情部分。为了了解 请参阅配置事件订阅
    9. 查看:查看您的连接和身份验证详细信息。
    10. 点击创建

    配置身份验证

    根据您要使用的身份验证输入详细信息。

    • 用户名和密码 <ph type="x-smartling-placeholder">
        </ph>
      • 用户名:连接器的用户名
      • Password:包含与 连接器。

    配置事件订阅

    如果您启用了事件订阅,请在 Event Subscription Details 部分:

    1. 为事件监听器选择以下任意一种身份验证类型。 <ph type="x-smartling-placeholder">
    2. 输入事件类型字段名称。此字段标识与 传入事件请求。
      {
      "event_type": "user.created",
      ...
      // other request fields
      ...
      }
    3. Select Enable private connectivity for secured connectivity between your backend application and your connection. If you select this option, you must perform additional configuration steps after creating the connection. For more information, see Private connectivity for event subscription.
    4. Enter the dead-letter configuration. If you configure dead-letter, the connection writes the unprocessed events to the specified Pub/Sub topic. Enter the following details:
      1. Dead-letter project ID: The Google Cloud project ID where you have configured the dead-letter Pub/Sub topic.
      2. Dead-letter topic: The Pub/Sub topic where you want to write the details of the unprocessed event.

    Use a custom read table function

    RFC_READ_TABLE

    The connector uses the SAP RFC_READ_TABLE function to get data from SAP tables.

    However, it has certain limitations. As an example, consider the DATA_BUFFER_EXCEEDED exception. The SAP RFC_READ_TABLE has a fixed size of 512 bytes. It can buffer for each row of data, and thus you cannot select more columns than the amount that would fit in this buffer. If you select more than 512 bytes, an exception occurs indicating that you have exceeded the maximum buffer size allowed per row and need to select fewer columns.

    RFC_READ_TABLE2

    The SAP ERP connector supports the RFC_READ_TABLE2 table read function. You can switch the active table read function to RFC_READ_TABLE2 by setting ReadTableFunction to /SAPDS/RFC_READ_TABLE2.

    Custom read table functions

    The connector includes a custom read-table RFC, Z_CUSTOM_READ_TABLE that is similar to the SAP RFC_READ_TABLE, but with a larger buffer to address the DATA_BUFFER_EXCEEDED problem and bypass RFC_READ_TABLE limitations.

    To use the included custom read-table RFC to bypass limitations with the default RFC_READ_TABLE, follow these steps:

    1. Use the RFC_READ_TABLE function as a template for the new function. Select transaction code SE37 and the SDTX function group and copy RFC_READ_TABLE to a new function group or your working function group. In this example, RFC_READ_TABLE is copied to Z_CUSTOM_READ_TABLE.
    2. On the Attributes tab of the SAP screen, select Remote Enabled Module.
    3. On the Tables tab, set the DATA parameter to CHAR8000. Right-click on the screen and then click Display -> Change.
    4. On the Source Code tab, paste the example source code for the replacement RFC_READ_TABLE function module located in the db subfolder of the installation directory. The code is located in Z_CUSTOM_READ_TABLE.txt, though Z_CUSTOM_READ_TABLE_752.txt is preferred if your SAP ERP instance is running ABAP version 7.52 or later.
    5. Click Save.
    6. Define the imports, tables, and exceptions as documented in the provided custom read table.
    7. Activate the function module and in your connection string set ReadTableFunction to Z_CUSTOM_READ_TABLE, or the name of your function module.

    The ABAP 7.52 Custom Read Table

    Along with Z_CUSTOM_READ_TABLE.txt, there is also a Z_CUSTOM_READ_TABLE_752.txt file, for ABAP version 7.52 and above. It is similar to Z_CUSTOM_READ_TABLE, but it takes advantage of the newly available keywords in ABAP 7.52 to perform paging within the database instead of in the ABAP script itself. This makes paging efficient when working with large tables.

    It is recommended to use the Z_CUSTOM_READ_TABLE_752 RFC.

    Configure authentication in SAP

    Configure the authentication in SAP by following the instructions in the Authentication overview for the on-premises or any cloud edition of ABAP SDK for Google Cloud guide.

    Validate the trigger

    To validate the trigger, you can create an ABAP program. The following is a sample ABAP program that you can use as a reference. The ls_event_payload field changes based on your requirements:

    *&---------------------------------------------------------------------*
    *& Report ZR_TEST_INT_CONNECTOR
    *&---------------------------------------------------------------------*
    *&
    *&---------------------------------------------------------------------*
    REPORT zr_test_int_connector.
    PARAMETERS: p_auth TYPE char1 RADIOBUTTON GROUP rbg1 USER-COMMAND uc DEFAULT 'X',
     p_apik TYPE char1 RADIOBUTTON GROUP rbg1.
    DATA:
     lv_p_projects_id TYPE string,
     lv_p_locations_id TYPE string,
     lv_p_connections_id TYPE string,
     ls_input TYPE /goog/cl_connectors_v1=>ty_103.
    TYPES: BEGIN OF event_payload,
     event_type TYPE string,
     event_id TYPE string,
     name TYPE string,
     org_id TYPE string,
     END OF event_payload.
    DATA: ls_event_payload TYPE event_payload.
    ls_event_payload = VALUE #(
     event_type = 'create-entity'
     event_id = '1'
     name = 'demo-org'
     org_id = 'SAP'
     ).
    TRY.
     IF p_Auth = abap_true.
     DATA(lv_client_key) = 'IC_DEMO_GOOGLE_AUTH'.
     lv_p_connections_id = 'conn-event-triggers-from-sap-erp'.
     ELSE.
     lv_client_key = 'IC_DEMO_GOOGLE_APIK'.
     lv_p_connections_id = 'conn-event-triggers-from-sap-erp-apik'.
     ENDIF.
    * Open HTTP Connection
     DATA(lo_client) = NEW /goog/cl_connectors_v1( iv_key_name = CONV #( lv_client_key ) ).
    * Populate relevant parameters
     lv_p_projects_id = lo_client->gv_project_id.
     lv_p_locations_id = 'us-central1'.
     GET REFERENCE OF ls_event_payload INTO ls_input-payload .
    * Call API method: connectors.projects.locations.connections.listenEvent
     CALL METHOD lo_client->listen_event_connections
     EXPORTING
    
    
    iv_p_projects_id = lv_p_projects_id
     iv_p_locations_id = lv_p_locations_id
     iv_p_connections_id = lv_p_connections_id
     is_input = ls_input
     IMPORTING
    * es_raw =
     es_output = DATA(ls_output)
     ev_ret_code = DATA(lv_ret_code)
     ev_err_text = DATA(lv_err_text)
     es_err_resp = DATA(ls_err_resp).
     IF lo_client->is_success( lv_ret_code ).
     MESSAGE 'Success' TYPE 'S'.
     ELSE.
     MESSAGE lv_err_text TYPE 'E'.
     ENDIF.
    * Close HTTP Connection
     lo_client->close( ).
     CATCH /goog/cx_sdk INTO DATA(lo_exception).
     MESSAGE lo_exception->get_text( ) TYPE 'E'.
    ENDTRY.