Example 1: Final total-only processing

This example shows simple total processing.

Assume that you have a database file FILEA and decide to create file FINTOT for your final total record as follows:

FILEA FINTOT
Code Count (count of all the selected records)
Amt Totamt (total of the amount field)
  Maxamt (maximum value in the amount field)
The FINTOT file is created specifically to hold the single record which is created with the final totals. You can specify:
OVRDBF     FILE(FINTOT) TOFILE(FILEA) SHARE(*YES)
OPNQRYF    FILE(FILEA) FORMAT(FINTOT) +
              MAPFLD((COUNT '%COUNT') +
                (TOTAMT '%SUM(AMT)') (MAXAMT '%MAX(AMT)'))
CALL       PGM(PGMG) /* Created using file FINTOT as input */
CLOF       OPNID(FILEA)
DLTOVR     FILE(FINTOT)