Passing parameters to pushbuttons

In the following section, we will demonstrate how to pass some data to a function that is called by a pushbutton. This process works essentially the same regardless of what type of screen element is being used - parameters can be passed to a variety of screen elements. In the following example, we will pass the parameter 'z_ord' to the function called by the pushbutton. In this example, the value will be contained in the script.

  1. Go to the VA01 screen in SAP.
  2. Open the VA01 script file (SAPMV45A.E0101.sjs) and enter the following code. Create the file if it does not already exist.
    pushbutton([1,1], "@2L\\QLaunch VA01@VA01", "/nva01", {"size":[1,10], "process":test1, "using":{"param1":"OR"}});
    				
  3. Now create the function that will be called. An example is shown below:
    function test1(param) {
                    onscreen 'SAPMV45A.0101'
                    set("F[Order Type]", param.param1);
                    enter();
    }
    				
  4. Save your changes and refresh the SAP screen.

    The VA01 screen now appears as follows:



  5. Click the VA01 button to initiate the function.

The VA01 screen now appears as follows:



We have created a new pushbutton and tied it to a function that sets the Order Type field to the value 'OR' each time the button is pressed. The value is defined within the script file. This action also sends an enter command, causing SAP to progress to the VA01 OVerview screen after the order type is populated.