Build a SAP Intelligent RPA 2.0 bot with Cloud Studio to execute a transaction in the ERP
Hello! In this blog post you’ll find out a quick way to build a custom SAP Intelligent RPA bot taking advantage of the latest 2.0 version release, where you can build bots using the Cloud Studio and exposing your project in a simpler way to your environment.
In this quick exercise, I’ll showcase how to run an ERP transaction (by creating a Business Partner) using the SAP Gateway Demo System, so you can also build it.
It is important to highlight that one key differentiator SAP Intelligent RPA has, it’s the Business Content with bots already built for executing many business transactions in the ERP (ECC and S4HANA). The purpose of this exercise is for you to get your hands on with the new Cloud Studio and learn how to build your own bots.
- Follow this tutorial to create an account on the SAP Gateway Demo System.
- Create a SAP Intelligent RPA trial account here. If you already have a SAP Cloud Platform trial account, you’ll just need to enable the service in the subscriptions tab and assign the Roles/Role Collections to your user, watch this video for more details.
- Download the latest Desktop Agent version (2.0.6) here and install it in your computer.
- Free Trial for SAP Intelligent Robotic Process Automation (RPA) link.
- SAP Intelligent RPA 2.0 – Today is THE day: Join the future of automation! link.
So let’s start 🙂
Now set up your Agent, and create a New agent group (set a name and select Machine as type). I named mine “Agent Group MMQ”.
After clicking on it, you need to Create a node (click on the + sign). Put your machine ID (device name) and a label.
For more information about Agent and Agent Groups, check out the documentation here.
Now you should see your Agent with a ready or idle status.
Go back to your environment (Test Env) and add the Agent (if not already).
Now, to access your Cloud Studio, first you need to create a Project. Go to the Project’s tab and create one, then click on it. I named mine “SAPES5 Gateway Demo System – ERP”.
Now, you first need to create an application (see image below at the top-left side, click on create and then application), which in this case is going to be the SAP Gateway Demo System. You need to capture the screens you want the bot to interact with.
In this case as I’m building a bot to create a Business Partner in the NetWeaver system, I need to capture at least 4 screens.
- SAP Log On to authenticate myself,
- SAP Easy Access to run the “BP” transaction,
- Maintain Business Partner to select “Person” to create a new one and,
- Create Person to fill out the Business Partner’s data and then save it.
It is important for you to know that in order to capture correctly the screens, the application should be open in a different window. In my case I used Google Chrome as the browser to run the Gateway Demo System instance, however you could also use Internet Explorer.
Some trick: if you use Chrome it is possible that you’ll need to check the Disable AutoScroll option in order to capture correctly the screen.
As you may see, the URL doesn’t change when navigating through different screens, that’s why you need to put more captured data as criteria to uniquely identified each screens within your application. By default, the criteria is going to select the “equals” condition, but you can change it by clicking on it.
Criteria defined for each captured screen:
- SAP Log On:
- SAP Easy Acces:
- Maintain Business Partner:
- Create Person:
After doing this, you need to Declare the Elements that you need in order to run your bot per each captured screen. See this image below for the Log On screen.
I declared 3 elements (User, Password and the Log On button). Keep in mind that as more criteria you give to your element, it is going to be more accurate. It is important for an element to be uniquely identified.
You can change the Element Class, whether if it is an input, checkbox, button, etc. Also, when selecting the elements through the screen, it is important to check in the HTML body that you’re selecting a clickable HTML element. In this case you can see how the User Name is identified as an Input in the HTML tree (to see this view, change the above view to “Both”).
You can also check out the specific ID by inspecting the HTML elements in your browser.
When you’re done declaring them, now let’s see the element declaration for the transaction input in the main menu of the system (SAP Easy Access screen):
Now when accessing to the transaction in the Maintain Business Partner screen, see how the element class for the Person’s button is different:
Here (Create Person screen) I declared more elements, however for this exercise we are going to focus in the main ones (Business Partner’s First and Last Name).
After you’re done declaring the elements, now what you need to do is to create an Automation (click on create at the top-left of your screen and select automation). I named mine “Create Business Partner”.
Here I already selected the first screen (Log On), just drag and drop it inside the workflow:
Now for each screen, you need to set up each activity. As it is a web application, you first need to start with the activity “Start Web Page“.
Here I have the whole workflow already set up and as an Input Parameter, I’m selecting Chrome as the browser where I want the bot to run the application. For this you have to click on the “pen” sign and copy this line: irpa_core.enums.navigator.Chrome
As you can see, the following activities in general have a Wait Element activity before setting their values, Why? Because the bot needs to wait until the element is correctly loaded in the application before setting their values.
For this exercise, as it is just a test, I’m setting my credentials as values. However, the proper way to do this in “real life” is to create Variables in the settings restricted for your Environment.
The Keystroke simulates pressing a Key in your keyboard. In this case instead of clicking the Log On button, I’m setting an Keystroke for the Enter key to access the system. To enable it, you need to copy this command in your input parameter: irpa_core.enums.key.Enter
I do the same when confirming “BP” as the transaction I’m interested in.
First I set the element “BP”:
Then confirm it with the Enter Keystroke:
In the case of the Maintain Business Partner screen, the main activity is Click Element for the Person Button:
Now let’s use First and Last Name as the main Business Partner data needed to create it. Some trick: it is possible due to the Demo System that after setting the value it doesn’t save them properly, so a workaround that I found for this, is to set up an Enter or Save Keystroke after each value and saving the Business Partner with a F11 Keystroke (instead of clicking the save button) with this command: irpa_core.enums.key.F11
For more information about Virtual Key Functions for SAP GUI applications, check out this list.
I recommend you to keep testing your bot while you’re building it, to ensure it is working fine. To test it, you just have to click on the Test button at the top-right side of your screen.
Check out in this video the testing result:
I’ll leave the blog until this point, however in this next blog post I’ll show you how to deploy your bot to your test environment and where to set up the triggers.
I hope you’d enjoyed this exercise 🙂