Welcome to the third edition of SAP Screen Personas series. In the first blog, we introduced the SAP Screen Personas and in the second blog, we saw how can we manipulate the screen layout and screen enhancements with SAP Screen Personas. In this blog, we will introduce and try to understand the Scripting in SAP Screen Personas.
If you are like me, you would be already impressed with SAP Screen Personas (referred as Personas hereafter) but Scripting tool is the most powerful tool in Personas’ arsenal. As evident, Scripting allows a developer to write scripts (programs) which can then be used to automate several steps leading to maximum productivity. Let’s see how we can add “scripts” in Personas:
In order to add the scripts, you need to go into the flavor and click on the scripting tool.
It will open a scripting window at the bottom of the screen. Now it is disconnected from the flavor navigation but still part of the flavor. This means you can navigate to other transaction which makes scripting a very powerful tool.
For writing a script, you can write it from scratch or can use various tools at your disposal which can accelerate the coding process. One of them is the Recording Tool. The concept is similar to macro recording in the excel – so after pressing “Start Recording”, Personas will capture each click on the screen along with the element where the action was performed and put it in the script in the sequential fashion – until you press stop recording.
Here we will take a very simple example. In this example, we are automating a simple step. In the SAP initial screen, we will provide a user with an option to go to the Technical Setting of a database table. If you break down the steps
- Enter transaction SE11.
- Enter the table name.
- Click on Display button.
- Click on Technical Setting.
If suppose a user’s job is to just enter the Database table name and record Size Category of the table then we are saving a lot of time for that user. First, he can reach the desired information in a single click and he does not even have to remember the transaction. If applied correctly for a client, this could mean an increase in productivity. Below is a script which was recorded doing exactly the same thing.
If you notice here, recording stores the MARA as hard coded value. If we want to allow a user to enter the table name, we can easily create a dashboard for the user in the SAP initial screen, by adding a label, a text field and a script button.
You can extrapolate this design to achieve a dashboard transaction, designed for a specific role (knock knock Fiori Launchpad) and the user does not have to remember any transaction. In order to capture the user entry, we can define a variable and use the inspector tool to click on the text field and use the text entered there as input. Below is the same script modified to take the user input.
Now, since this blog is meant to be an ABAPer’s take on Personas, let me add my perspective. I have done java scripts in my college days – which was in my past life and I was still able to read and fairly understand the code. Recording tool does provide me quite a code and I need to tweak things in the code. Obviously, you need to learn a little more about scripting to trap the errors and perform more functions in the scripts but it can be easily done. If you compare the ABAP and Personas Script’s commands you will find that it is evident that Personas has no connection with the database. It is recording the input and performing actions on the top of the SAP GUI so you need to be careful about the performance (I will cover this in the next blog).
12 var table = session.findById("wnd/usr/txtPersonas_1492452065680").text;
For example – the variable table is specific text entered in a particular screen element. It is not something which you can find without having that text element present on the screen. Each and every element on the screen has a name. A table control has a name and a row and column to identify the cells. It will not be as coding in the ABAP but it is high time to come out of the comfort zone.
In the script, all the logical statements for example – IF and Loops are acceptable but since it is just the front end, you cannot write select statements – Or can you? If you want to know, tune into the next installment.
As usual, please let us know whether you liked this one or not. Post feedback and questions and share it with your friends if you find this helpful. Please also mention any Personas related topic in which you are interested or let me know how can I make it better in next installments.
Some Popular Tutorials in SAPYard
1. ABAP for SAP HANA Tutorials
2. ABAP Web Dynpro Tutorials
3. GOS Tutorial
4. OOPs ABAP Tutorial
5. HANA Tutorial
6. SAP Netweaver and OData Tutorial
7. SAP Adobe Form Tutorial
8. SAP Fiori Tutorial
9. SAPUI5 Tutorial
10. SAP Screen Personas Tutorials