Presentation is loading. Please wait.

Presentation is loading. Please wait.

This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.

Similar presentations


Presentation on theme: "This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed."— Presentation transcript:

1 This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed. If you have opened this lesson in PowerPoint, use the PowerPoint menus to view it in slide show mode. If you have opened this lesson in a browser and see a bar similar to that below, click on the Slide Show icon A notice similar to the one below may appear warning that ActiveX or other scripts are disabled. Enable the controls for this website in order to see the animations.

2 The Control Break Algorithm This slide show discusses a famous algorithm for generating reports. Christine S. Wolfe Ohio University Lancaster 2008-Aug-01 Vocabulary: control break detail footer grand total header level subtotal summary

3 The report shown below is a type that is commonly found in business. It lists a set of records that are grouped together based on some common value. At the end of each group, subtotals are displayed and a grand total appears at the end. This type of report is called a “control break” report. Click Tip Control break reports are named that way because the report takes a little “break” in the processing every time the value in the “control” field changes.

4 1000100.00 1000200.00 3000210.00 1000 50.00 2000300.00 3000150.00 1000 30.00 3000 50.00 SalesmanIDAmount The data below represents the text file that contains the data for the report. If we only needed a grand total, the solution would be easy. It would be a simple loop like the ones we’ve used to calculate totals and find highest and lowest values. Total 8 1090.00

5 1000100.00 1000200.00 3000210.00 1000 50.00 2000300.00 3000150.00 1000 30.00 3000 50.00 SalesmanID Amount NumSales TotalSales 0 0 1000 100.00 1 200.00 2 300.00 1000 210.00 3000 3 510.00 8 1090.00 50.00 3000 Click through the algorithm to calculate the total amount sold.

6 1000100.00 1000200.00 1000 30.00 1000 50.00 2000300.00 3000150.00 3000 50.00 3000210.00 SalesmanIDAmount The previous example did not produce subtotals for each sales person. To calculate subtotals, the input file must first be sorted on the control field. Salesman Num Total 1000 4 380.00 2000 1 300.00 3000 3 410.00 Total 8 1090.00

7 This is the algorithm seen on slide 5 that was used to calculate the grand total.

8 The steps outlined in blue must be added to the algorithm to process the control break.

9 Key to solving a control break problem is to save the value of the control field into a holding variable so that each new record can be compared to the holding value in order to determine whether or not the control value has changed. Variables must also be declared and initialized to hold the subtotals.

10 The subtotal variables are updated at the same time and in the same way as the grand totals.

11 As each record is read, the value in the control field is compared to the holding value. If they are different it means that it is time to end one group and start another group. 3 steps make up the control break processing: The contents of the holding variables and subtotal variables are printed. The holding variable(s) are reset to the new value. The subtotal variables are reset to zero.

12 After the last record is processed, the subtotals for the last group are displayed.

13 This is another control break report. Click to see the parts of the report.

14 REPORT HEADER REPORT FOOTER GROUP HEADER GROUP FOOTER DETAIL LINE

15 group info (before read) description report header (before reads) details 1 / record report footer (after reads) Grand Totals group info (after read) Sub-Totals group info (before read) description details 1 / record group info (after read) Sub-Totals This is the only information that is read directly from the file. This is the layout of a single level control break. (You can tell it is a single level because there is only one level of grouping.) A group is a set of records that have the same value in one of their fields.

16 group header report header details report footer group footer group header details group footer This is the layout of a 2-level control break. (You can tell it is a 2- level because there are 2 levels of grouping.) group header group footer details group header details group footer details group header group footer group header details group footer details

17 Cincinnati header report header household report footer Cincinnati footer Philadelphia header Phildelphia footer Ohio header Ohio footer Columbus header Columbus footer Pennsylvania header Pennsylvania footer Pittsburgh header Pittsburgh footer household

18 Cincinnati header report header household report footer Cincinnati footer Philadelphia header Phildelphia footer Ohio header Ohio footer Columbus header Columbus footer Pennsylvania header Pennsylvania footer Pittsburgh header Pittsburgh footer household Cole household Cincinnati OH 2 Wimer household Cincinnati OH 5 Scherer household Columbus OH 3 Zang household Columbus OH 1 Smith household Philadelphia PA 4 Cramer household Philadelphia PA 4 Oktela household Pittsburgh PA 4 Fichter household Pittsburgh PA 3 Cole household Cincinnati OH 2 Wimer household Cincinnati OH 5 Zang household Columbus OH 1 Smith household Philadelphia PA 4 Cramer household Philadelphia PA 4 Oktela household Pittsburgh PA 4 Fichter household Pittsburgh PA 3 Scherer household Columbus OH 3

19 1000100.00 1000200.00 1000 30.00 1000 50.00 2000300.00 3000150.00 3000 50.00 3000210.00 ID $ Amt 1000 100.00 1000 200.00 1000 30.00 1000 50.00 ---------------------- 1000 4 380.00 2000 300.00 ---------------------- 2000 1 300.00 3000 150.00 3000 50.00 3000 210.00 ---------------------- 3000 3 410.00 ========================= Total 8 1090.00 Input Output

20 Salesman Header (none) Report header (Title, Columns) Sale (SalesmanID, Amount) Report footer (NumSales, TotalSales) Salesman Footer (NumByID, SalesByID) ID $ Amt 1000 100.00 1000 200.00 1000 30.00 1000 50.00 ---------------------- 1000 4 380.00 2000 300.00 ---------------------- 2000 1 300.00 3000 150.00 3000 50.00 3000 210.00 ---------------------- 3000 3 410.00 ========================= Total 8 1090.00 1000100.00 1000200.00 1000 30.00 1000 50.00 2000300.00 3000150.00 3000 50.00 3000210.00


Download ppt "This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed."

Similar presentations


Ads by Google