Skip to Content
Technical Articles
Author's profile photo Peter Engel

SAP Intelligent Robotic Process Automation 2.0: SAP GUI Table Control (2/2)

In my previous blog post. SAP Intelligent Robotic Process Automation 2.0: SAP GUI Table Control (1/2) you learned how to fill in data into a GUI table control.

In this blog post you will learn how to read data from a table based on SAP GUI Table Control. These controls are used in transactions like ‘Create Sales Order’ or ‘Create Purchase Order’. I will show you the activities you need and how to create a list to work with the extracted data in the automation.

The complete automation executes the following steps:

  1. Create a variable to store the data
  2. Get the number of rows to read
  3. Loop over the table
  4. Get the position data
  5. Get the material data
  6. Get the order quantity
  7. Get the unit
  8. Add the extracted data to the variable
  9. Scroll on line down
  10. Loop over the list
  11. Write a log with the position data

Create a Data Type

After we extract the data we want to keep them in a table to use the data later in the automation. To achieve this we have to create a data type. We can create a data type by clicking on the create button and select ‘Data Types’.

Then we add four fields to the data type, one for each entity. We use for each field the type ‘String’.

For more information on Data Types refer to the SAP Intelligent RPA Cloud Studio User Guide.

Screen Capture

For this exercise we capture the overview screen of the transaction VA03. For the details how to declare the elements read my blog post SAP Intelligent Robotic Process Automation 2.0: SAP GUI Table Control (1/2).

Read the Data

As the number of rows in a table is dynamic we need the number of rows which have data. To get this value we use the ‘Get Scroll Max (GUI Table)’ activity. The target of this activity is the table itself. As output we get the parameter ‘result’ with the maximum value up to which scrolling is possible for the table.

With this information we are able to create a loop with the ‘Repeat’ control. The starting value is 0 as the index for the rows in the table starts with 0 and the ending value is the ‘result’ from the ‘Get Scroll Max’ activity. In my example the sales order has 18 positions so the value of the ‘result’ variable is 17.

In this loop we include four ‘Get Element’ activities to get the position, the material, the quantity and the unit for each row. The target for the position is the item with the index 0. As we work during the whole loop on the first row we can use this as a fix value. As output we get the variable ‘text’.

To select the target we can click on the button right to the target input field and select ‘Item’ and set the ‘Index of the element’ to 0.

At the end of the loop we scroll down the list by one row using the ‘Scroll Down (GUI Table) activity.

The result of this step is that we can have always the current row in the first line with the index 0.

Add the Data to the List Variable

After the successful extraction of the data we have to store them in a variable for further use in the automation. To create a list of our data type we go to the ‘Data’ section and select our ‘VA01Pos’ data type and position this activity as the first step of our automation.

We open the activity and tick the checkbox for the ‘List’ option. On the left side we can see the option to enter data here but we we keep the list empty.

The output parameter of this activity is ‘myVariable’ which is a list based on our data type ‘VA01Pos’.

As we have now the data and the variable we can use the ‘Add item’ activity to add the extracted data to the list. For the input parameter ‘list’ we select the variable form step 1 which is ‘myVariable’. Then we define the items we want to add and where the values come from which is in this case the output of the steps 4 – 7.

As a result we get all data in a list which we can use for further activities in the automation.

Work with the Data

One example to work with the list is the ‘For each’ control which allows us to execute activities on each row/element of the list. The parameters are ‘Set looping list’ which is in our case ‘myVariable’. The ‘Loop Parameters’ ‘currentMember’ and ‘index’ are defined by the application.

To use the data from the list we can select the values of the ‘currentMember’ parameter using the ‘Expression Editor’.

Conclusion

Now we have learned how to read data in a SAP GUI table control without knowing how many rows we have and to prepare the data for further use in the automation This example will be useful in many scenarios we have when we implement automations with SAP Intelligent RPA.

For more information on SAP Intelligent RPA

 

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Kamil Jamrozik
      Kamil Jamrozik

      Thanks Peter for this excellent blog post, it helped me a lot with my table content automations.

      I have one comment/suggestion in case of any data modifications in the table. When you set one of the fields in Change mode and hit Save button, this is moving me back to the top scroll position in the table (probably default setting in my SAP).

      In this particular situation it seems more error-proof and precise to use Scroll To [position - index from Repeat] rather then just Scroll Down from GUI Session. In my opinion, Scroll Down might accidentally jump into the infinite loop or skip one of the records by mistake.

      FYI, I'm using ECC, happy to see more posts like this, using all kinds of loops, the bread and butter of all automations for me!

      Author's profile photo Sergei Kandrashin
      Sergei Kandrashin

      Peter, good time!
      Your post is what I need. Very visual and detailed. But I ran into a problem after adding the steps (1)" Add data to a list variable "and (8)"Add Item". Without them, in the loop, all data is read normally, but after adding (1) and the addItem (8) method returns an error: “automating the "LogView" content is not valid.”
      !!!"LogView" is the name of my automation.
      I tried several times, from the very beginning, with a different number of fields and rechecked all the values and variables specified in the post, but after ""Add Item", an error always appears.
      Tell me, what could be the problem?
      Thanks!

      Author's profile photo Peter Engel
      Peter Engel
      Blog Post Author

      Hi,

      please contact me via community mail, so we can exchange the projects.

      Br,

      Peter

      Author's profile photo Sergei Kandrashin
      Sergei Kandrashin

      Hello, Peter!
      I sent you an example of my project by email yesterday.

       

      Sergey