Skip to Content

Personas scripting overview

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.


You must be Logged on to comment or reply to a post.
  • Hello,

    I’m searching for a detailed documentation for this scripting.

    Has anyone an idea where to find a documentation or more detailed info about the actions?

    I’m a beginner with SAP Screen Personas.

    Thanks and Regards

    Michaela Joa-Möhres

    • There are lots of snippets of information, much in video form, here on SCN and over on the SAPScreenPersonas Wiki. It isn’t straightforward to find, though. I’ve made the same comment about the need for comprehensive scripting documentation. I don’t know if/when something will appear, though.

      In the meantime, if you have questions post them here in the SAP GUI space and I’m sure someone will try to answer them. I certainly will if I can, although I’m pretty new to it myself 🙂


  • Hi Steve,

    This is a great blog. I am also excited about the scripting in Personas. I’ll blog soon on the script I use to run 4 transactions to created the skeleton classes for OData development. It takes a 15 minute process and does it in seconds.



  • Hi Steve,  I’m curious, once you capture information and store it in a variable, is there a way to look at the contents of that variable without having to paste it into a field first?

    For example,  in C# I would store user input into a variable
        firstName = “Steve”;

    Then I could use an IF to look at the firstName variable and decide what to do next.

        IF(firstName == “Steve”)

            lastName = “Rumsby”;

    Is there any such check in Personas?  It seems like you can only look at the contents of a control and not the contents of a variable.  In order to check what I have stored, I have to paste it into something like a label first, and then perform my IF on the label.

    I can post some screenshots of what I’m trying to do if this isn’t clear.

    Any insight you have would be appreciated!

    • Hi Cheryl,

      If you have the latest note implemented, then you can reference any variable with args.variable in place of control id and use it in if condition.

      Example below:




      • Hi Sushant,

        Can you please review this code snippet and suggest what is wrong with IF condition comparing variables i & limit?

        Everything else is working fine. I am comparing two variables. limit is set to 5 and i will be incremented very time I click the Script button. Their values are assigned to two screen labels and value of i is updated every time it changes. When i becomes 5, I should see label Limit Reached. But what I see is Limit not Reached in any case.

        I will paste the relevant code image as I don’t see any option to upload text files from my laptop. I have combinations like args.i equals args.limit, i equals limit, args.i equals limit but no use. Might be a minor mistake, so apologies in advance.

        IF comparison issue.PNG



        IF comparison issue.PNG
      • Hi Sushant,

            Thanks for this example, this should help reduce a number of calls to subsequent scripts in various scenarios. 🙂

        But not sure with which note this functionality came in, as we are yet to apply lastest note – 1965691. When I verified this on our system it already works which we did not make use of it thus far 😯 . Wondering where to look for on more specifications of symptoms(which are a bit generalized) or the new features introduced with notes ?



        • Hi Geetha,

          Well we do not add any new features in between SPs, but as you know we had a shiny new scripting engine with SP03 which gave us capability to include args.variable handling  🙂

          It was introduced probably 2-3 notes after SP03. And yes, you are right, we should have posted this somewhere. Will take care of it.

          Best Regards,


  • Steve,

    I am fairly new to personas and don’t have a lot of information on scripting. 

    Can you provide help on the following:

    I created a new flavor from tcode VA22 -> Header -> sales tab.  I want to move Shipping condition (VBAK-VSBED)field  which is on the Header-> Shipping tab to my new flavor.  What does a script like that look like?


    Pam Newberry

    • I don’t think you need a script for that. I think this is straightforward tab merging and is described in this document – SAP Screen Personas 2.0 – How to merge tabs. I say think because we don’t use quotations so I can’t test this, but the screen looks very similar to the sales order screen which I can test…

      If you turn on tab caching and cache at least the Shipping tab, then you can move any fields from that tab to another within the tab set. The simplest way to do that is to go into edit mode while viewing the Shipping tab and drag the field and its label off the tab onto the main screen. Then drop out of edit mode, switch to the sales tab, re-enter edit mode and drag the field into its new location.

      Let me know if you need any more help with this.

  • Hi,

    I’m looking for scripting documentation, about a question How managing (capture and request in IF condition) options in a Dynpro

    I’ll really preciate any answer