Chapter 15 Control Breaks System Concepts Control break
Chapter 15 – Control Breaks • System Concepts – Control break • Control field – What its being sorted on • Control total – Produces this when a control break is encountered • Multiple control breaks – Major field – Minor field – Intermediate field • Running versus rolling totals 1
Figure 15. 1 Transaction File. (The sales amount shows ASCII rather than EBCDIC Characters Acct Num Salesperson Sales Amount Comm Pct Location Region 000069 000100 000101 000104 100000 130101 203000 248545 277333 400000 444333 444444 475365 476236 476530 555555 555666 576235 583645 649356 694446 700039 750020 800396 878787 987654 988888 999340 BENWAY HUMMER CLARK JOHNSON CLARK HAAS JOHNSON ADAMS FEGEN HAAS FEGEN BENWAY FEGEN ADAMS CLARK KARLSTROM HUMMER MARCUS KARLSTROM JOHNSON ADAMS BENWAY 023! 010’ 1500 030# 3200 8900 0345 009( 070) 100% 0100 0333 037& 023% 0304 2003 0100 0145 0345 0904 0932 0305 3030 1235 2005 0450 0334 10 05 10 03 06 20 05 14 08 08 01 02 05 03 05 05 20 03 04 05 10 10 05 09 12 10 01 30 CHICAGO TRENTON ST. PETERSBURG TRENTON ST. LOUIS ST. PETERSBURG NEW YORK ST. PETERSBURG ST. LOUIS ST. PETERSBURG CHICAGO ST. PETERSBURG NEW YORK TRENTON BALTIMORE CHICAGO BALTIMORE ST. PETERSBURG NEW YORK CHICAGO MIDWEST NORTHEAST SOUTHEAST NORTHEAST MIDWEST SOUTHEAST NORTHEAST SOUTHEAST MIDWEST NORTHEAST NORTHEAST MIDWEST NORTHEAST SOURHEAST NORTHEAST MIDWEST 2
Figure 15. 2 444333 555666 987654 000069 476530 988888 999340 000101 000104 130101 576235 444444 476236 555555 203000 277333 475365 000100 649356 694446 100000 248545 400000 878787 583645 800396 700039 750020 ADAMS BENWAY CLARK FEGEN HAAS HUMMER JOHNSON KARLSTROM MARCUS 100% 2003 2005 023! 023% 450 0334 1500 0500 3200 0100 037& 0304 8900 009( 0333 010’ 0345 0904 030# 0345 070) 1235 0145 3030 0932 0305 (a) Sorted Data (by Salesperson) 01 20 10 10 05 01 30 10 03 20 03 02 03 05 05 08 05 05 05 10 06 14 08 12 04 09 10 05 One-level Control Break One-level control break SALES ACTIVITY REPORT PAGE 3 SALESPERSON: CLARK ACCOUNT # SALES COMMISSION 444333 1, 00510555666 SALES ACTIVITY REPORT 2, 003 PAGE 401 2 987654 2. 005 201 SALESPERSON: BENWAY -------** SALESPERSON TOTAL $ 3, 003 COMMISSION $ 582 ACCOUNT # SALES 444333 1, 00510 SALES ACTIVITY REPORT PAGE 1401 555666 2, 003 987654 2. 005 201 SALESPERSON: ADAMS -------** SALESPERSON TOTAL $ 3, 003 COMMISSION $ 582 ACCOUNT # SALES 444333 1, 00510555666 2, 003 401 987654 2. 005 201 -------** SALESPERSON TOTAL $ 3, 003 $ 582 (b) Partial Output 3
Figure 15. 3 583645 800396 700039 750020 000069 476530 988888 999340 000100 649356 694446 444333 555666 987654 203000 277333 475365 444444 476236 555555 100000 248545 400000 878787 000101 000104 130101 576235 KARLSTROM MARCUS BENWAY HUMMER ADAMS HAAS FEGEN JOHNSON CLARK 0145 3030 0932 0305 023! 023% 0450 0334 010’ 0345 0904 100% 2003 2005 8900 009( 0333 0100 037& 0304 030# 0345 070) 1235 1500 0500 3200 0100 04 09 10 05 01 30 05 05 10 01 20 10 05 08 05 02 03 05 06 14 08 12 10 03 20 03 Two-level Control Break BALTIMORE CHICAGO CHICAGO NEW YORK ST. LOUIS ST. PETERSBURG ST. PETERSBURG TRENTON One-level control breaks (minor key) Two-level control break (major key) (a) Sorted Data (by Location and Salesperson) 4
Figure 15. 3 Two-level Control Break SALES ACTIVITY REPORT PAGE 3 LOCATION: NEW YORK SALESPERSON: ADAMS ACCOUNT # 583645 SALES ACTIVITY REPORT 800396 SALES COMMISSION 145 PAGE 2 6 3, 030 273 -------LOCATION: CHICAGO ** SALESPERSON TOTAL $ 3, 175 $ 279 SALESPERSON: KARLSTROM ACCOUNT # SALES COMMISSION # 145 SALES 6 583645 ACCOUNTPAGE SALES ACTIVITY REPORT 1 6 800396583645 3, 030 145 273 800396 3, 030 273 ------LOCATION: BALTIMORE ** SALESPERSON TOTAL $ 3, 175 -------$ 279 ------SALESPERSON: **KARLSTROM SALESPERSON TOTAL $ 3, 175 $ 279 ACCOUNT # SALES COMMISSION 583645 145 6 SALESPERSON: MARCUS 800396 3, 030 273 ACCOUNT # SALES COMMISSION -------700039 932 93 ** SALESPERSON TOTAL $ 3, 175 $ 279 7500020 305 15 ------SALESPERSON: MARCUS ** SALESPERSON TOTAL $ 1, 237 $ 108 ACCOUNT # SALES COMMISSION 700039 932 93 **** LOCATION TOTAL $ 4, 412 $ 387 7500020 305 15 ------** SALESPERSON TOTAL $ 1, 237 $ 108 **** LOCATION TOTAL $ 4, 412 (b) Partial Output $ 387 5
Figure 15. 4 10 05 01 30 05 05 10 Three-level Control Break 000069 476530 988888 999340 000100 649356 694446 BENWAY HUMMER 023! 023% 0450 0334 010’ 0345 0904 203000 277333 475365 HAAS 8900 05 ST. LOUIS 009( 08 ST. LOUIS 0333 05 ST. LOUIS MIDWEST 583645 00396 700039 750020 444333 555666 987654 000101 000104 130101 576235 444444 476236 555555 100000 248545 400000 878787 KARLSTROM MARCUS ADAMS CLARK FEGEN JOHNSON 0145 3030 0932 0305 100% 2003 2005 1500 0500 3200 0100 037& 0304 030# 0345 070) 1235 NORTHEAST NORTHEAST NORTHEAST SOUTHEAST SOUTHEAST 04 09 10 05 01 20 10 10 03 20 03 02 03 05 06 14 08 12 CHICAGO CHICAGO BALTIMORE NEW YORK TRENTON ST. PETERSBURG ST. PETERSBURG MIDWEST MIDWEST One-level control breaks (tertiary key) Two-level control breaks (secondary key) Three-level control break (primary key) (a) Sorted Data (by Region, Location, and Salesperson) 6
SALES ACTIVITY REPORT PAGE 3 REGION: SOUTHEAST SALES ACTIVITY REPORT PAGE 2 LOCATION: ST. PETERSBURG SALESPERSON: BENWAY REGION: NORTHEAST ACCOUNT # SALES COMMISSION LOCATION: BALTIMORE 000069 23123 SALESPERSON: BENWAY 476530 23512 SALES ACTIVITY REPORT PAGE 1 ACCOUNT # 988888 SALES COMMISSION 450 5 000069 23123999340 334 100 REGION: MIDWEST 476530 23512 -------LOCATION: CHICAGO 988888 450 5 ** SALESPERSON TOTAL $ 318 $ 70 SALESPERSON: BENWAY 999340 334 100 ACCOUNT # SALES COMMISSION -------SALESPERSON: HUMMER 000069 23123** SALESPERSON TOTAL $ 318 $ 70 COMMISSION ACCOUNT # SALES 476530 23512000100 1075988888 450 5 SALESPERSON: HUMMER 649356 345 17 999340 334 100 ACCOUNT SALES 904 90 ---- # 694446 ------- COMMISSION 000100 1075 -------** SALESPERSON TOTAL $ 318 $ 70 649356 TOTAL 345 17 ** SALESPERSON $ 1, 142 $ 102 694446 904 90 SALESPERSON: HUMMER -------**** LOCATION TOTAL COMMISSION $ ------1, 460 $ 172 ACCOUNT # SALES ** SALESPERSON TOTAL $ 1, 142 $ 102 000100 1075 LOCATION: 649356 ST. LOUIS 345 17 **** LOCATION TOTAL SALESPERSON: $ 90 1, 460 $ 172 BENWAY 694446 904 ACCOUNT # SALES COMMISSION -------LOCATION: ST. LOUIS 203000 8, 900 445 ** SALESPERSON TOTAL $ 1, 142 $ 102 SALESPERSON: BENWAY 277333 988 ACCOUNT # SALES COMMISSION 475365 333 17 **** LOCATION TOTAL $ 1, 460 $ 172 203000 8, 900 445 -------277333 988** SALESPERSON TOTAL $ 9, 135 $ 454 LOCATION: ST. LOUIS 475365 333 17 **** LOCATION TOTAL $ 9, 135 $ 454 SALESPERSON: BENWAY -------ACCOUNT # SALES COMMISSION ** SALESPERSON TOTAL $ 445 9, 135 454 ****** REGION TOTAL 8, 900 $ $10, 595 $ 626 203000 **** LOCATION TOTAL $ 9, 135 $ 454 277333 988475365 333 17 ****** REGION TOTAL $------10, 595 $ 626 -------** SALESPERSON TOTAL $ 9, 135 $ 454 **** LOCATION TOTAL $ 9, 135 $ 454 ****** REGION TOTAL $ 10, 595 $ 626 (b) Partial Output 7
• Define the following – Control group – Control field – Control break 8
1. 2. 3. What would happen if step 7 were deleted and the group totals were initialized to zero before step 5. If step 15 were deleted, what step would have to be included in the inner loop and where would it go. What changes would have to be made in the algorithm in order not to print any output except headings, group totals, and final totals? 9
Assume that an input file contains 100 records. There are four control groups in the file. Referring the previous control break algorithm how many times will each of the following steps be performed during processing. 1. Step 2 2. Step 6 3. Step 12 4. Step 14 10
- Slides: 10