310 likes | 440 Views
Sequential Processing to Update a File. Please use speaker notes for additional information!.
E N D
Sequential Processing to Update a File Please use speaker notes for additional information!
EDIT: The transactions that will be used in the update must be as error free as possible to prevent corrupting the master file. To assure the integrity of the data, the transactions should be processed in an edit program and only valid transactions should be allowed to update the master file. The output of the edit file includes the valid (good) transaction file which will be processed in the next step. SORT: The master file is in some kind of order - the usual order is by identification number. The transaction file must be in the same order as the master file. The sort program sorts the valid transactions and creates a sorted valid transaction file. UPDATE:The update program uses the sorted valid transaction file to update the master file, creating a new master file and reports. In a maintenance update there can be add, change or delete transactions so records can be added to the new master, changed on the new master, or deleted so they do not appear on the new master. The update program completes the updating maintenance cycle. Update Sequential Updating
Steps to update Sorted Valid Trans Valid Trans Data Edit Program Sort Errors can be put on disk, printed, interactively corrected or any combination of solutions. Update Program Master File New Master File Errors Trail Note: Errors can be written to disk, printed, interactively corrected or any combination of solutions. An optional paper trail can also be produced on disk, paper or another medium.
EDIT Program Valid Trans Data Data Edit Program Valid Trans Edit Program Trans with Errors Errors Trans with Errors Errors and/or and/or This processing where the data is entered and errors are produced is frequently done by data entry operators who enter the data quickly and accurately. The errors will be reprocessed and reentered at a later date. This processing can be done interactively. In that case, the data entry person is frequently someone who is knowledgeable about the data and can fix the errors that are shown on the screen. Only errors that cannot be fixed are put to either disk/report or both.
Sort Program Sorted Valid Trans Valid Trans Sort When you are going to do a Sequential Update, the transactions must be sorted so they are in the same order as the records on the file that you are going to update. Since you are going to process each file sequentially, one record at a time, it is critical that they be in the same order.
SEQUENTIAL UPDATE: • Information that is kept on files needs to be modified as changes to the information on the file occur. This process is called UPDATING and the files that are being updated are usually called MASTER FILES. Updating allows the company to keep a file up-to-date. Without an update, the file would be obsolete shortly after it was created. • Updating a file can involve the following: • Adding records to the file • Changing records on the file • Deleting records from the file • Add, change, and delete transactions that will be used to update the master file are either keyed in and saved on a transaction file or keyed in from a screen. Frequently the screen input is also saved on a file to provide a trail of transactions. That transaction file will be processed with the master file to update the file. Sequential Update Program Sorted Valid Trans Update Program Master File New Master File Errors Trail
Flowchart Process Mainline Read old master Initialize Read transactions Process Wrapup MID & TID not EOF(9s) LOOP Y Stop Run N Wrapup End Process Initialize Close files Open files End Wrapup End Initialize
Logic flowchart continued Loop MID < TID N Y MID =TID N Write routine Y Add N Y Change N Y Change Read old master N Y Add Routine (includes write) Delete Change Routine N Y Delete Routine Add Error Read transaction Delete Error Change Error Read transaction Read transaction Read transaction Read transaction Read transaction Read old master
Logic flowchart continued Change Routine Delete Routine Note that I am writing to the report for a paper trail. Record deleted written on report. Write Routine Record old to report (optional) Write new master from master work End Delete Routine Field1 not spaces N Y End Write Routine Add Routine Last field1 = “-” N Y Record added written on report. Trans data to field1 in master work Space out field1 in master work Write new master from add trans End Add Routine NOTE: Repeat the check illustrated above for all fields that could be changed. Record changes to report (trail). End Change Routine
Logic flowchart continued Delete Error Routine Read Old Master Routine Read old master MOVE all 9s to MID Record delete error written on report. Add Error Routine Record add error written on report. End Delete Error Routine End Read Old Master Routine End Add Error Routine Wrapup Routine Read Trans Routine Close all files Change Error Routine Read transaction MOVE all 9s to TID End Wrapup Routine Record change error written on report. End Change Error Routine End Read Trans Routine
OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... We are going to assume that these are the files we are reading. The … stands for the data on the file. In looking at the logic for processing we are going to focus on comparing the id numbers on the two files and the transaction code which tells us whether the transaction is designed to add a record, change a record or delete a record. The output that is produced will be a new master file with the valid additions, changes and deletions made and an error report with a trail of the invalid add, changes and deletes.
Sample files OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER ERROR REPORT The first record from each file is read. MID =121, TID = 121. Therefore MID = TID. Since the transaction code is a C, the change is made in the work area. Since the transaction has now been handled, a new transaction will be read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121... ERROR REPORT MID = 121 and TID =124 therefore MID < TID. When this happens we write the old record (in this case complete with the changes that were made based on the previous transaction) to the new master. A record will now be read from the old master file.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123... ERROR REPORT MID = 123 and TID =124 therefore MID < TID. When this happens we write the old record (in this case it is a record that has no changes) to the new master. A record will now be read from the old master file.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124... ERROR REPORT MID = 222 and TID =124 therefore MID > TID. Now we need to check the transaction code. It is an A. This is the situation where it is valid to ADD a record so the information from record with TID=124 will be written to the new master. Since this transaction has now been processed, a new transaction will be read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124... ERROR REPORT MID = 222 and TID =222 therefore MID = TID. When we check the transaction code we find that it is a C and matching identification numbers is what we need to make a change. The change will get made in the work area. Since this transaction has now been processed, a new transaction will be read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124... ERROR REPORT MID = 222 and TID =222 therefore MID = TID. When we check the transaction code we find that it is a C and matching identification numbers is what we need to make a change. The change will get made in the work area. Since this transaction has now been processed, a new transaction will be read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222... ERROR REPORT MID = 222 and TID =333 therefore MID < TID. This means we should write the old master record - complete with changes from the two transactions - on to the new master file. Since we have not processed the new transaction but we are done with the master, we will now read another master record.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… ERROR REPORT MID = 234 and TID =333 therefore MID < TID. This means we should write the old master record on to the new master file. Since we have not processed the new transaction but we are done with the master, we will now read another master record.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… ERROR REPORT MID = 333 and TID =333 therefore MID = TID. This means that a delete is valid Since a delete involves dealing with the master and the transaction, we read a new record from each table.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… 345... ERROR REPORT MID = 345 and TID =350 therefore MID < TID. This means that 345 will be written to the new master. Since the master has been dealt with, a new master is read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… 345... ERROR REPORT 350… MID = 444 and TID =350 therefore MID > TID. We need to check the transaction code. Since it is a C the fact that they are not equal means that this is an invalid change. The change error is written the error report. Since the transaction has been handled (as an error), another transaction is read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… 345... ERROR REPORT 350… 444... MID = 444 and TID =444 therefore MID = TID. We need to check the transaction code. Since it is a A, the fact that they are equal means that this is an invalid change. The add error is written on the error report. Since the transaction has been handled (as an error), another transaction is read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… 345… 444... ERROR REPORT 350… 444… MID = 444 and TID =450 therefore MID < TID. Since the master is the smallest it will be processed. That means that 444 is copied to the new master. Since the master has been dealt with, a new master will be read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… 345… 444... ERROR REPORT 350… 444… 450... MID = 456 and TID =450 therefore MID >TID. In this condition, a Delete is invalid. Therefore 450 is written to the error report. A new transaction record will be read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… 345… 444… 456... ERROR REPORT 350… 444… 450... MID = 456 and TID =999 therefore MID < TID. Since the master is less it will be copied to the new master. Another master record will be read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… 345… 444… 456… 512... ERROR REPORT 350… 444… 450... MID = 512 and TID =999 therefore MID < TID. Since the master is less it will be copied to the new master. Another master record will be read.
Logic continued OLD MASTER 121... 123… 222... 234… 333... 345… 444... 456… 512… 999... TRANSACTIONS 121… C 124… A 222… C 222… C 333… D 350… C 444… A 450… D 999... NEW MASTER 121… 123… 124… 222… 234… 345… 444… 456… 512... ERROR REPORT 350… 444… 450... MID = 999 and TID =999 therefore MID = TID and more importantly they both = 999. This means that end of file has been reached on both files and processing will terminate.