Passing parameters to pushbuttons

In the following section, we will demonstrate how to pass some user-entered 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 entered by a user.

  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":"&V[z_ord]"}});
    textbox([2,12], [3,24], {"name":"z_ord"});
  3. Now create the function that you will call when the pushbutton is pressed. 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. Enter RO in the textbox and click the VA01 button to initiate the function.

The VA01 screen now appears as follows: