I was asked a question about how to change the name of the spool file created by running Query/400.
The default print file for Query/400 output is QPQUPRFIL. The inquisitor wanted to change the name of the spool file to another which would allow the users to be able to identify it.
This can be achieved by using the OVRPRTF command.
Amongst the myriad of parameters available for the OVRPRTF command is the SPLFNAME parameter. Whatever is entered into this parameter will be the name of the spool file.
How is it done? The CL program below shows I could do it:
01 PGM 02 OVRPRTF FILE(QPQUPRFIL) SPLFNAME(TESTQRY) + 03 OVRSCOPE(*CALLLVL) 04 RUNQRY QRY(TESTQRY) QRYFILE((IN_FILE)) 05 ENDPGM |
The OVRPRTF, on lines 2 and 3, is overriding the default Query/400's spool file name to be TESTQRY, which is the name of the Query/400. The OVRSCOPE parameter has been defined as *CALLLVL, which means that the override is to the current call level. Any Query/400 run by this program with the override in place will use that spool file name. Once the program has completed the override ends and Query/400 returns to using the QPQUPRFIL name again.
I have defined the QRYFILE for the RUNQRY command, line 4, as this will use the first IN_FILE in the library list, rather than the file defined within the Query/400. This makes sure that if I change the library list, for example from "production" to "testing", the Query will use the appropriate file.
If there are multiple Query/400s run in the same program the OVRPRTF command can be used to give each spool file a unique name.
01 PGM 02 OVRPRTF FILE(QPQUPRFIL) SPLFNAME(TESTQRY) + 03 OVRSCOPE(*CALLLVL) 04 RUNQRY QRY(TESTQRY) QRYFILE((IN_FILE)) 05 OVRPRTF FILE(QPQUPRFIL) SPLFNAME(ANOTHER) + 06 OVRSCOPE(*CALLLVL) 07 RUNQRY QRY(TESTQRY) QRYFILE((IN_FILE)) 09 ENDPGM |
After running the one query with a unique spool file name you wish to revert to using the default name for the other Query/400s you would use the DLTOVR to delete the override.
01 PGM 02 OVRPRTF FILE(QPQUPRFIL) SPLFNAME(TESTQRY) + 03 OVRSCOPE(*CALLLVL) 04 RUNQRY QRY(TESTQRY) QRYFILE((IN_FILE)) 05 DLTOVR FILE(QPQUPRFIL) LVL(*) 06 ENDPGM |
What I have shown above can be done with any spool file.
01 OVRPRTF FILE(QSYSPRT) SPLFNAME(AGE_BAL) + 02 OVRSCOPE(*CALLLVL) |
Therefore, this can be used for any reports to give the spool file a name that users can easily recognize as the report they want.
You can learn more about the override commands on the IBM website:
This article was written for IBM i 7.1, and it should work with earlier releases too.
Does it only change the file name, or actually uses an existing printer file named the same as SPLFNAME?
ReplyDeleteWhat is explained above is just how to change the name of the spool file, not the printer file used.
DeleteIf you want to change which printer file is used you also use the OVRPRTF command, but the command would be:
OVRPRTF FILE(QSYSPRT) TOFILE(Q198WIDE) OVRSCOPE(*CALLLVL)