You can produce variations of a report using a single qfile. You define parameters in a CA OLQ command into which a user-defined text string can be inserted at execution time.
Access mode: You cannot use parameters in qfiles dictionary when the access switch is set to IDMS.
Example:
You can tailor a qfile to produce standard summary reports for each department. The department ID is identified as the parameter. You can change the definition of the parameter to reflect the department you want to report on.
How Parameters work:
You include a parameter in a qfile where you want to change the value of something. For instance; replace a field name in order to change the field retrieved, or a qfile name in order to change the next qfile invoked.
Keep in mind that these parameters are positional. The order in which you specify them in the qfile is the exact order you must specify them when executing the qfile.
In the following example, the department ID value (6666) is replaced with a parameter in order to change the department being reported on.
Original SELECT:
select * from department, employee, emposition - where dept-id-0410 = 6666
SELECT with variable parameter:
select * from department, employee, emposition - where dept-id-0410 = &dept-no.
You define the parameter in the first line of the qfile, and if you want to change the default, you specify the value at execution:
&dept-no. = 6666 select * from department, employee, emposition - where dept-id-0410 = &dept-no.
If you wanted to override the default, your QFILE command would look like:
qfile emp-report 2364
(Where 2364 is the department number)
Defining Parameters:
Once you have your parameters in the qfile, you must define them in the beginning of the qfile. You do this on the first line of the qfile. If you don't have any parameters to define, you must leave the first line of the qfile blank. The syntax of the parameter line is:
& parameter-name = parameter-value
The parameter-value you specify acts as the default. You can override the default by specifying a value at execution of the qfile:
QFILE qfile-name parameter-value
Guidelines for defining parameter statements follow:
Multiple parameters in one command:
You can use more than one variable parameter in a command statement.
Example:
select &emp-field-name. &dept-field-name. from employee, department
The parameter statement that would appear as the first line in the qfile would read:
&emp-field-name. = EMP-LAST-NAME-0415 - &dept-field-name. = DEPT-ID-0410
Nesting qfiles allows you to suspend processing of one qfile to execute another qfile, which, upon completion returns execution back to the first qfile.
Access mode: You cannot use parameters in qfiles dictionary when the access switch is set to IDMS.
What is nesting used for?
Using this method, you can execute a qfile that retrieves records, calls another qfile to format those records, and returns to the first qfile to then save the formatted records in a report file.
This would be especially helpful if you had one report you wanted formatted in different ways; for example, to format a department report to highlight the employee information, and format the same report to highlight the department information. You could have three qfiles:
By nesting the qfiles, you could use the same qfile to build the report and then use a variable parameter to call a certain qfile, depending upon how you wanted the report formatted.
Example:
RETRIEVE-DATA retrieves records:
&format='. ' select * from department, employee, emposition - where dept-employee and emp-emposition &format.
In the example above, the first line (&format='. ') is the parameter definition statement. This statement dictates that the value of the parameter will be supplied at execution time. The last statement (&format). is the parameter that, when specified, calls another qfile.
At execution time, you can issue the command:
retrieve-data format-emp-report
The FORMAT-EMP-REPORT will be substituted in the parameter &FORMAT. at execution of the qfile and will result in the execution of qfile FORMAT-EMP-REPORT upon the completion of the qfile RETRIEVE-DATA.
How to nest qfiles
To nest qfiles, just enter a QFILE qfile-name command in the qfile where you want to transfer execution to the second qfile. When the nested qfile completes execution, control is returned to the first qfile at the command immediately after the last executed QFILE command.
|
Copyright © 2013 CA.
All rights reserved.
|
|