130 likes | 243 Views
Chapter 10. Designing and Writing Control-Break Programs. Types of Reports. Detail or Transaction Reports Include one or more lines of output for each input record read Exception Reports Printout of individual records that meet (or fail to meet) certain criteria Summary Reports
E N D
Chapter 10 Designing and Writing Control-Break Programs
Types of Reports • Detail or Transaction Reports • Include one or more lines of output for each input record read • Exception Reports • Printout of individual records that meet (or fail to meet) certain criteria • Summary Reports • Summarizes rather than itemizes to provide more comprehensive information
Topics • Single-Level Control-Break Programs • Sequence of input records is important • Data is sorted on the control-break field • Multiple-level Control-Break Programs • Input data is sorted on two or more fields • Control-Break is Similar to Page Breaks
Control-Break Processing • The input data must be sorted • (Note: Chapter 13 covers detail of how your program can sort a file) • For now, we will assume the input file is already sorted (i.e., Sales Rep Number) • It could be sorted on two or three fields
Processing Logic • Loop until EOF • Read record • If First-Record Set the Saved-Ctrl-Nbr • If Ctrl-Nbr not equal Saved-Ctrl-Nbr • Print Ctrl-break totals • Reset Ctrl-break totals • Set the Saved-Ctrl-Nbr • Process record • Print Ctrl-break Totals
Processing Logic • When the “Next Record” does not match the Saved Control Number • Print the control-break total • Reset accumulators • Don’t forget about page break processing • Two types of Print Lines: • Detail Line • Control-break Total Line • At EOF, print last Control-break Total
Complex Programs • Suppose there are two, or even three, control fields • The input file must be sorted on all fields (sorted in the proper sequence) • Sub-totals for each control-break
Complex Programs • Input Data: • State, Branch, Sales Rep Number, other data • AR 01 001 ...AR 01 001 ...AR 01 002 ...AR 02 002 ...AR 03 001 ...AR 03 004 ...KY 02 002 ...KY 02 003 ...KY 02 003 ...KY 03 001 ...KY 03 002 ...KY 04 008 ...KY 04 010 ...