SAP Screen Personas
Create: Clemens Gantert
Last Update: Regina Sheynblat
Experimental Feature: Scheduling scripting tasks to be executed asynchronously
SAP SCREEN PERSONAS KNOWLEDGE BASE - by Clemens Gantert , Regina Sheynblat
As of SP06 this article is obsolete. Please refer to the new Knowledge Base article on executeScriptAsync method.
A new experimental scripting feature is described. It allows for breaking up long running scripts into smaller chunks that are executed asynchronously and can update the screen with progress information when they are finished.
This article describes an experimental feature.
The feature described in the article was introduced with Service Pack 3 of SAP Screen Personas 3.0
- It only works in the SAP GUI for Html. It is not supported in the SAP Gui for Windows or Java
- The described API may be changed or even removed in future releases of SAP Screen Personas
Long running Personas scripts, which may block the UI for many minutes, can be split into smaller, shorter running tasks and scheduled to be executed one after the other. When a task is complete, the screen is redrawn allowing for progress information to be shown.
Breaking up long-running scripts into smaller, asynchronously executed tasks
The problem: You have personas script that takes tens of seconds to minutes to complete. While the script executes the UI is blocked and except for the loading animation the user has no indication of what is happening. There is no progress information. To make matters worse many older kernels do not even show the loading animation during script execution.
The solution is to break up the script into smaller tasks that are scheduled and that at the end of their execution update the screen with progress information. Please note that this will work on scripts that can be broken up into tasks, such as when a list of documents or objects is processed one at time. If your long-running script just presses a standard button that then will start the standard button action which happens to take very long then the outline approach will of course not work.
API method sap.personas.scripting.scriptingEngine.scheduleTask( fTask ) and Usage Examples
The following simple example
shows the following log:
Within your tasks functions you have access to the session variable and can do anything a "normal" script can do, up to manipulating UI elements to give a progress update to the user. When writing your script it is key that each task function "knows" which step and what data to work. This can be achieved with "global" variables defined in the original script or by packing the data into closure of the task script.
Example 1: All tasks are scheduled in the original script. Each task waits 3s and then appends a task string to a multi-line label.
The above example works because the variables taskStrings and index exist for every task and during the entire life time of the process. When one task finishes it increases the "global" variable index.
It might be cleaner to pack the data into the closure of each task as done in Example 2, but this does not make such a script easier to read and understand.
Example 2: If does the same thing as Example 1, but data is encapsuled in each task.
Last but not least, it is possible to schedule tasks during the execution of a task.This is even required if the if task 2 depends on data or results of task 1.
SAP Screen Personas, Script, Scripting, asynchronous, scheduling
Search the KB
Important SAP Notes
How to Open OSS Message
What information is needed for creating OSS message?