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:
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.
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 🙂
Steve.
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.
Regards
JohnA
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:
Regards,
Sushant
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.
Thanks
Abhi
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 ?
Regards,
Geetha
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,
Sushant
Thank you for the tip! Can you give me the number of the latest note? I will have Basis look to see if it is implemented.
~ Cheryl
Hi Cheryl, you can find the relevant notes here:
http://scn.sap.com/community/gui/blog/2013/08/28/sap-screen-personas--how-to-configure-the-system-troubleshooting-faq
Regards,
Sushant
Awesome, implementing that note fixed the issue. However, something else unexpected has happened.
I’m working on a screen that has different fields that get filled in by different buttons. Before that note, I could click buttons independently and the data would fill in and STAY filled in when I clicked other buttons.
Now, each time I click a button, the information that was previously retrieved by other buttons gets erased.
Is anyone else having this issue? Was this 'screen-clearing' also part of the most current note?
~ Cheryl
This certainly doesn't happen to me and I also have the most current note installed. Could you tell us a little more about what the scripts on the buttons are doing? That might help figure out the problem. If they're not too long, post them here (screen grabs is the best way).
Steve.
Please go here for followup posts regarding this issue:
http://scn.sap.com/thread/3489351
hi Cheryl,
Could you please start a new discussion thread and also post you script there (including video)?
You can export your script in a text file and upload there.
Best Regards,
Sushant
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?
Thanks
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
Thanks
Leo
I suggest asking your question here - post a discussion in this SAP GUI space. I'm sure you'll get an answer.
Steve.