Skip to Content
Product Information
Author's profile photo Ankit Somani

SAP Intelligent RPA 2.0 – How to execute BAPI

Introduction:

In this blog post I would like to introduce you to the BAPI SDK which is available with the September release (2109) of SAP Intelligent RPA 2.0. I will explain how to execute a BAPI from SAP Intelligent RPA using this SDK.

Let’s start off with a brief introduction of BAPI.

What is BAPI:

BAPI is a standard interface to the business object models in SAP products. In the SAP system, BAPIs are stored as RFC (Remote function call) capable function modules in the ABAP workbench function builder.

Client programs that use BAPIs to access SAP business objects can be part of the same SAP system, part of an external system (for example, a .Net application), part of an HTTP Gateway, or part of another SAP system. To execute any BAPI user needs to pass import, table and changing parameters.

You can also refer to the detailed documentation from help.sap.com if you want more details about BAPI.

What is BAPI SDK:

The SAP BAPI SDK package is a collection of activities allowing you to automate processes in SAP system by calling BAPI. SDK package consist mainly three types of activities.

  1. Set and Close SAP connection
  2. Execute BAPI
  3. Commit all transaction on SAP connection

Prerequisites:

  1. Latest desktop agent should be installed. i.e., desktop agent of SAP Intelligent RPA 2109
  2. For Set SAP Connection (SSO) SDK BAPI activity, SSO (SAP Single Sign-On) must be configured on your system

Steps to follow:

Here we are going to create Purchase requisition order using “BAPI_PR_CREATE”. It has following import, table and export parameters.



We will be using PRHEADER, PRHEADERX from import parameters and PRITEM, PRITEMX from table parameters.

  1. Set SAP connection (Basic or SSO): Use Set SAP connection (Basic/SSO) activity to set connection. Input parameters of activity can be found under properties of sap system.
  2. Create parameters of BAPI: All import and changing parameters are in form of structure(object) and all table parameters are in form list of structure(object).
    1. Create Import data type by name Import_PR (datatype name can be anything) as shown in picture.
    2. Create Table data type by name Table_PR as shown in picture
    3. Drag and drop the Import_PR data type to create an Import_PR variable and fill the values.
    4. Drag and drop the Table_PR data type to create a Table_PR variable and fill the values.
  3. Execute BAPI with above connection and parameters: Drag and drop Execute BAPI activity and fill the input parameters.
    Outputs parameter is for response of execute BAPI, user can pass comma separated parameters name. if nothing is pass in outputs then entire BAPI response will be return else provided parameters response will be returned in JSON format.

  4. Commit BAPI and Close Connection:

    This is last step of automation. In this we will commit all the transaction done on sap connection and close the connection.

Find more information on SAP Intelligent RPA:

Assigned Tags

      20 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Srinivas Rao
      Srinivas Rao

      Ankit Somani - Very nice and crisp blog post...Thanks for sharing !

      Author's profile photo Prasanth Padmanabhan Menon
      Prasanth Padmanabhan Menon

      Hi Ankit,

       

      Great blog outlining how we can call BAPIs from the cloud studio. Are there any demo bots in the bot store for this? Something similar to the dynamic BAPI bot for the desktop studio

       

      Best Regards,

      Prasanth

      Author's profile photo Ankit Somani
      Ankit Somani
      Blog Post Author

      Thank you for your kind words.

      As of now we don't have demo BOTs. Once it is available on the BOT store I will share with you.

      Author's profile photo James Farmer
      James Farmer

      Thanks for the blog - How would you structure an excel spreadsheet to match the data imports (especially the table) so that you could enter in multiple line items , or multiple new PRs to be create etc?

      Author's profile photo Ankit Somani
      Ankit Somani
      Blog Post Author

      Hi James,

      Right now, we do not have anything that can read data directly from Excel, format it and pass it into BAPI activities.

      Please use Excel activities in Cloud Studio to read excel data, manipulate the data, create corresponding data types and variables, and feed them into the Execute BAPI activity.
      Author's profile photo Sujit Kumar
      Sujit Kumar

      @Ankitsomani After manipulating the data from excel how I pass multiple line items in import table data dynamically.

      Author's profile photo Ankit Somani
      Ankit Somani
      Blog Post Author

      You can pass multiple line items in a format similar to a table parameter by reading the data as a list of JSON objects and then passing it in as an import parameter.

      Author's profile photo James Farmer
      James Farmer

      Thanks Ankit,

       

      Actually that was what I was asking about - what the best way was to manipulate the data on excel to then be able to pass it to the BAPI (via the data types)? The above example without excel worked fine for me, but when I tried to use an excel to pass the values to the the created data types,(BAPI parameters) I get errors such as "missing PR_ITEM" - yet the PR_ITEM does not have any values (on the excel) or even when we use just the data type without excel - so I'm not sure why the excel file structure doesn't seem to work, or how can you structure the excel to match the data type better etc.

       

      I was just curious if there was a best practice/method to uses the excel to match the parameters of the data types, so you could then implement a LOOP to handle all the line items and create additional line items on the PR or multiple PRs.

      Author's profile photo Ankit Somani
      Ankit Somani
      Blog Post Author

      Hi James,

      As of now, we don't have any methods/best practices for using Excel workbooks to interact with BAPI activities. We'll update this post if it becomes available.

      Current Excel activities return data in a list format, but BAPI requires a JSON data format. Therefore, data manipulation is needed. Alternatively, you can use the Excel Cloud link activity, which generates predefined data types from worksheets and returns JSON data.

      Author's profile photo James Farmer
      James Farmer

      HI Ankit,

       

      Thanks for that ... I did use the cloud link to see if I could get it to work, and I was able to have it loop and create multiple, one line purchase reqs. However, I'm not sure how you would get this to work with 1 Purchase req and MULTIPLE line items with excel? I mean, how would be able to structure to the excel to know the link items are for the one Purchase req vs. a new Purchase req?

      Author's profile photo Sujit Kumar
      Sujit Kumar

      James Farmer were to able to loop mutiple line items and pass to bapi

      Author's profile photo Gabriel Colombo
      Gabriel Colombo

      Hello, Ankit.

       

      I'm trying to use BAPI SDK with RFC_READ_TABLE function, but it is not running with the following parameters.

      I'm getting 'DATA_BUFFER_EXCEEDED is Required' error, but the process should return only 2 elements.

      I think that I am setting the parameters as you suggested, but on BAPI_PR_CREATE there are no data on Exceptions tab, otherwise on RFC_READ_TABLE we have a list of exceptions and then I don't know how to set the output parameter in Execute BAPI stage.

       

      Do you know how to help me with that?

      Best Regards.

      Author's profile photo James Farmer
      James Farmer

      Do you ever resolve this by chance? I have similar issue with a function module call, exception that the item is in the Exceptions tab etc - but I think its similar to what you are getting.

      Author's profile photo shivam shukla
      shivam shukla

      Hi ,

       

      When i am trying to follow this example  -  am getting below error any expert advice  ?

       

      Thanks,

      Shivam

      Author's profile photo Ankit Somani
      Ankit Somani
      Blog Post Author

      Hi Shivam,
      Can you please install this Microsoft C++ Runtime DLLs version 10.0 (this is contained in Microsoft Visual C++ 2010 Redistributables). You can get the MSI installer from the Microsoft download pages.
      Post that restart your system and try to execute the BAPI module again.

      Author's profile photo shivam shukla
      shivam shukla

      Hi Ankit Somani ,

       

      Thanks this is done now i am getting the new error invalid parameters from BAPI (Exception).

      I have SAP System with router string & am confused how this router string will be passed in Basic connection setup activity  ?

       

      I have posted my query on community as well.

      https://answers.sap.com/questions/13716490/consume-bapi-inside-sap-rpa-but-sap-server-is-behi.html

       

      Thanks,

      Shivam

       

       

       

       

       

       

       

       

       

      Author's profile photo Ankit Somani
      Ankit Somani
      Blog Post Author

      Hi Shivam,

      This is not supported as of now by BAPI SDK. We are working on this.
      We will let you know once it is supported.

      Author's profile photo Ankit Somani
      Ankit Somani
      Blog Post Author

      Hi Shivam,

      As of now we don't support System Router Strings while setting the sap connection .
      We are working on this.

      Author's profile photo shivam shukla
      shivam shukla

      its fine we used Odata as wrapper to overcome this problem.

      Thanks,

      Shivam

      Author's profile photo Sujit Kumar
      Sujit Kumar

      shivam shukla It works like SprounterString + /H/ApplicationServer

       

      Example: /H/54.69.83.142/H/10.0.0.186