使用 SAP BAPI package,构建一个输入结构以获取数据的 bot

先决条件

Download the SAP Java connector and dynamic library files (.dll file for Windows automation and .dylib file for macOS automation) from the SAP portal.

在本教程中,您将构建一个从 SAP 演示航班数据应用程序调用 BAPI_FLIGHT_GETLIST 的 bot。 执行时,bot 通过输入航空公司 ID 和目的地详细信息调用 BAPI 函数,获取航班列表,并将响应数据写入 CSV 文件。

您将使用以下导入参数来限制您的搜索:
  • 航空公司: 使用该参数传递航空公司 ID。
  • DESTINATION_FROM: 使用该参数获取结构,并传递城市名称和机场 ID。
本教程旨在演示如何执行以下操作:
  • 获取导入参数的结构。
  • 设置检索到的结构中的字段值。
  • 根据输入数据以表格形式获取响应数据。

过程

  1. 创建一个名为 SAP-BAPI-FlightListReportTask Bot
    1. 登录到 Control Room
    2. 在左侧窗格中,单击自动化
    3. 单击创建机器人图标。
    4. 名称字段中,输入 SAP-BAPI-FlightListReport,然后单击创建和编辑
  2. To connect the bot to your SAP system, from the Actions panel, find SAP BAPI > Connect action and add it to the Bot editor.
    1. In JCo: SAP Java Connector package, specify the path to the Java connector .jar file.
    2. In JCo DLL/DYLIB dependency, specify the path to the dynamic library file.
      .dll for Windows automation and .dylib for macOS automation.
    3. Choose Custom Application Server as Connection Type.
    4. In Application server host name, specify the host name of the SAP application server.
      注: As a best practice, use the Credential Vault to specify sensitive information such as host name, user name, and password.
    5. In System number, enter the instance number.
    6. In SAP instance system ID, enter the system ID.
    7. In Client number, enter the client number.
    8. In Logon language code, enter EN or the language specific to your system.
    9. In Router string, enter the SAP router string.
    10. In Username, enter your SAP username.
    11. In Password, enter your password.
    12. Run the bot to test the connection.
      If you specify the correct connection properties, the bot executes successfully.
  3. 要创建一个函数,请添加SAP BAPI > 创建函数操作。
    1. 函数别名中,输入 getFlightListByAirline
    2. BAPI 名称中,输入 BAPI_FLIGHT_GETLIST
  4. 要按航空公司名称筛选数据,请添加SAP BAPI > 设置字段值操作。
    1. 函数别名中,输入 getFlightListByAirline
    2. 单击功能选项卡。
    3. 字段名称中,输入 航空公司 作为输入参数名称。
    4. 字段数值中,输入 AZ
  5. 要通过机场和目的地城市限制选择,首先获取 DESTINATION_FROM 导入参数的结构,然后为检索到的结构中的字段设置值。 要做到这一点,请添加SAP BAPI > 获取结构操作。
    1. 函数别名中,输入 getFlightListByAirline
    2. 结构名称中,输入 DESTINATION_FROM
    3. 要将检索到的结构分配给别名,请单击别名选项卡中的目的地,然后在创建结构别名中输入 destinationFrom
      您现在可以使用别名为检索到的结构中的字段设置值。
  6. 要为 DESTINATION_FROM 参数中的 AIRPORT ID 字段设置一个值,请添加SAP BAPI > 设置字段值操作。
    1. 函数别名中,输入 getFlightListByAirline
    2. 来源中,单击结构选项卡。
    3. 结构别名中,输入 destinationFrom
    4. 字段名称中,输入 AIRPORTID
    5. 字段数值中,输入 FCO
  7. 要设置 DESTINATION_FROM 参数中 CITY 字段的值,请添加SAP BAPI > 设置字段值操作。
    1. 函数别名中,输入 getFlightListByAirline
    2. 来源中,单击结构选项卡。
    3. 结构别名中,输入 destinationFrom
    4. 字段名称中,输入 CITY
    5. 字段数值中,输入 ROME
  8. 要执行 BAPI_FLIGHT_GETLIST,请添加SAP BAPI > 运行函数操作。
    1. 函数别名中,输入 getFlightListByAirline
  9. 要从 FLIGHT_LIST 表中获取过滤后的数据,请添加SAP BAPI > 获取表操作。
    1. 函数别名中,输入 getFlightListByAirline
    2. 表格名称中,单击 航班列表 选项卡。
    3. 目标中,单击变量以将检索到的表数据存储在内存中。
    4. 将结果保存到变量中,通过单击 (x) 创建一个名为 tblFlightList 的变量。
  10. 要将检索到的表格数据写入 CSV 文件,请添加数据表 > 写入文件操作。
    1. 数据表中,选择 tblFlightList
    2. 输入文件名中,指定要写入数据的 CSV 文件的路径。
    3. 选择创建文件夹/文件(如果不存在)
    4. 单击覆盖现有文件
  11. 保存然后运行 bot