Skip to Content

SAP Screen Personas 2.0 - How to go beyond the existing script actions


Note: This article is about SAP Screen Personas 2.0. If you are looking for more information about SAP Screen Personas 3.0, please go to the SAP Screen Personas 3.0 Portal.

In our webinar Streamline the Order-To-Cash process with SAP Screen Personas, we executed a script on the SAP Easy Access transaction (SMEN) that skipped the first screen of the Create Delivery transaction VL01N using the order number entered on SMEN and a selection date that was calculated using the current date and the selection of a dropdown list.

To copy values on one screen and use them on another screen, we used the Copy Value and Paste Value actions as explained in SAP Screen Personas - How to fetch data from another screen. However, to use a value like the date in ten days, some advanced calculation is needed. In such cases, SAP Screen Personas allows you to add JavaScript snippets to a script that has read and write access to the same variables that are accessible via Copy/Paste Value actions.

In this example, the value "days" has been copied from the dropdown list, then the following JavaScript snippet has been executed and finally, the value date (created within JavaScript) has been pasted.

var d = new Date(); d.setDate(d.getDate() + parseInt(args.days)); = (d.getMonth() + 1) + "/" + d.getDate() + "/" + d.getFullYear();

This example showed how to use the JavaScript action for date modifications. During our co-innovation projects, we have also seen that JavaScript was used for basic string operations e.g. concatenating strings to enforce data entry convention.

Please have a look at the following video, showing how to use the "Calculate in JavaScript" action.

We suggest to use the "Calculate in JavaScript" action for calculations or manipulations beyond the available actions. Variables created using the "Copy Value" action are accessible using the args. - new variables can also be created following the same pattern. Example:; create or overwrite the existing variable with a value calculated by adding 1 to the content of the variable args.old. While JavaScript can provide great power and flexibility for manipulating dates and strings, we recommend against using it to embed any business logic. If you want to add functionality beyond the basic SAP transactions, you can do so using WebRFCs.

As usual, if you want to learn more or discuss anything related to how to make your SAP GUI screens more functional using SAP Screen Personas, please start a discussion in the SAP GUI space on SCN.