Example of using Get structure command from SAP BAPI package
- Updated: 2022/09/21
Example of using Get structure command from SAP BAPI package
Using the SAP BAPI package, build a bot that inputs a structure to get data.
Prerequisites
Download the SAP Java connector and DLL from the SAP website.
In this tutorial, you will build a bot that invokes BAPI_FLIGHT_GETLIST from the SAP demo Flight Data application. When executed, the bot calls the BAPI function by inputting an airline ID and destination details, gets a list of flights, and writes the response data to a CSV file.
You will use the following import parameters to limit your search:
- AIRLINE: Use the parameter to pass the airline ID.
- DESTINATION_FROM: Use the parameter to get the structure and pass the city name and airport ID.
The tutorial is intended to demonstrate how to perform the following
actions:
- Get the structure of an import parameter.
- Set the values for the fields in the retrieved structure.
- Get response data in a table based on the input data.
Procedure
-
Create a Task Bot named
SAP-BAPI-FlightListReport.
- Log in to Control Room.
- On the left pane, click Automation.
- Click the Create a bot icon.
- In the Name field, enter SAP-BAPI-FlightListReport, and click Create & Edit.
-
To connect the bot to your SAP system, from the
Actions panel, find action and add it to the Bot editor.
-
To create a function, add the
action.
- In Function alias name, enter getFlightListByAirline.
- In BAPI name, enter BAPI_FLIGHT_GETLIST.
-
To filter the data by an airline name, add the
action.
- In Function alias name, enter getFlightListByAirline.
- Click the Function tab.
- In Field name, enter AIRLINE as the input parameter name.
- In Field value, enter AZ.
-
To limit the selection by the airport and the destination city, get the
structure of the DESTINATION_FROM import parameter first,
and then set values for the fields in the retrieved structure. To do this, add
the action.
-
To set a value for the AIRPORT ID field in the
DESTINATION_FROM parameter, add the action.
- In Function alias name, enter getFlightListByAirline.
- In Source, click the Structure tab.
- In Structure alias, enter destinationFrom.
- In Field name, enter AIRPORTID.
- In Field value, enter FCO.
-
To set a value for the CITY field in the DESTINATION_FROM
parameter, add the action.
- In Function alias name, enter getFlightListByAirline.
- In Source, click the Structure tab.
- In Structure alias, enter destinationFrom.
- In Field name, enter CITY.
- In Field value, enter ROME.
-
To execute BAPI_FLIGHT_GETLIST, add the action.
- In Function alias name, enter getFlightListByAirline.
-
To get the filtered data from the FLIGHT_LIST table, add
the action.
- In Function alias name, enter getFlightListByAirline.
- In Table name, click the FLIGHT_LIST tab.
- In Destination, click Variable to store the retrieved table data in memory.
- In Save the outcome to a variable, create a variable named tblFlightList by clicking (x).
-
To write the data from the retrieved table to a CSV file, add the
action.
- In Data table, select tblFlightList.
- In Enter file name, specify the path to the CSV file to which you want to write the data.
- Select Create folders/files if it doesn't exist.
- Click Overwrite existing file.
- Save and then run the bot.