Control-Break Algorithms. Your input file contains data for your sales staff. Each record has a 5 digit sales region number, a 20 character region name, a 4 digit salesperson number, a 30 character salesperson name and a sales amount (of the form S9(7)V99). You are to generate a report that shows the contents of the entire file. Not only do you need a grand total, but also the toal for each region. Luckily, the file is sorted by region number. Since you are familiar with report generation this will concentrate on the control break. Region number and salesperson number are not fields that we will actually do any math with so define them as alphanumeric. PREV-REGION PIC X(5) VALUE LOW-VALUES. REGION-TOTAL PIC 9(09)V99 VALUE ZERO. GRAND-TOTAL PIC 9(11)V99 VALUE ZERO. Initializations Get Date/Time Put Date/Time info to Page Headings Open Files Read 1st Input Record Repeat while not end of file If input region not = prev region If prev region is not = low-values Print region subtotals Add region subtotal to grand total Set region subtotal to 0 Move input region to prev region Print current record Add sales amount to region subtotal Read next record Termination Print region subtotals Add region subtotal to grand total Print grand totals Close Files Now, what if we also wanted salesperson subtotals (file is sorted by region number, but with region number is sorted by salesperson number)? This is a 2-level control break. PREV-SALESPERSON PIC X(5) VALUE LOW-VALUES. SALESPERSON-TOTAL PIC 9(09)V99 VALUE ZERO. Initializations Get Date/Time Put Date/Time info to Page Headings Open Files Read 1st Input Record Repeat while not end of file If input region not = prev region if prev salesperson not = low-values Print salesperson subtotals Add salesperson subtotal to region subtotal Set salesperson subtotal to 0 Move input salesperson to prev salesperson If prev region is not = low-values Print region subtotals Add region subtotal to grand total Set region subtotal to 0 Move input region to prev region if input salesperson not = prev salesperson if prev salesperson not = low-values Print salesperson subtotals Add salesperson subtotal to region subtotal Set salesperson subtotal to 0 Move input salesperson to prev salesperson Print current record Add sales amount to salesperson subtotal Read next record Termination Print salesperson subtotals Add salesperson subtotal to region subtotal Print region subtotals Add region subtotal to grand total Print grand totals Close Files