Liquid UI - WS Reference Library

onUIEvents()


Purpose

With onUIEvents() command, you can trigger processes or function codes.

This command is applicable to any process user will perform in an SAP screen with the sole exception of pushbutton clicks. There are a number of possible ways of writing this command, as shown in the examples below.


Syntax

Syntax
Definition
onUIEvents["action"]=process_name;
Launches a process upon the specified user action.
onUIEvents["action"]={"process":function_name};
				
Launches a process upon the specified user action.
onUIEvents["action"]={"fcode":"functioncode","process":function_name};
				
Transports the user to the specified transaction, where the process will then execute.
onUIEvents["action"]={"fcode":"functioncode","process":function_name, "using":{parameter:"Parameter_value"}};
Transports the user to the specified transaction, executes the specified process using the previously specified parameters.


Options

You can use the following options with the onUIEvents() event handler command.

"fcode":".."

"fcode":true - This option is used to send a function code. The code can be either an SAP transaction code or a function key code.

"process":".."

"process":true - This option is used to specify a process that will be triggered.

"using":".."

"using":{parameter:"string_value"} - This specifies a parameter that will be employed in the designated process. It is very useful to send a value to the process function, which can then be passed to SAP.
"using":{parameter:"numerical_value"} - This specifies a parameter that will be employed in the designated process. It is very useful to send numerical values to the process function, which can then be passed to SAP.


Option Details

fcode

  1. This option is used to send a function code. The code can be either a SAP transaction code or a function key code.

  2. onUIEvents["/4"]={"fcode":"/nmm01"};
  3. On pressing F4 key, you will switch to mm01 transaction.

process

  1. This option is used to specify a process that will be triggered.

  2. onUIEvents["enter"]={"fcode":"/nmm01","process":test_UIEvent};;
    function test_UIEvent(){
    	onscreen 'SAPLMGMM.0060'
    	set("F[Material]","DPC7700");
    }
  3. Click enter and this option will trigger the process(test_UIEvent) to execute. This function will navigate your screen to MM01 and set the Material field value as DPC7700.

using

  1. This specifies a parameter that will be employed in the designated process. It is very useful to send a value to the process function, which can then be passed to SAP. You can also send numerical values as a parameter under using option.

  2. onUIEvents["enter"]={"fcode":"/nva02","process":test_UIEvent,"using":{param1:5455}};
    function test_UIEvent(param){
    	onscreen 'SAPMV45A.0102'
    	set("F[Order]", param.param1);
    	}

Example

The following examples demonstrate the usage of onUIEvents() command:

Executing a process

In the following example, we are going to use the onUIEvents() command to trigger a process based on a user action. The transaction where the process will occur is specified using the 'fcode' option. Specifically, when a user presses the Enter key, the user will be transported to the VA02 transaction and a function will execute.

  1. Open the Easy Access script file (SAPLSMTR_NAVIGATION.E0100.sjs) and enter the following code. Create the file if it does not already exist.
    del ("X[IMAGE_CONTAINER]");
    onUIEvents['Enter']={"fcode":"/nva02","process":test_UIEvent};
    text([4,1],'This example includes the execution of UI action Enter. Hit Enter  to execute process');
  2. Now add the function code that will execute when the VA02 transaction launches. An example function is shown below:
    function test_UIEvent(){
    	onscreen 'SAPMV45A.0102'
    		set("F[Order]","14200");
    	enter();
    	onscreen 'SAPMV45A.4001'
    	enter();
    }
  3. Save the changes.
  4. Launch SAP and navigate to the Easy Access transaction.
  5. Press the enter key to initiate the process from the Easy Access screen. On execution of the process, the screen appears, as shown:

Passing parameters to onUIEvents

In the following example, we will pass some parameters to the onUIEvents command with the 'using' option. To demonstrate this, please do the following.

  1. Open the Easy Access script file (SAPLSMTR_NAVIGATION.E0100.sjs) and enter the following code:
    onUIEvents['/1']={"fcode":"/nva02","process":test_UIEvent, "using":{param_1:15965}};
    text([4,1],'This example includes the execution of UI action F1. Hit F1 to execute process');
    			
  2. Now create a function that will actually do the work of passing the parameter. An example is shown below:
    function test_UIEvent(param){
    	onscreen 'SAPMV45A.0102'
    		set("F[Order]",param.param_1);
    	enter();
    	onscreen 'SAPMV45A.4001'
    	enter();
    }
    			
  3. Save your changes.
  4. Launch SAP and navigate to the Easy Access screen to initiate the process by clicking the enter button.
  5. The function executes and the screen appears as shown:

Tips and Tricks

  • Display Custom Pop-up

    Display custom pop-up and wait for user interaction.

    onUIEvents['Enter'] = {"fcode":"/12", "process":executeVK11}

    Learn more about Display Custom Pop-up on SAP Easy Access Screen.