SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Execute SAP Screen Personas Script with Parameter


Programmers developing SAP Screen Personas scripts using Script Editor, can execute other scripts and pass parameters to those scripts within current Javascript code block. Javascript developer can create new scripts to do some certain tasks that can be executed repeatedly with different parameters.

For example, on a SAP Personas flavor due to the status of an order buttons on the flavor can be enabled or disabled. In this SAP Personas tutorial, I will create a Personas script which is used to disable button whose control id is passed as parameter to the script.

Let's first create a script and then call that Personas script with passing control id as a parameter.

On target Personas flavor, switch to Scripting Editor

Launch SAP Screen Personas Scripting Editor

Create a new Personas script, name it using a descriptive title "fnDisableButton" as in this example

You will see that the script has an additional Personas id "wnd[0]/scrptPersonas_13"

Please check following SAP Personas script.
To pass parameter to this Personas script, developers can use session variables.
To read a session variable in SAP Personas script, session.utils.get() method can be used.
As you see, I read the session variable pButton2Disable using 'session.utils.get("pButton2Disable")' statement.

var obj = session.utils.get("pButton2Disable");
if(obj !== null && obj !== '') {
 session.findById(obj).enabled = false;
 session.utils.put("pButton2Disable","");
}
Code

Here is the Personas script which is used to disable button for given control id

read parameters in SAP Personas script

Now we can go to the first script which will execute fnDisableButton or with its script id "wnd[0]/scrptPersonas_13" and add Javascript codes to pass parameter for button and call script execution code.

Just the opposite way of using Get() method of session.utils to read session parameters, developers can use Put() method of session.utils to set session parameter values.

For example, in below Javascript code I created a new session variable named pButton2Disable and set its value to the Id of the button that I want to disable "wnd[0]/usr/btnPersonas_1473147801970"

Of course to call the first Personas script fnDisableButton that we have created earlier within onLoad Personas script, programmers can call session.utils.executeScript() method

pass parameter to Personas script

Here is the onLoad Personas script which is calling another script and passing parameter to this second Personas script.

// used to pass parameter between Personas scripts
session.utils.put("pButton2Disable","wnd[0]/usr/btnPersonas_1473147801970");

// call another Personas script using executeScript method
session.utils.executeScript("wnd[0]/scrptPersonas_13");
Code

To summarize the steps to pass parameters between two SAP Screen Personas scripts and execute one script from another;

If you are using similar Javascript code blocks for similar tasks with different variables, you can create another script which can read session variables using session.utils.get method into script variables and execute in a generic way.

To pass parameters to a script in SAP Personas, you can use session.utils.put method.

To execute a Personas script from another Personas script, use session.utils.executeScript method with passing the script id as an input argument.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.