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 Set Default Selection in DropDown List

SAP Screen Personas tutorial shows how to set default selected value of a dropdown list control on a Personas flavor by using OnCreateHandler event using script button.

Although SAP Personas flavor dropdown list control is created with a predefined default selected value during execution the dropdown field is displayed as empty. To overcome this problem and show default value in the dropdown list control on the SAP Personas flavor, I will show developers how they can use script button and OnCreateHandler.

SAP Personas Flavor Layout with Dropdown List Control

I have used a dropdown list control on a SAP Screen Personas flavor. Although I have defined a value as default selection, unfortanetely the preselected value I have set is not displayed as I expected when I execute the flavor transaction.

SAP Screen Personas flavor dropdown list control

Here is the flavor control dropdown list configuration. On VA01 transaction flavor, I set the standart order as the default value of the dropdown list control.

control conversion for dropdown list from textbox

To set default value, normally checking the option box on the left side of the dropdown list item is enough. Unfortunately, in this case when the flavor is first displayed the default value is not displayed as the selected value. The default displayed value on the dropdown list is an empty value which we do not want.


Use OnCreateHandler for Dropdown List Default Value

In order to solve this problem which prevents displaying default selection of a dropdown list control on a SAP Personas flavor, first create a new Script by adding script button on the Personas layout.

Add the following user action into the steps of the script button which sets the selected value of the dropdown list.

SAP Personas Script Button actions

ABAP developer should replace the control "ses[0]/wnd[0]/usrUSRAREA/ctxtVBAKAUART" with the target dropdown list Personas layout control. Using "Enter Value" action, the selected item value of the dropdown list can be provided.

As last step, copy the id value of the script button control. Then paste the script button id into the OnCreateHandler attribute of the layout user area as seen in below screenshot. Finally, hide the script button since the execution will be controlled by the page load event of the Personas flavor.

set OnCreateHandler for default values of SAP Personas flavor

OnCreateHandler event of the Personas layout user area will enable SAP Screen Personas developers to execute a default script when on page load event of the layout automatically.

Afterwards, everytime the flavor is called or executed, the dropdown list will be shown with predefined value is selected by default as follows.

dropdown list with default value is set

On fortunately, if you have copies of this flavor for example for the purpose of different country implementations, etc all flavors should be updated manually for the target default values of the dropdown list flavor controls.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


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