Control-Break Processing

Here is generic pseudocode for a one-level control-break problem. This modular solution involves the use of nested loops (one loop within another). The outer loop controls processing for the entire report, while the inner loop controls processing that recognizes when a logical break occurs for processing objects like subtotals.

 

 

START

DO INITIALIZTION

DO REPORT-LOOP WHILE (NOT EOF)

DO FINAL-SUMMARY

STOP

 

 

INITIALIZATION

OPEN FILES

INITIALIZE FINAL ACCUMULATOR(S), COUNTER(S)

Do any other report initialization

INPUT FIRST RECORD

 

 

REPORT-LOOP

COPY THE CONTROL FIELD

INITIALIZE SUBTOTAL ACCUMULATOR(S), COUNTER(S)

Do any other “first-record” processing

DO NORMAL-PROCESSING WHILE (NOT EOF AND CONTROL FIELD HAS NOT CHANGED)

OUTPUT SUBTOTALS

Do any other “control break” processing

 

 

NORMAL-PROCESSING

IF NECESSARY, PRINT REPORT HEADINGS

PROCESS & PRINT FIELDS FOR CURRENT RECORD

ACCUMULATE CURRENT RECORD TOTALS

Do any other “every-record” processing

INPUT NEXT RECORD

 

 

FINAL-SUMMARY

PRINT FINAL TOTALS

Do any other “final” report processing

CLOSE FILES