Linking functions to pushbuttons

In the preceding example, we used the pushbuttons to navigate to a specific SAP transaction. However, pushbuttons can do far more than merely help users navigate to transactions. Pushbuttons can also be used to trigger a complete process which may involve multiple screens and data entry points. We will not cover cover advanced processes at this time, but we will demonstrate one here. The process will set the order type in VA01 to 'OR'.

  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( {"offset":[12,2]}, '@2L@Save Restriction Codes', {"size":[2,25], "process":setOrderType});
    function setOrderType() {
        set("F[Order Type]", "OR");
    }
    				
  3. Save your changes and refresh the SAP screen.

    The VA01 screen now appears as follows:



  4. Click the 'Save Restriction Codes' 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. This action also sends an enter command, causing SAP to progress to the VA01 Overview screen after the order type is populated.