Progress reporting is a mechanism to ensure the user that a long running batch job is functioning correctly and is not caught in some sort of endless loop. The quantity of records in our PM, PA, and MR files can cause trivial programs to run for a significant amount of time even if they just read through the file and don’t do anything else. A reasonable number of records to use as a trigger value should a number that will let the user know within a few minutes that progress is being made. The large PM files, such as the APM or CPI, work well with a progress report every 10,000 records. The sample code in this newsletter uses COBOL II, but the same technique can be used with any language.

WORKING-STORAGE code:

02 RECORDS-READ PIC 9(08) VALUE 0.

02 RECORDS-WRITTEN PIC 9(08) VALUE 0.

PROCEDURE DIVISION code:

READ INPUT-FILE

AT END

MOVE ‘Y’ TO END-OF-FILE-FLAG

NOT AT END

ADD 1 TO RECORDS-READ

IF RECORDS-READ > ZEROS

AND RECORDS-READ (5:4) = ‘0000’

DISPLAY RECORDS-READ ‘ RECORDS READ, ‘

RECORDS-WRITTEN ‘ RECORDS WRITTEN.’

END-IF

END-READ.

.

.

.

WRITE EXTRACT-RECORD.

ADD 1 TO RECORDS-WRITTEN.

Sample Output:

00010000 RECORDS READ, 00000000 RECORDS WRITTEN.

00020000 RECORDS READ, 00000001 RECORDS WRITTEN.

00030000 RECORDS READ, 00000004 RECORDS WRITTEN.

.

.

.

21670000 RECORDS READ, 00000537 RECORDS WRITTEN.