Presentation is loading. Please wait.

Presentation is loading. Please wait.

Any Questions? Control Breaks Agenda Control Breaks –Also known as Reports with sub-totals.

Similar presentations


Presentation on theme: "Any Questions? Control Breaks Agenda Control Breaks –Also known as Reports with sub-totals."— Presentation transcript:

1

2 Any Questions? Control Breaks

3 Agenda Control Breaks –Also known as Reports with sub-totals.

4 Report Types Transaction Reports Summary or Group Reports Exception Reports

5 Control Break Occurs when there is a change in key fields when reading sequentially through a file

6 Customer Accounts Date: 05/04/05Page: 999 Date Amount Customer: 1015 Cindy Laurin 05/01/00$100.00 05/02/00$200.00 05/03/00$300.00 * Totals: 1015 Cindy Laurin $600.00 Customer: 1016 Bruce Nugent 05/01/00$100.00 * Totals: 1016 Bruce Nugent$100.00 ** Totals: All Customers $700.00 *** End of Report Where’s the Control Break?

7 What do you do at a Control Break? Print the totals for the save or previous key Initialize the accumulators used for the group or level Print headings for the new or file key

8 Single Control Breaks Example QGPL/CHAP8AS4 contains all a record for each student enrolled in College X. Each student’s record lists their name, student number, school, class, GPA and number of credits. Your task is to produce a Summary Report listing Average GPAs for each school to find out which school has the easier program.

9 Steps to solve problem Create a logical file over CHAP8AS4 that sorts the data in School Sequence. Write a Control Break program that calculates and prints the average for each school.

10 Single Control Break (using ifs) Read the First Record (check for EOF) If not EOF Write the heading for file-key Move file-key to save-key Do While not End of File If save-key  file-key Calculate & Write totals for save-key Initialize Accumulators Move file-key to save-key Write headings for file-key Process Record Read the next Record (check for EOF) ENDDO Calculate & Write totals for save-key

11 Single Control Break (Using Nested Loops) Read the First Record (check for EOF) Do While not End of File Write the heading for file-key Move file-key to save-key Do While file-key = save-key and not EOF Process Record Read the next record (check for EOF) ENDDO Calculate & Write totals for save-key Initialize Accumulators ENDDO

12 Multiple Control Breaks Example QGPL/CHAP8AS4 contains all a record for each student enrolled in College X. Each student’s record lists their name, student number, school, class, GPA and number of credits. Your task is to produce a Summary Report listing Average GPAs for each class and school to find out which school has the easier program.

13 Steps to solve problem Create a logical file over CHAP8AS4 that sorts the data in School & Class Sequence. School is the Primary or Major Key Class is the Secondary or Minor Key Write a Control Break program that calculates and prints the average for each class & school.

14 Multiple Control Breaks (Using Ifs) Read the First Record (check for EOF) If not EOF Write the headings for file-key Move file-key to save-key Do While not End of File If save-Primary-key  file-Primary-key Calculate & Write totals for save-Secondary-key Calculate & Write totals for save-Primary-key Initialize Primary & Secondary Accumulators Move file-key to save-key Write headings for Primary & Secondary file-keys If save-Secondary-key  file-Secondary-key Calculate & Write totals for save-Secondary-key Initialize Secondary Accumulators Move file-Secondary-key to save-Secondary-key Write headings for file-Secondary-key Process Record Read the next Record (check for EOF) ENDDO Calculate & Write totals for save-Secondary-key Calculate & Write totals for save-Primary-key

15 Multiple Control Breaks (Using Nested Loops) Read the First Record (check for EOF) Do While not End of File Write the headings for file-Primary-key Move file-Primary-key to save-Primary-key Do While not EOF and file-Primary-key = save-Primary-key Write headings for file-Secondary-key Move file-Secondary-key to save-Secondary-key Do While not EOF and file-Secondary-key = save-Secondary-key and file-Primary-key = save-Primary-key Process Record Read the next record (check for EOF) ENDDO Calculate & Write totals for save-Secondary-key Initialize Secondary Accumulators ENDDO Calculate & Write totals for save-Primary-key Initialize Primary Accumulators ENDDO

16 Next Class


Download ppt "Any Questions? Control Breaks Agenda Control Breaks –Also known as Reports with sub-totals."

Similar presentations


Ads by Google