CIS 111 Control break processing

Objective

  • Create a control break report

Control break overview

  • a control break is a change in a key field that triggers special processing
  • one example is printing totals for each department in a report
  • in that case, every change in the department field would trigger a total to print
  • if there is more than one level of control break, the term is level break
  • a higher priority level break causes an automatic break in all levels below it
  • for example, a department break would also trigger an employee break
  • level breaks work by comparing a current field value to the previous field value
  • the previous field value must be set to the current value at the end of the record processing loop
  • the first record usually shouldn;t trigger a level break
  • a forced level break is often required after the last record is processed

Control break pseudocode

prevDept = "???" departmentTotal = 0 grandTotal = 0 recordNumber = 0 open report file output report headers to report file open the data file for each record in the data file recordNumber++ if department != prevDept and recordNumber != 1 output departmentTotal to report file add departmentTotal to grandTotal departmentTotal = 0 output record details to report file prevDept = department close data file output departmentTotal to report file add departmentTotal to grandTotal output grandTotal to report file output report footers to report file close report file