RAMP TS015 Step 4 Using Screen Variants in the Script

RAMP-TS

RAMP-TS015 Step 4. Using Screen Variants in the Script

In this step you will use the screen variants to set the caption of the button corresponding to the F11 key according to the view shown.

1.   In the Framework window, select the System i Server application and the Active Jobs business object to Display the Work with Active Jobs screen.

2.   Press F11 to display the different views of the screen.

3.   Notice that the Caption of the button corresponding to the F11 key has a static caption Display Elapsed Data.

To set the appropriate caption on the button depending on the view shown, you need to check which variant is being shown and then use the OVERRIDE_KEY_CAPTION_SCREEN function to set the button caption:

4.   Switch to the RAMP Tools window and display the script for the WrkActJob screen.

5.   In the vHandle_ARRIVE function add an IF… ELSE IF… ELSE statement after the bReturn variable declaration to check which screen variant is shown and to set the caption of the button:

    if (this.vLatestVariant == "Status")
        {
        OVERRIDE_KEY_CAPTION_SCREEN("WrkActJob", KeyF11, "Show Elapsed Data");
        }

    else if (this.vLatestVariant == "Elapsed")
        {
        OVERRIDE_KEY_CAPTION_SCREEN("WrkActJob", KeyF11, "Show Thread Data");
        }

    else
        {
        OVERRIDE_KEY_CAPTION_SCREEN("WrkActJob", KeyF11, "Show Status");
        }

 

Your script will look like this:

 

6.   Commit the changes and do a partial save of the RAMP definition.

7.   Switch to the Framework window and test your changes. The button caption will change depending on the screen variant shown: