Break Processing:

Break processing involves printing totals when there is a change in processing caused by a new control number being read. In doing break processing, there is an assumption that the files are sorted in order by break number. If you want to print department totals, then the department number is your control number. When you read a record with a different department number, a break has happened. You want to print out the total of the previous department and then start processing the new department by processing the record that caused the break.

Sometimes there are multiple levels of breaks. For example you might have divisions which are broken down into branches which are broken down in departments. When there are multiple levels of breaks, the following assumptions are made (if these assumptions dont hold, you need to develop another program):

This means that the programmer checks first for a division break, if a division break happens then we know branch and department have also changed. The program should then display/print out the total for the department, the total for the branch and the total for the division. If the division didnt change, the programmer should check to see if the branch changed. If it did then the department also changed and department totals followed by branch totals should be displayed/printed. If the branch didnt change, then the programmer should check to see if the department changed. If the department changed, department totals should be displayed/printed. In addition to displaying/printing totals, the programmer also has to clear out accumulators and reset hold areas. This means that the code to print/display a total line includes the code to gather the information for the line, the code to display/print the line, move 0 to the hold area for that accumulator and move the new control number to the hold area for that control number.

For every record that is processed the detail line needs to be displayed/printed. If there was a break, the breaks are processed first. Essentially if there was a break, you display/print out the totals and then display/print out the record that caused the break. If there was no break you just display/print the next record in the group.