Download presentation
Presentation is loading. Please wait.
Published byAmelia Potter Modified over 9 years ago
1
Master File Update Processing
2
Objectives On completing this section you should be able to: w Distinguish between online processing and batch processing. w Define the terms file maintenance and file maintenance run. w Explain the purpose of a turnaround file. w Distinguish between sequential and direct processing.
3
Objectives (Continued) w Design an algorithm that updates a sequential master file. w Explain how CASE tools are helping to promote code reusability and thereby increasing programmer productivity.
4
Introduction w Processing initiated by a user at a terminal or personal computer is said to take place in an online-processing environment. w 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.
5
Introduction (Continued) w 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.
6
Introduction (Continued) w 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.
7
Introduction - Batch Processing w 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.
8
System Flowchart for Billing CUSTOMER BILLING DATA MONTHLY BILLING PROGRAM MONTHLY BILL
9
File Maintenance w 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.
10
File Maintenance (Continued) w Updating a master file is called file maintenance; execution of a program that performs file maintenance is called a file maintenance run. w For example: a publishing company stores the names, addresses, and other information about subscribers in a master name and address file.
11
File Maintenance Example w 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.
12
File Maintenance System Flowchart OLD MASTER N/A FILE ADJUSTMENTS MASTER FILE UPDATE PROGRAM NEW MASTER FILE
13
System Flowchart w Master file update is performed by a master file update program. w 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.
14
System Flowchart (Continued) w The update program provides an updated (new) master file. w The new file will be used as input (“old” file) the next time we run this program. w This is called a turnaround file. w New master file may also be used as input to other programs - for example, for a program that prints mailing labels.
15
Sequential Processing w A major consideration in processing records is the order in which they are processed. w 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.
16
Sequential Processing (Continued) w This method is called sequential processing. w 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. w The key field is typically a part number, employee number, or something similar.
17
Key Fields w 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. w 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.
18
Direct Processing w Master file records can also be stored on disk. w Disk file records can be accessed sequentially or directly. If processed directly, they need not be processed in order. w This is called direct or random processing. w Transaction records also need not be sorted.
19
Sequential Master File Update w Program performs a sequential update procedure. w 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.
20
Master File Update (Continued) w Assumptions like this need to be clear in the program design and documentation. w 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.
21
Master File Update Program w Initialization is followed by reading the first record from each input file. w 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.
22
Master File Update (Continued) w 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.
23
Master File Update - Details w 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?
24
Overall Control Program A000 Start Process initialization (B000) Read master file (B010) Read transaction file (B020) IF EOF-M = 1 OR EOF-T = 1 THEN WRITE ‘No data’ message ELSE DOWHILE EOF-M = 0 OR EOF-T = 0 Process update (B030) ENDDO ENDIF Stop
25
Process Initialization (B000) B000 Enter EOF-M = 0 EOF-T = 0 SAVE-FLAG = 0 DELETE-FLAG = 0 Return
26
Read Master File (B010) B010 Enter READ Master file record IF EOF THEN EOF-M = 1 ID#-M = 99999 (ELSE) ENDIF Return
27
Read Transaction File (B020) B020 Enter READ Transaction file record IF EOF THEN EOF-T = 1 ID#-T = 99999 (ELSE) ENDIF Return
28
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
29
Process Trans Key < Master Key C000 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
30
Process Trans Key = Master Key C010 Enter CASENTRY CODE CASE ‘C’ Process change (D000) CASE ‘D’ Process delete (D010) CASE ‘A’ Process add (D020) CASE other WRITE ‘Invalid transaction code’ ENDCASE Read transaction file (B020) Return
31
Process Trans Key > Master Key C020 Enter IF DELETE-FLAG = 0 THEN WRITE new master record ELSE DELETE-FLAG = 0 ENDIF IF SAVE-FLAG = 1 THEN Copy save area into current master record area SAVE-FLAG = 0 ELSE Read master file (B010) ENDIF Return
32
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
33
Process Delete D010 Enter IF DELETE-FLAG = 0 THEN DELETE-FLAG = 1 ELSE WRITE ‘Trying to delete a deleted record.’ ENDIF Return
34
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
35
About Exam 2... w Open book - you can use: Your textbook. Your class notes. Homework assignments. w Format similar to exam 1 w Emphasis on topics covered since exam 1 but you still need to know all about flowcharts and program structures (to solve the problems).
36
Topics We’ve Covered w Chapter 6 DOWHILE – Trailer Record Logic Trailer record processing Automatic EOF processing Headings w Chapter 7 CASE Structure Nested IFTHENELSE How CASE can replace that
37
Topics We’ve Covered w Chapter 8 DOUNTIL Control Structure DOUNTIL Counter-Controlled Loops DOUNTIL vs. DOWHILE
38
Topics We’ve Covered w 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
39
Topics We’ve Covered w 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
40
Topics We Have Covered w 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
41
Topics We Have Covered w 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
42
Grades and papers w Bring self-addressed stamped envelope for return of papers along with your grade. w Papers are kept on file for one year; records are kept (electronically) for a longer time. w Letter grades depend on your performance relative to the overall class performance.
43
Thank You for taking this class!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.