Example 3: Final total-only processing

This example shows total-only processing using a new record format.

Assume that you want to process the new file/format with a control language (CL) program. You want to read the file and send a message with the final totals. You can specify:
DCLF       FILE(FINTOT)
DCL        &COUNTA *CHAR LEN(7)
DCL        &TOTAMTA *CHAR LEN(9)
OVRDBF     FILE(FINTOT) TOFILE(FILEA) SHARE(*YES)
OPNQRYF    FILE(FILEA) FORMAT(FINTOT) MAPFLD((COUNT '%COUNT') +
                (TOTAMT '%SUM(AMT)'))
RCVF
CLOF       OPNID(FILEA)
CHGVAR     &COUNTA &COUNT
CHGVAR     &TOTAMTA &TOTAMT
SNDPGMMSG  MSG('COUNT=' *CAT &COUNTA *CAT +
               ' Total amount=' *CAT &TOTAMTA);
DLTOVR     FILE(FINTOT)

You must convert the numeric fields to character fields to include them in an immediate message.