200 likes | 213 Views
Explore pseudocode algorithms for report generation, control breaks, and sequential file updates in commercial programs. Learn program structure and principles for handling common business tasks effectively.
E N D
Chapter 9 General algorithms for common business problems
Objectives • To provide general pseudocode algorithms for four common business applications. Topics covered are: • report generation with page break • single-level control break • multiple-level control break • sequential file update
9.1 Program structure
Program structure • General solution algorithm consists of mainline module and three subordinate modules. These are: • An initial processing module, containing steps to be performed at the beginning of the algorithm • A processing module inside the loop containing all the steps necessary to process records • Final processing module, containing the steps to be performed at the end of the algorithm
Program structure • This basic solution algorithm forms the framework for most commercial business programs • This general solution algorithm can be also modularised: Process_ sequential_file Perform_initial_ processing Process_ this_record Perform_final_ processing
Program structure • Skeleton solution in pseudocode looks like below: Process_sequential_file Initialise processing Read first record DOWHILE more records exist Process this record Read next record ENDDO Final processing END
9.2 Report generation with page break
Report generation with page break • Most reports require page heading lines, column heading lines, detail line and total lines • General solution algorithm for processing a sequential file can be extended by the addition of new modules that cater for there reports requirements
Report generation with page break • Hierarchy chart Print_report_ program Initialise_ variable_fields Print_page_ headings Process_ this_records Print_report_ totals Print_detail_ line Accumulate_ total_fields
9.3 Single-level control break
Single-level control break • Printed reports that also produce control break total lines are very common in business application • Control break total line is a summary line for a group of records that contain the same record, and is referred to as the control field
Single-level control break • Hierarchy chart Produce_single_ level_control_ break Initialise_ variable_fields Print_page_ headings Process_ this_records Print_report_ totals Print_control total_line Print_detail_ line Accumulate_ total_fields Reset_ control_totals
9.4 Multiple-level control break
Multiple-level control break • Reports are required to produce multiple-level control break totals • Example of a hierarchy chart shown on next slide
Multiple-level control break • Hierarchy chart Produce_multiple_ level_control_ break Initialise_ variable_fields Print_page_ headings Process_ this_records Print_minor control_totals Print_major control_totals Print_report_ totals Print_detail_ line Accumulate_ total_fields Reset_minor control_totals Reset_major control_totals
9.5 Sequential file update
Sequential file update • Master file • Is a file that contains permanent and semi-permanent information about the data entities it contains • Transaction file • Contains all the data and activities that are included on the master file. These are transactions to: • Add a new record • Update or change an existing record • Delete an existing record
Sequential file update • Audit report • Is a detailed list of all the transactions that were applied to the master file • Error report • Is a detailed list of errors hat occurred during the processing of the update
Sequential file update • Sequential update logic • Sequential processing falls generally into three categories: • If the key on the transaction record is less than the key on the old master record, the transaction is probably an add transaction • If they key on the transaction record is equal to the key on the old master record, the transaction is probably an update or delete transaction • If the key on the transaction record is greater that the key on the old master record, there is not matching transaction for that master record
Summary • Developed general hierarchy charts to four common business applications. • Applications covered were: • report generation with page break • single-level control break • multiple-level control break • sequential file update.