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

SAP Screen Personas OnCreateHandler Script Button to Run At Page Load

SAP Screen Personas developers use script button at OnCreateHandler property of a flavor to set initial values of displayed controls on page at start automatically. Programmers can think of OnCreateHandler as a page event triggering at flavor load which enables automatic execution of predefined script button actions.

I have created a SAP Screen Personas flavor for VA01 transaction initial screen. But I want to populate below empty fields automatically when the page is load.

SAP Screen Personas sales order entry screen

In fact, if I had the chance to use pure Javascript, I would use Javascript onLoad event of the web page.

ABAP developers who create SAP Screen Personas transaction screens can use OnCreateHandler property to run a specific Script button code when the Personas flavor is displayed in front of the SAP user.

First add a Script button on to the SAP Personas flavor.

add script button to SAP Screen Personas flavor

Give a meaningful name to your Script button like "Create Handler Script" We will fill the script steps later in this SAP Personas tutorial.

Click on Show/Hide Properties icon which is on the right.

Show/Hide Properties

Then click on an empty area on the flavor layout.
You will be selecting the control with ID ses[0]/wnd[0]/usrUSRAREA
You will see the OnCreateHandler property.

OnCreateHandler

On SAP Screen Personas developers can use the OnCreateHandler attribute to run a script button automatically when a Personas layout is loaded. Adding steps to the script button enables the developer to customize what is to run automatically when the page is load.

Copy the Script button ID and paste into the OnCreateHandler attribute
To copy the Script button control id, click on script button. When properties screen is displayed click on the top area containing text which is like a GUID. When you click on that text, it is automatically copied into clipboard.

copy SAP Screen Personas control id

Paste the script button id into OnCreateHandler event of the SAP Personas flavor.

SAP Personas script button to run with onCreateHandler event

ABAP developer can now edit the script button details to add new steps that will populate input textboxes with predefined values.

To simplify the SAP Personas tutorial, I used "Enter Value" action. Then I selected the control on the SAP Screen Personas flavor. I also entered the values I wanted to see on the screen.

SAP Screen Personas: define script button properties

Save and exit your flavor development.

OnCreateHandler script button on SAP Screen Personas layout

You can hide the script button for a better GUI desing, there is no need to show it on the screen to the SAP users.

hide or unhide controls on SAP Personas flavor



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


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