Example 2: Final total-only processing
This example shows total-only processing with record selection.
Assume that you want to change the previous example
so that only the records where the Code field is equal to B are in
the final total. You can add the QRYSLT parameter as follows:
OVRDBF FILE(FINTOT) TOFILE(FILEA) SHARE(*YES)
OPNQRYF FILE(FILEA) FORMAT(FINTOT) +
QRYSLT('CODE *EQ "B" ') MAPFLD((COUNT '%COUNT') +
(TOTAMT '%SUM(AMT)') (MAXAMT '%MAX(AMT)'))
CALL PGM(PGMG) /* Created using file FINTOT as input */
CLOF OPNID(FILEA)
DLTOVR FILE(FINTOT)
You can use the GRPSLT keyword with the final total function. The GRPSLT selection values you specify determines if you receive the final total record.