1 / 15

Any Questions?

Any Questions?. Control Breaks. Agenda. Control Breaks Also known as Reports with sub-totals. Report Types. Transaction Reports Summary or Group Reports Exception Reports. Control Break. Occurs when there is a change in key fields when reading sequentially through a file.

sjordon
Télécharger la présentation

Any Questions?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Any Questions? Control Breaks

  2. Agenda • Control Breaks • Also known as Reports with sub-totals.

  3. Report Types • Transaction Reports • Summary or Group Reports • Exception Reports

  4. Control Break • Occurs when there is a change in key fields when reading sequentially through a file

  5. Where’s the Control Break? Customer Accounts Date: 05/04/05 Page: 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

  6. 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

  7. 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.

  8. 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.

  9. 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

  10. 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

  11. 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.

  12. 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.

  13. 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

  14. 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

  15. Next Class

More Related