Author Topic: How to override user click, and execute the user click in a Function  (Read 4711 times)

umang@guixt.com

  • Administrator
  • Newbie
  • *****
  • Posts: 34
    • View Profile
When a button is pressed on the screen, the requirement is to suppress the user action, read values from the screen
based on the values read from the screen, either stay on the screen or execute a user action within a function.

This way the user entered value can first be captured, checked followed by user action based on desired logic.

Below is an example for VA01 transaction (Overview Screen)

When user clicks the back or save button, in this scenario, we need to first check what user has entered in the delivery block field.
If user has entered the value '01' then we want the user to stay on the same screen and display a message to the user to select a different value.
If user has entered any other value, then we want to execute the user action in the function.  In this example either Back ('/3') or Save ('/11')

Sample script for the scenario as per below
----------------------------------------------------------------------------------------------------------------------------------------------
Script File Name: SAPMV45A.E4001.sjs
----------------------------------------------------------------------------------------------------------------------------------------------
// Back Button is clicked on the UI
// In below case 'Back' action is suppressed and replaced with '?' which is equivalent to screen refresh
onUIEvents['/3']={'fcode':'?','process':executeFunction,'using':{'l_code':'/3'}};
// Save Button is clicked on the UI
// In below case 'Save' action is suppressed and replaced with '?' which is equivalent to screen refresh
onUIEvents['/11']={'fcode':'?','process':executeFunction,'using':{'l_code':'/11'}};


function executeFunction(param) {
   
   onscreen 'SAPMV45A.4001'
      set('V[z_va01_deliveryblock]','&F[Delivery block]');
      // If Delivery Block selected is 01, then stay on SAPMV45A.4001 screen and do not perform
      // any additional action in the function.  Exit Function
      // [Change is logic as per your use case and requirements]
      if(z_va01_deliveryblock=='01') {
         message('E: Please select different delivery block');
         enter('?')
         goto SCRIPT_END;
      }
      // Execute the function as passed to the function.
      // In this example either '/3' [Back] or '/11' [Save]
      enter(param.l_code);
   
   SCRIPT_END:;
}