Example of using Run standard workflow from SAP BAPI package

Using the Run standard workflow action from the SAP BAPI package, build a bot that retrieves data from SAP systems.

Prerequisites

Download the SAP Java connector and DLL from the SAP website.

In this tutorial, you will build a bot that uses the Run standard workflow action. The Run standard workflow action provides a user interface that enables you to select BAPIs and configure the parameters for the selected BAPI.

By using this single SAP BAPI package action, you will perform the following actions:

  • Select a BAPI (BAPI_FLIGHT_CHECKAVAILABILITY) from a list of function modules available in the connected SAP system.
  • Set values for the import and export parameters of the selected BAPI.
  • Assign retrieved structure or tables to dictionary or table variables.

When executed, the bot gets flight availability data based on the input data, and writes it to a CSV file.

Procedure

  1. Create a bot named SAP-BAPI-CheckFlightAvailability.
    1. Log in to the Control Room.
    2. On the left pane, click Automation.
    3. Click the Create a bot icon.
    4. In the Name field, enter SAP-BAPI-CheckFlightAvailability, and click Create & Edit.
  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 dependency, specify the path to the DLL file.
    3. Choose Custom Application Server as Connection Type.
    4. In Application server host name, specify the host name of the SAP application server.
      Note: 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 user name.
    11. In Password, enter your password.
    12. Run the bot to test the connection.
      If the specified connection properties are correct, the bot is executed successfully.
  3. From the Actions panel, find SAP BAPI > Run standard workflow action after the Connect action.
  4. Select a BAPI.
    1. Click the Select workflow option.
    2. In the Standard BAPI Selector window, from Select Standard BAPI, expand SAP Modules.
    3. Find and expand Flight with connection data (SAP training).
    4. In Flight with connection data (SAP training), expand General > Create, select BAPI_FLIGHT_CHECKAVAILABILITY, and then click Select.
  5. Specify values for the fields in the import parameter. Do the following in Import to BAPI:
    1. Click the vertical ellipsis option for the AIRLINEID field, and select Edit.
    2. In Value, enter DL and click Apply.
    3. Click the vertical ellipsis option for the CONNECTIONID field, and select Edit.
    4. In Value, enter 1699 and click Apply.
    5. Click the vertical ellipsis option for the FLIGHTDATE field, and select Edit.
    6. In Value, enter 20170418 and click Apply.
      The Java connector for SAP systems takes the date values in the yyyymmdd format.
    BAPI_FLIGHT_CHECKAVAILABILITY returns data in the AVAILABILITY export parameter, which is of the type structure.
  6. In Export to BAPI, perform the following steps:
    1. Click the ellipsis option for the AVAILABILITY field.
    2. On the Availability window, select the Field name check box to select all fields within the structure, and then click Apply.
  7. Store the data that the BAPI exports to a variable.
    1. In Save exported structures and scalars, create a variable by clicking (x) and name it ReturnStructure.
  8. In Save exported structures and scalars, create a variable by clicking (x) and name it ReturnStructure.
  9. Save the Run standard workflow action.
  10. Convert the exported data to a table.
    1. From the Actions panel, find Dictionary > Get action, and add it after the Run standard workflow action.
    2. Click inside Dictionary variable and select ReturnStructure.
    3. In Key, enter AVAILABILITY.
    4. In Assign the output to variable, create a variable by clicking (x) and name it Availability.
  11. To write the data from the retrieved table to a CSV file, add the Data Table > Write to file action.
    1. In Data table, select Availability.
    2. In Enter file name, specify the path to the CSV file, to which you want to write the data.
    3. Select Create folders/files if it doesn't exist.
    4. Click Overwrite existing file.
  12. Save and run the bot.