Help/Systems SEQUEL Software PowerTech Skybot Software
Data Access & Analysis For System i

December 2009

Use SETVAR to pass variables

When you create a SEQUEL script, you can combine multiple commands into a job stream. If multiple SEQUEL objects in the script prompt for variables, you can use the SETVAR parameter so that you are prompted only once for the variables that will be passed to the various objects. This can be handy when you are setting up something like a script to run month-end reports and you must pass same date range to several reports.

Create two simple views with variables

Let’s create a sample script that displays two views. These views use the same variables for their beginning and ending dates. When you run the script we’ll create, it prompts you only once for the date range.

Because the PDATE field (in the WHERE clause) is a date data type, you must use two ampersands (&) within a pair of double quotes for the variable name.

Open the Variables tab and define the Type as “Date” for both variables. Exit and save the first view as TEST1 in the SEQUELEX library. Create and save the second view as TEST2 in the SEQUELEX library.

Create a script using SETVAR

Select File > New > Script from the ViewPoint Explorer menu to start the script designer.

In the script designer, enter the three lines shown below to monitor for global messages (and prevent the script from ending if an error occurs) and display the two views.

Notice that the SETVAR parameter contains pairs of variables. The first variable in the pair (&START) is the variable you defined in the view. You will define the second variable ('&&START2') in the script. SEQUEL passes the value of the script variable to the view variable at run time.

As you did with your view definition, define the script variables by opening the Variables tab and specify “Date” as the prompt type.

Exit and save the script.

When you run the script, SEQUEL prompts you for the date range only once because the SETVAR parameter passes the dates from the script to the view for you. If you had not included the SETVAR parameter in your script, SEQUEL would have prompted you twice—once for the script and again for the view.

Contributed by Steven Smith, Technical Writer

Use special values to bypass prompt screens

There are times you want to pass a variable to a SEQUEL view without having the user see or supply the value. For example, you may want to pass the job date or system time into the title of the view, report, or table. SEQUEL includes several special default values for variable passing.

Keyword Usage Length
*JOBNBR Retrieve current job number 6
*JOB Retrieve current job name 10
*USER Retrieve current user name 10
*JOBDATE Retrieve current job date 6
*SYSDATE Retrieve current system date 6
*SYSTIME Retrieve current system time 6

 

When you use these special values in conjunction with another special value, *NOPROMPT, *NP, or *NOPMT on the “Prompt Text” parameter, SEQUEL passes the value to the view without user intervention.

For example, here is simple prompted view to pass the variable, job date (*JOBDATE), into the title of the view:

On the Variable tab, define the Type as “Date,” the Prompt Text as *NOPROMPT, and the Default as *JOBDATE.

To see the job date value in the title of the results, you must put the variable in the description of the view when you save it.

When you run the view, you won’t be prompted for the date. SEQUEL automatically inserts it into the title.

For a more complete description of the special keywords and *NOPROMPT, refer to the Variable Specification section of the SEQUEL ViewPoint User Guide.

Q&A

I need to create a work file before I display a client report in ViewPoint. How do I do this?

You need to create a very simple two-line script. For the first line, use the EXECUTE command to create your work file. For the second line, use the REPORT command to display the report in ViewPoint. You do not need VPSHELL or RUNRMTCMD.

Need Help?

Talk to Us
In the U.S. and Canada, call 1-800-328-1000 and ask for Sales.
Elsewhere in the world, contact your local international office.