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":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":true - This option is used to specify a process that will be triggered. |
|
"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. |
Option Details
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.
- 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');
- 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(); }
- Save the changes.
- Launch SAP and navigate to the Easy Access transaction.
- 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.
- 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');
- 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(); }
- Save your changes.
- Launch SAP and navigate to the Easy Access screen to initiate the process by clicking the enter button.
- The function executes and the screen appears as shown: