SAP Screen Personas : Scripting for Automation

Jonathan Andre is a lead ABAP developer at IT Partners. Jon is also the President of Andre Technical Consulting LLC located out of Centreville, Virginia. Jon has over 6 years experience with SAP, with a concentration on ECC SD, MM, and IS-OIL modules. Jon’s focus has been in the areas of ABAP OOP and ABAP Web Dynpro. He can be reached at jon.andre@itpsap.com

The last topic for this blog series will cover Screen Personas Scripting. This is by far the most powerful feature that Screen Personas offers. Scripting allows the automated execution of steps a user can perform, and can be used to populate fields and/or carry out actions.
To illustrate exactly how scripts are created and executed, we will revisit and complete the Sales Order – Quick Query control we mocked up in the blog SAP Screen Personas: Get Up and Running Quickly Using These Steps. This time, however, we will actually create a script to populate our text fields when we click the “Go” button.

Our first step will be to add a Script Button to our tool. The Script Button can be found on the Insert Tab near the Transactional Button we used extensively in past blogs.

Next, we will create a script to perform the actions of retrieving the data we wish to populate. To do this, we will have to exit the Flavor Editor and return the to main Persona Management screen, then click the Scripting button located in the bottom right corner

From here, we will hit the Create Script button, name our Script then Start Recording. The Start Recording feature will automatically record our actions in the scripting language. Any action performed, from navigating to a transaction to clicking a certain tab or field, is documented and repeatable by executing the recorded script.

Once the recording has begun, navigate to the transaction you wish to record. In this particular scenario, we will be navigating to VA03. As we do this, we will see the script populate with code that will navigate to the T-code.

Once we arrive in the VA03 initial screen we will enter a sales order number (14642) to allow us to proceed to the next screen. Our ultimate goal, however, is that we can replace this sales static order String with any sales order the user enters into the tool. We will get around to making this possible by editing our script manually later, but for now, we will just take note of the point in the script the sales order number is entered.

In the Overview section of VA03, we spot the first piece of information that we want to be returned to our Sales Order control tool in an automated fashion. We would like to store the Sold-To party for this Sales Order. The Scripting functionality provides an automation tool that will allow us to generate the code to find the value of this or any other on-screen element by selecting it.

Before we do this though, we will pause our script recording to avoid unintentionally recording any steps.

We will then navigate to the Inspector tab and select the Object Inspector tool

With the Object Inspector tool active, we can click on any screen element to reveal its attributes in the Inspector tool. We are searching for the “text” attribute of the Sold-To party field.

From here, we can click the Pencil icon next to the “text” attribute to automatically add the “session.findById” code into our script. The value of the variable added to our script contains whatever text is currently in the field.

To store this information and allow it to be returned to the Dashboard Sales Order tool, we need to place it in our own created variable. We accomplish this by typing the following code

We will store the contents of this field in a variable named “cust”. This variable will always hold the valueof this field, regardless of the particular value or the current sales order on the screen.

With the Recording still paused, we can repeat the Object Inspector, text, and variable creation pattern for each field until we have retrieved all of the information required from this screen and tab. In the for Sales Order Query Tool, we would still want to locate the Material and Quantity from this tab.

The final field we would like to retrieve from the VA03 transaction is Delivery Status, which is not on the Sales tab, but on the Shipping tab. To retrieve this information, we click Start Recording, navigate to the Shipping tab, turn off recording, then follow the same process as above to retrieve the value.

We now have all the information required to populate our Sales Order Query tool. We can now turn the recording back on and use the back button to navigate to the dashboard. Once there, we will use the variables we created in the VA03 transaction to populate the tools fields. We will follow a similar process using the Object Inspector but in reverse. We will find the id of the text field, but this time we will populate the text using the variables we created above.

Let’s look at the code a little closer, you can see we just used or variable “cust” as the source and left the target as it was generated when we hit the red pencil inside the Object Inspector tool. We will repeat this process for all the remaining target fields, which are “del_stat”, “mat”, and “quant”. The code will look like screen-shot below:

The final step to completing our script is to ensure that we aren’t passing the hard-coded value 14642 into the VA03 order field, but instead, the order number that is entered by the customer.

To do this, we scroll to the first line of our script and use the Object Inspector to find the text value of the Order Number and store it in a variable.

We then find where the original order number of “14642” was being passed in, and instead, change the code to pass in the value of our order variable “order”. The // you see is commenting out the line where we pass in the hard-coded value of “14642”.

Save your changes by hitting the “Save All Changes” button at the stop of the Scripting tool (which looks like an arrow going into a box). It is also a good time to Validate/Execute your script to check for bugs. Once completed, the last and final step is to attach our script to the “On Click” event of our Go button.

This is achieved by exiting the Script editor, opening the Flavor Editor, and selecting the Go button of our tool. Once selected, we navigate to the Insert tab and select the dropdown next to Scripting Events. The Scripting Events dropdown shows all possible events tied to a particular object. In this buttons case, the only available event is On Click. Appearing next to the On Click event will be a search field allowing you to search for scripts that are applicable to this event. Here I selected SO_LOOKUP, which is the script that was just created above.

We can finally give our new tool a test and should be pleased with the results. Enter in the Sales Order number of your choice and click the GO button!

Summary

Scripting is obviously a very powerful tool that can greatly simplify system interactions for the user. The example created a tool utilize scripting, but scripting can be used to populate standard fields on the screen as well, eliminating user error where values are known beforehand. The potential events that can be used go well beyond just clicking too. When a window or user area is loaded, refreshed, or even resized, a well-written script can automatically trigger field population, highlighting, or formatting to using specific logic improve the users experience.

SAP Screen Personas has a lot to offer in terms of improving the users experience with the system. It allows the robust SAP catalog of business software to be paired with a robust and customizable UI that is truly only limited by the users imagination.

Below are some links to help and a SAP Community WiKi on the subject. Cheers!

If you enjoyed this blog, SAP Screen Personas : Scripting for Automation, please fill out the form below to sign up for our newsletter. We deliver SAP Technical tips & tricks, SAP news, and the current month’s BLOG right to your inbox!

Related Posts

Gallery image with caption: 10+ New Features in S4HANA Finance Group Reporting 1909

Gallery image with caption: How a Platform Technology like BPM Can Accelerate Your DX Journey

The tools of the New ABAP Debugger are optimized for the different debugging situations you may have to deal with during the course of solving a problem. Some of the tools you will recognize from the Classic ABAP Debugger; others are brand new. Before we look at a few of the tools and how to use them, lets first get comfortable with the tools menu and how the tools are organized.

With all their new features, the latest versions of the ABAP Editor, I thought it best to appreciate the new features; we should first go back in time to see some of the limitations that were present in prior versions of the editor.

SAP NetWeaver 7.0 (formerly 2004s) offers the new Enhancement Framework that not only is intended to unify the modification and classic enhancement techniques, but also offers you almost the same flexibility as modifications without the limitations of modifications.

In contrast to enhancements in the Enhancement Framework, modifications are physically part of the object they modify. This means that every single modification gets lost in an upgrade and needs to be re-inserted even in cases where the underlying SAP object has not changed at all!

In all the aspects, enhancements are more powerful than modifications, even given all the modification support that transaction SPAU offers. The reason is due to an important difference between an enhancement and a modification that stems from the conceptual difference between the two technologies.

In addition to the new kernel-based BAdI, there are many other types of enhancement options that are part of the new Enhancement Framework. You implement these enhancements using the Enhancement Framework tools, which are integrated into the ABAP Workbench

No matter if you create an enhancement point or a BAdI as an enhancement option provider, or if you implement an existing enhancement option (be it implicit or explicit), what you create must fit into the structure of the Enhancement Framework in a way that enables you to collect and organize the enhancement options and their counterparts on the implementation side.

The Controls Technology Framework resides on the application server (the back-end), and the Automation Controller sits on the presentation server (the front-end). The integral component that optimizes the communication between the two is the Automation Queue.

The ALV Grid Control solves this problem. Its user interface provides a set of generic functions (e.g., sorting, filtering) for handling tabular data. It also confers the many benefits of controls technology to users, enabling more operations by mouse, and interaction with other controls, such as drag-and-drop. Developers simply plug the ALV Grid Control into their applications and the tool takes care of the rest. You do not need to do any further programming to offer users these functions. How you “plug” the control into an application is the first thing I will show you in this month’s blog. So lets get started!

he key to configuring the ALV Grid Control for your particular application is the structures that are passed by the application to an ALV Grid instance before or during list display. For some simple extensions of your ALV Grid instance, you only need to set the right parameter and pass the table or structure by using method set_table_for_first_display.

Adding new GUI elements to an ALV Grid instance is event-controlled and requires experience in ABAP Objects event handling. There is an event for each element type (toolbar push button, toolbar menu, and context menu). In the relevant event handler method, you define the properties of an element (such as its menu options) and assign a function code to each executable function.

What is web Dynpro? It’s SAP’s newest user interface (UI) development option for the SAP NetWeaver platform — has been designed to become the de facto option of choice for SAP development. Web Dynpro was created because, like every other software vendor in the Web space, SAP needed a longterm, strategic solution for the many problems faced by Web developers during the implementation of browser-based business applications.

Pin It on Pinterest

Share This

THIS WEBSITE USES COOKIES: By clicking "Accept", you agree to the use of cookies and similar technologies to enhance your browsing experience, and analyze your engagement with our content. Read our Privacy Policy.