Sequential Processing to Update a File

31
Sequential Processing to Update a File Please use speaker notes for additional information!

description

Sequential Processing to Update a File. Please use speaker notes for additional information!. - PowerPoint PPT Presentation

Transcript of Sequential Processing to Update a File

Page 1: Sequential Processing to  Update a File

Sequential Processing to Update a File

Please use speaker notes for additional information!

Page 2: Sequential Processing to  Update a File

Sequential Updating• 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.

UpdateUpdate

Page 3: Sequential Processing to  Update a File

Steps to updateSteps to update

Data EditProgram

SortedValidTrans

SortValidTrans

Errors can be put on disk, printed, interactively corrected or any combination of solutions.

MasterFile

UpdateProgram

NewMaster

File

Errors

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.

Trail

Page 4: Sequential Processing to  Update a File

EDIT program 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 process includes the valid transaction file which will be processed in the next step. Errors are dealt with in a variety of ways including printed reports and files containing error transactions.

SORT program The master file is in some kind of order - the usual order is by some kind of 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. Note that sometimes there is no separate sort program. The sort can be done at the end of the edit program or the valid transaction file or at the beginning of the update program before the actual updating begins.

UPDATE program The update program uses the sorted valid transaction file to update the master file creating a new master file and reports. At a minimum, there is an error report. There is frequently another report that provides a trail of the processing. The updating program completes the updating maintenance cycle. Errors will be handled during the next or a special run.

Page 5: Sequential Processing to  Update a File

Data EditProgram Valid

Trans

EDIT ProgramEDIT Program

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.

Transwith

Errors

Errors

EditProgram Valid

TransData

Transwith

Errors

Errors

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.

and/or

and/or

Page 6: Sequential Processing to  Update a File

Sort ProgramSort Program

SortedValidTrans

SortValidTrans

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.

Page 7: Sequential Processing to  Update a File

SortedValidTrans

MasterFile

UpdateProgram

NewMaster

File

Errors Trail

Sequential Update Program

Sequential Update Program

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 fileChanging records on the fileDeleting 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.

Page 8: Sequential Processing to  Update a File

There are two kinds of business updating. One is the classic concept of maintenance updating where information is added, changed and deleted. For example, at a college, maintenance updating is done to add new students to the file, delete students that have dropped out and make changes to student/s records where the student changes majors, courses etc. In an inventory situation, maintenance updating involves adding new products, deleting products you no longer are going to carry and changing things like cost, price, vendor etc. Another kind of updating is production updating that occurs during processing and usually involves just changes. For example, in inventory when a sale is made, the on hand in inventory is updated to reflect that there are less items on hand or in accounts receivable when a payment is received, the amount owed is updated to reflect the payment. This handout will deal with maintenance updating because it is the most comprehensive type.

Sequential UpdateSequential Update

Page 9: Sequential Processing to  Update a File

Tran Code = A Tran Code = C Tran Code = D

MID<TID

Since the master is less than the transaction, there is no activity for that master. The master record is simply written on the new master file. Note: If the master has already been changed, be sure to write the changed version. A read is done on the input master file to get the next master record.

MID=TID Invalid add transaction (can't add a record that is already there). Error written to report. New transaction read.

Valid change transaction -changes made to master record in memory. New transaction read.

Valid delete transaction - record not written to new master. Master read. New transaction read.

MID>TID Valid add transaction. Record is written to the new master. New transaction is read.

Invalid change transaction (no matching record). Error written to report New transaction read.

Invalid delete transaction (no matching record). Error written to report New transaction read.

Sequential Update Logic

Sequential Update Logic

Page 10: Sequential Processing to  Update a File

FlowchartFlowchart

Mainline

Initialize

Process

Wrapup

Stop Run

Initialize

Process

End Process

End Initialize

Open files

Read oldmaster

Read transactions

MID & TIDnot EOF(9s)

LOOPY

N

Wrapup

End Wrapup

Close files

Page 11: Sequential Processing to  Update a File

Logic flowchart continued

Logic flowchart continued Loop

MID < TID

Writeroutine

Read oldmaster

YN

MID =TID

Change

ChangeRoutine

Readtransaction

Y

Y

Y

N

N

Delete

DeleteRoutine

Readtransaction

AddError

Readtransaction

Read oldmaster

YN

Add

AddRoutine(includes

write)

Readtransaction

Change

ChangeError

Readtransaction

DeleteError

Readtransaction

Y

N

N

Page 12: Sequential Processing to  Update a File

Logic flowchart continued

Logic flowchart continued

Write Routine

Write new master from master work

EndWrite Routine

Change Routine

Record old to report (optional)

Field1 notspaces

Last field1= “-”

Space out field1 in

master work

N Y

YN

Trans datato field1 in

master work

NOTE: Repeat the check illustrated above for all fields that could be changed.

Record changes to report (trail).

EndChange Routine

Delete Routine

Record deletedwritten on report.

EndDelete Routine

Add Routine

End Add Routine

Record addedwritten on report.

Write new master from

add trans

Note that I am writing to the report for a paper trail.

Page 13: Sequential Processing to  Update a File

Logic flowchart continued

Logic flowchart continued

AddError Routine

Record add errorwritten on report.

End AddError Routine

ChangeError Routine

Record change errorwritten on report.

End ChangeError Routine

Delete Error Routine

Record delete errorwritten on report.

End Delete Error Routine

Wrapup Routine

Close all files

EndWrapup Routine

Read OldMaster Routine

End Read OldMaster Routine

Read oldmaster

MOVE all 9s to MID

Read Trans Routine

End Read TransRoutine

Readtransaction

MOVE all 9s to TID

Page 14: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

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.

Page 15: Sequential Processing to  Update a File

Sample filesSample files

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER ERRORERROR REPORT 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.

Page 16: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121...

ERRORERROR REPORT 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 continuedLogic continued

Page 17: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123...

ERRORERROR REPORT 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 continuedLogic continued

Page 18: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124...

ERRORERROR REPORT 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 continuedLogic continued

Page 19: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124...

ERRORERROR REPORT 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 continuedLogic continued

Page 20: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124...

ERRORERROR REPORT 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 continuedLogic continued

Page 21: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222...

ERRORERROR REPORT 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 continuedLogic continued

Page 22: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

ERRORERROR REPORT 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 continuedLogic continued

Page 23: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

ERRORERROR REPORT 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 continuedLogic continued

Page 24: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

345...

ERRORERROR REPORT 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 continuedLogic continued

Page 25: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

345...

ERRORERROR REPORT 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 continuedLogic continued

Page 26: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

345...

ERRORERROR REPORT 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 continuedLogic continued

Page 27: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

345…

444...

ERRORERROR REPORT 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 continuedLogic continued

Page 28: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

345…

444...

ERRORERROR REPORT 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 continuedLogic continued

Page 29: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

345…

444…

456...

ERRORERROR REPORT 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 continuedLogic continued

Page 30: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

345…

444…

456…

512...

ERRORERROR REPORT 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 continuedLogic continued

Page 31: Sequential Processing to  Update a File

OLD MASTEROLD MASTER

121...

123…

222...

234…

333...

345…

444...

456…

512…

999...

TRANSACTIONSTRANSACTIONS

121… C

124… A

222… C

222… C

333… D

350… C

444… A

450… D

999...

NEW MASTERNEW MASTER

121…

123…

124…

222…

234…

345…

444…

456…

512...

ERRORERROR REPORT 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.

Logic continuedLogic continued