Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Former Member

The thing I find most exciting about SAP Screen Personas is the scripting capabilities. I see so much potential there for automation, although admittedly not all of it is realisable with the current version. I hope future versions will enhance the scripting features. In this blog I want to go through one of my scripts in some detail, which I hope will give you a good idea of what can be achieved. Scripts are recorded through the personas interface and attached to a "script button", so that pressing the button activates the script. For the developers among you, a Personas script is essentially a BDC session except that it can be enhanced to interact with Personas-specific gui elements. You'll see this in the example below. Let's start with my logon screen:

Notice the "Users" section. There's a text field labelled "Username", a "Lookup" button and a field labelled "Name". The intention, obviously, is to type in a username and lookup the user's real name. The script does this by calling transaction SU01 and grabbing data from it. This all happens in the background and the user isn't aware of it at all. All you see is the real name appearing. Let's look at the script step by step:

First we "refresh" the screen. I confess I'm not clear what's going on here, but when you copy values from screen fields a refresh is usually required. This is one of those things you "just do", and it will appear later in this script too. Then we copy the contents of the field called "Personas/..." into a variable called "username". These variables can be created at will and exist just for the lifetime of the script. Next we run SU01 and paste the username we just copied into the appropriate field on the first screen of that transaction. In step 6 we press the "Display" button. We're now at the point where the user's name is visible in SU01.

Steps 7-9 grab the first name and last name from the screen and save them for later. Remember we need the "refresh" before copying anything from the screen. Now for the clever bit.

First we navigate back to the login screen (press "Back" twice - I sometimes use "/n"). I wanted to present the name in a single field rather than in two, but Personas scripting has no string manipulation functions. Fortunately you can add Javascript to a Personas script, and that Javascript has access to all of the Personas script variables. So in step 12 I do some string concatenation before finally, in step 13, putting this calculated value into the relevant place back on my logon screen. After all this I now have a simple "who is this" function on my logon screen. No need to run any transactions, and while the script is running I don't see any of the steps happening and so I'm unaware that SU01 is even involved. In use, it looks like this:

You can use scripting like this to bring data from multi-screen transactions together in one place. You can also use it to chain transactions together - replace the "save" button in one transaction with a script that performs the save and then automatically executes a follow-on transaction. I'm sure I'll come up with many other uses for it as our Personas project unfolds.