master file update processing. objectives on completing this section you should be able to: w...
TRANSCRIPT
Master File Update Processing
ObjectivesOn completing this section you should be able to:
Distinguish between online processing and batch processing.
Define the terms file maintenance and file maintenance run.
Explain the purpose of a turnaround file. Distinguish between sequential and direct
processing.
Objectives (Continued)
Design an algorithm that updates a sequential master file.
Explain how CASE tools are helping to promote code reusability and thereby increasing programmer productivity.
Introduction
Processing initiated by a user at a terminal or personal computer is said to take place in an online-processing environment.
Online programs are typically independent• input obtained directly from the user.• no other program operates on it beforehand.• output sent directly to user.• output is not used in other programs.
Introduction (Continued)
Programs designed to solve one problem at a time would probably operate in this (online) fashion.• An example might be a program to track the
location of an important package shipped to a customer.
• Another might be to track the value of an investment over time.
Introduction (Continued)
In a typical business, many programs are run on a regularly scheduled basis using large volumes of input.• Large amounts of input are collected and
processed as sets, or batches.• The processing is done by a series of interrelated
programs during a single processing run.• Each series completes one requirement.
Introduction - Batch Processing
The complete series of program forms a system.• Source documents (forms, bills, receipts, etc.)
within the system may be used to create input for one or more programs.
• Output from one program may serve as input to another.
• These programs are said to operate in a batch-processing environment.
System Flowchart for Billing
CUSTOMERBILLING
DATA
MONTHLYBILLING
PROGRAM
MONTHLYBILL
File Maintenance
We have seen that a master file is a collection of relatively permanent data.• Even “permanent” data sometimes changes:
• People move.• Prices change.• Salaries are increased.• Job title or classification changes with promotion.
• Update of master files for one or more systems is a process required everywhere.
File Maintenance (Continued)
Updating a master file is called file maintenance; execution of a program that performs file maintenance is called a file maintenance run.
For example: a publishing company stores the names, addresses, and other information about subscribers in a master name and address file.
File Maintenance Example
Weekly processing is done for such operations as:• Adding names and addresses of new
subscribers.• Deleting names and addresses of subscribers
whose subscriptions have expired.• Modifying records of current subscribers who
have renewed their subscriptions or changed their address.
File Maintenance System Flowchart
OLD MASTERN/A FILE
ADJUSTMENTS
MASTER FILEUPDATE
PROGRAM
NEWMASTER
FILE
System Flowchart
Master file update is performed by a master file update program.
Two inputs to the program:• “Old” (current) master N/A file.• Adjustments file - also known as the
transaction file - containing changes to be made to the master file.
System Flowchart (Continued)
The update program provides an updated (new) master file.
The new file will be used as input (“old” file) the next time we run this program.
This is called a turnaround file. New master file may also be used as input to
other programs - for example, for a program that prints mailing labels.
Sequential Processing
A major consideration in processing records is the order in which they are processed.
Records in a file stored on magnetic tape need to be processed in the order in which they are stored.• Takes too long to wind tape back and forth to find
the record we want.• Record is accessed only after all the ones preceding
it have been accessed.
Sequential Processing (Continued) This method is called sequential
processing. In order to maximize efficiency of
processing, the records are arranged in order by the value of a field common to all records - a key field.
The key field is typically a part number, employee number, or something similar.
Key Fields Transaction records to be used in sequential
processing with a master file must be arranged (sorted) in order by the same key field as the master file.
Processing compares the transaction key field to the master key field of successive master file records until the key fields match. If records are not in the same order few (if any) matches would occur.
Direct Processing
Master file records can also be stored on disk.
Disk file records can be accessed sequentially or directly. If processed directly, they need not be processed in order.
This is called direct or random processing. Transaction records also need not be sorted.
Sequential Master File Update
Program performs a sequential update procedure.
Assumptions (important):• Master and transaction files are in the same
sequence according to key fields (ID#-M and ID#-T, respectively).
• ID#s read from either file are in the range 1 to 10,000.
• Automatic EOF processing used on both files.
Master File Update (Continued)
Assumptions like this need to be clear in the program design and documentation.
Structure chart - see page 279.• Many modules to this program.• Some modules appear in more than one place.• Reuse of modules like this is highly desirable.
Master File Update Program
Initialization is followed by reading the first record from each input file.
Keys are compared. Three possibilities exist:• Transaction record key is less than the master
file record key. • The transaction record is added to the master file.
• Next transaction record is read.
Master File Update (Continued) Possibilities (continued):
• Transaction record key is equal to the master file record key.
• The master record is deleted or updated.• Next transaction record is read.
• Transaction record key is greater than the master record key.
• No more transactions for this master record.• Output master record to new master file.• Read next master file record.
Master File Update - Details
Overview helps but we need more details, such as:• How do we handle end-of-file processing for
two input files, when we may reach the end of one before the end of the other?
• What types of errors might occur during processing?
Overall Control ProgramA000StartProcess initialization (B000)Read master file (B010)Read transaction file (B020)IF EOF-M = 1 OR EOF-T = 1 THEN WRITE ‘No data’ messageELSE DOWHILE EOF-M = 0 OR EOF-T = 0 Process update (B030) ENDDOENDIFStop
Process Initialization (B000)
B000
Enter
EOF-M = 0
EOF-T = 0
SAVE-FLAG = 0
DELETE-FLAG = 0
Return
Read Master File (B010)B010
Enter
READ Master file record
IF EOF THEN
EOF-M = 1
ID#-M = 99999
(ELSE)
ENDIF
Return
Read Transaction File (B020)B020
Enter
READ Transaction file record
IF EOF THEN
EOF-T = 1
ID#-T = 99999
(ELSE)
ENDIF
Return
Process Update (B030)B030
Enter
DOWHILE ID#-T < ID#-M
Process Trans-key < Master-key (C000)
ENDDO
DOWHILE ID#-T = ID#-M
Process Trans-key = Master-key (C010)
ENDDO
Process Trans-key > Master-key (C020)
Return
Process Trans Key < Master KeyC000
Enter
IF CODE = ‘A’ THEN
Copy master record into save area
Copy trans record into current master record area
SAVE-FLAG = 1
ELSE
WRITE ‘Record does not exist or invalid code’
ENDIF
Read transaction file (B020)
Return
See page 285
Process Trans Key = Master KeyC010EnterCASENTRY CODE CASE ‘C’ Process change (D000) CASE ‘D’ Process delete (D010) CASE ‘A’ Process add (D020) CASE other WRITE ‘Invalid transaction code’ENDCASERead transaction file (B020)Return
Process Trans Key > Master KeyC020EnterIF DELETE-FLAG = 0 THEN WRITE new master recordELSE DELETE-FLAG = 0ENDIFIF SAVE-FLAG = 1 THEN Copy save area into current master record area SAVE-FLAG = 0ELSE Read master file (B010)ENDIFReturn
Process Change
D000
Enter
IF DELETE-FLAG = 0 THEN
Copy transaction record into current master record area
ELSE
WRITE ‘Trying to change a deleted record’
ENDIF
Return
Process Delete
D010
Enter
IF DELETE-FLAG = 0 THEN
DELETE-FLAG = 1
ELSE
WRITE ‘Trying to delete a deleted record.’
ENDIF
Return
Process Add
D020
Enter
IF DELETE-FLAG = 1 THEN
Copy transaction record into current master record area
ELSE
WRITE ‘Trying to add a record that already exists.’
ENDIF
Return
About Exam 2 ... Open book - you can use:
• Your textbook.
• Your class notes.
• Homework assignments.
Format similar to exam 1 Emphasis on topics covered since exam 1 but you
still need to know all about flowcharts and program structures (to solve the problems).
Topics We’ve Covered
Chapter 6• DOWHILE – Trailer Record Logic
• Trailer record processing• Automatic EOF processing• Headings
Chapter 7• CASE Structure
• Nested IFTHENELSE• How CASE can replace that
Topics We’ve Covered
Chapter 8• DOUNTIL Control Structure• DOUNTIL Counter-Controlled Loops• DOUNTIL vs. DOWHILE
Topics We’ve Covered
Chapter 9• Simple variables vs. subscripted variables• Manipulating single-dimensional arrays (lists)
• Input
• Output
• Other operations (averaging, etc.)
• Manipulating multi-dimensional arrays (tables)• Row-major and column-major ordering
Topics We’ve Covered Chapter 10 (Object-Oriented
Programming)• Object-oriented vs. procedure-oriented design• Terminology: see objectives and key terms• Driver program• Constructor and destructor• Inheritance and polymorphism• Base and derived classes
Topics We Have Covered
Chapter 11 - Array Applications• Loading values into a table• Sequential search of a table• Binary search of a table• Program switches• Sorting values in a table
Topics We Have Covered
Chapter 12 - Master File Update Processing• Online vs. batch processing• File maintenance and file maintenance run• Turnaround file• Sequential vs. direct processing• Update of a sequential master file• Code reusability
Grades and papers
Bring self-addressed stamped envelope for return of papers along with your grade.
Papers are kept on file for one year; records are kept (electronically) for a longer time.
Letter grades depend on your performance relative to the overall class performance.
Thank You for taking this class!