Portability Considerations |
The features described in this section are ONLY supported on IBM i. |
Report programs can be made more flexible by using the LANSA OPEN command in conjunction with the USE_OPTION(*OPNQRYF) parameter.
The OPNQRYF command is actually an IBM i operating system command. By using it with LANSA you can make reports much more flexible, often replacing several reporting programs with just one program.
The power of the OPNQRYF command is primarily used in two different ways to increase function and flexibility. These are:
1. To alter the data selection criteria used by the program at execution time.
2. To alter the data ordering criteria used by the program at execution time.
Consider the following example:
REQUEST FIELDS(#REP_TYPE)
CASE OF_FIELD(#REP_TYPE)
WHEN VALUE_IS('= A')
CHANGE FIELD(#ORDER_BY) TO('PRODNO CUSTNO PARTNO')
WHEN VALUE_IS('= B')
CHANGE FIELD(#ORDER_BY) TO('CUSTNO PARTNO')
WHEN VALUE_IS('= C')
CHANGE FIELD(#ORDER_BY) TO('PARTNO DEPTNO CUSTNO')
ENDCASE
OPEN FILE(PARTHIST) USE_OPTION(*OPNQRYF)
KEYFLD(#ORDER_BY)
EXECUTE SUBROUTINE(PRINT)
Here the user is asked to nominate what type of report is required (field #REP_TYPE). This value is then used to set up a KEYFLD parameter value in a variable called #ORDER_BY. This value is then passed to the OPNQRYF command via the LANSA OPEN command and the report is produced.
This program can now produce the same report in 3 different orders. By product, customer and part (a type A report), by customer and part (a type B report), or by part, department and customer (a type C report).
The same type of processing can be used to assemble the QRYSLT parameter of the OPEN command to alter the actual data selected by the program from the file for inclusion on the report.
Refer to the LANSA Technical Reference Guide for more details and examples before attempting to use the OPEN command in this way.