General Algorithms for Common Business Problems - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

General Algorithms for Common Business Problems

Description:

General Algorithms for Common Business Problems. Simple Program ... In this chapter you ... in a paper entitled One More Time How to Update a Master File'1 ... – PowerPoint PPT presentation

Number of Views:330
Avg rating:3.0/5.0
Slides: 18
Provided by: nate190
Category:

less

Transcript and Presenter's Notes

Title: General Algorithms for Common Business Problems


1
General Algorithms for Common Business Problems
2
Objectives
  • In this chapter you will be able to
  • Provide general pseudocode algorithms to four
    common business applications. Topics covered
    are
  • Report generation with page break
  • Single-level control break
  • Multiple-level control break
  • Sequential file update

3
Program Structure
  • The aim of this chapter is to present a number of
    general pseudocode solutions for typical
    programming problems
  • This basic solution algorithm forms the framework
    for most commercial business programs
  • It does not include processing for page headings,
    control breaks, total lines, or special
    calculations
  • Examine the hierarchy chart and pseudocode shown
    on pages 161 and 162 of the textbook

4
Report Generation with Page Break
  • Most reports require page heading lines, column
    heading lines, detail lines, and total lines
  • Reports are also required to skip to a new page
    after a predetermined number of detail lines have
    been printed
  • Examine the typical report on page 162 of the
    textbook along with the hierarchy chart and
    pseudocode of the solution algorithm on pages 162
    through 164 of the textbook

5
Single-Level Control Break
  • A control break total line is a summary line for
    a group of records that contain the same record
    key
  • There are two things you must consider when
    designing a control break program
  • The file to be processed must have been sorted
    into control field sequence
  • Each time a record is read from the input file,
    the control field on the current record must be
    compared with the control field on the previous
    record

6
Single-Level Control Break
  • A Hierarchy Chart (shown on page 165)
  • All control break report programs will require
    the following variables
  • A variable named this_control_field which will
    hold the control field of the record just read
  • A variable named prev_control_field which will
    hold the control field of the previous record
  • One or more variables to accumulate the control
    break totals
  • One or more variables to accumulate the report
    totals

7
Single-Level Control Break
  • B Solution Algorithm (shown on page 166 and
    167)
  • There are four points in this mainline algorithm
    that are essential for a control break program to
    function correctly
  • Each time a new record is read from the file, the
    new control field is assigned to the variable
    this_control_field
  • When the first record is read, the new control
    field is assigned to both the variables
    this_control_field and prev_control_field
  • The variable prev_control_field is updated as
    soon as a change in the control field is detected
  • After the end of the file has been detected, the
    module Print_control_total_line will print the
    control break totals for the last record or set
    of records

8
Multiple-Level Control Break
  • Often reports are required to produce
    multiple-level control break totals
  • The concepts that applied to a single-level
    control break program also apply to a
    multiple-level control break program
  • The general solution algorithm that was developed
    for a single-level control break program can be
    extended by the addition of two new modules to
    incorporate a two-level control break
  • A Hierarchy Chart (shown on page 169)

9
Multiple-Level Control Break
  • B Solution Algorithm (shown on pages 170
    through 172)
  • The points to be noted in this mainline are
  • Each time a new record is read from the input
    file, the new control fields are assigned to the
    variables this_minor_control_field and
    this_major_control_field
  • When the first record is read, the new control
    fields are assigned to both the current and
    previous control field variables
  • After the end of the input file has been
    detected, the two modules Print_minor_control_tota
    ls and Print_major_control_totals will print
    control totals for the last minor control field
    record, or set of records, and the last major
    control field or set of records

10
Sequential File Update
  • Sequential file updating involves updating a
    master file by applying update transactions on a
    transaction file
  • Both files are sequential
  • A new master file that incorporates the update
    transaction is produced
  • A system flowchart of a sequential update program
    is illustrated on page 173 of the textbook

11
System Concepts
  • Master File
  • A master file is a file that contains permanent
    and semi-permanent information about the data
    entities it contains
  • Transaction File
  • A transaction file contains all the data and
    activities that are included on the master file
  • If the transaction file has been designed
    specifically to update a master file, there are
    usually three types of update transactions on
    this file

12
System Concepts
  • These are transactions to
  • Add a new record
  • Update or change an existing record
  • Delete an existing record
  • Audit Report
  • An audit report is a detailed list of all the
    transactions that were applied to the master file
  • Error Report
  • An error report is a detailed list of errors that
    occurred during the processing of the update

13
Sequential Update Logic
  • Processing involves reading a record from each of
    the input files and comparing the keys of the two
    records
  • As a result of this comparison, 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 the 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
    than the key on the old master record, there is
    no matching transaction for that master record

14
Sequential Update Logic
  • Sequential update programs also need to include
    logic that will handle multiple transaction
    records for the same master record, and the
    possibility of transaction records that are in
    error
  • The types of transaction record errors that can
    occur are
  • An attempt to add a new master record when a
    record with that key already exists on the master
    file
  • An attempt to update a master record when there
    is no record with that key on the master file
  • An attempt to delete a master record when there
    is no record with that key on the master file
  • An attempt to delete a master record when the
    current balance is not equal to zero

15
Balance Line Algorithm
  • A good general solution algorithm written in
    pseudocode was presented by Barry Dwyer in a
    paper entitled One More Time How to Update a
    Master File1
  • This algorithm has been referred to as the
    balance line algorithm
  • It handles multiple transaction records for the
    one master record, as well as the possibility of
    transaction record errors
  • 1 Barry Dwyer, One More Time- How to Update a
    Master File, Comm. ACM, Vol. 124, No. 1, January
    1981.

16
Balance Line Algorithm
  • A modularized version of the balance line
    algorithm is presented in this chapter
  • A Hierarchy Chart (shown on page 176)
  • B Solution Algorithm
  • Refer to the mainline and subordinate modules
    shown on pages 176 through 179 of the textbook

17
Summary
  • The aim of this chapter was to develop general
    pseudocode algorithms to four common business
    applications
  • The applications covered were
  • Report generation with page break
  • Single-level control break
  • Multiple-level control break
  • Sequential file update
Write a Comment
User Comments (0)
About PowerShow.com