![Page 1: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/1.jpg)
13-1
Chapter 13
![Page 2: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/2.jpg)
Overview of Sequential File Processing Sequential File Updating - Creating a New
Master File Validity Checking in Update Procedures Update Procedures with Multiple
Transaction Records
13-2
![Page 3: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/3.jpg)
Balanced Line Algorithm for Sequential File Updating
Sequential File Updating - Rewriting Records on Disk
Matching Files for Checking Purposes Interactive Updating of Sequential File
13-3
![Page 4: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/4.jpg)
Records always read in sequence Read first record, process it, then read
second record, process it and so on◦ For example payroll records in order by employee
number may be processed in sequence for updating or printing reports
13-4
![Page 5: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/5.jpg)
May be sorted into any sequence using any field in record◦ To distribute checks more easily, records may be
sorted by department Sequential processing then used to print
checks, reading first record, then second, etc.
13-5
![Page 6: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/6.jpg)
Set of files used to store companies data in areas like payroll, inventory
Usually processed by batch processing Need updated on a regular basis
13-6
![Page 7: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/7.jpg)
Typical procedures for sequential processing in batch mode are:
Designing Master File Creating Master File Creating Transaction File Updating Master File Reporting from Master File
13-7
![Page 8: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/8.jpg)
Place key fields that uniquely identify record at beginning of record
If possible, choose numeric key fields Secondary fields after primary key fields Remaining fields appear in order of
importance
13-8
![Page 9: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/9.jpg)
Choose field size large enough to accommodate data that may be stored in it
Use coded fields where possible to save space (not a big problem anymore)
Be sure all date fields include four-digit year
13-9
![Page 10: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/10.jpg)
Original master file data entered interactively, stored on disk file
Ensure data integrity by using data validation techniques to minimize risk or errors
Control listing or audit trail produced to show data stored in new master file and control totals
13-10
![Page 11: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/11.jpg)
Changes to master file made with separate procedure
Changed records stored in file called transaction file
13-11
![Page 12: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/12.jpg)
Create a new blank file (New Master) Updating is process of making master file
current Update master file by incorporating
changes from transaction records
13-12
![Page 13: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/13.jpg)
Scheduled reports prepared on regular basis from data stored in master file◦ Sales reports, customer bills, checks, etc.◦ Use detail, exception and group printing
techniques On demand reports produced as need arises
◦ May be in report form or displayed on screen
13-13
![Page 14: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/14.jpg)
Data may be read in from another file or entered interactively from keyboard
If data entered is valid, move it to master or transaction record fields
WRITE new record to file
13-14
![Page 15: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/15.jpg)
Two input files Input Master File (Old-Master)
◦ Current through previous updating period◦ Does not contain changes since previous update
Input Transaction File (Trans-File)◦ Contains changes since previous update to be
applied to Old-Master
13-15
![Page 16: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/16.jpg)
Two output files Output Master File (New-Master)
◦ Integrates data from Old-Master with all of changes from Trans-File
◦ Will become Old-Master for next update Control Listing or Audit Trail
◦ Print file showing changes made to master file, errors during processing and control totals
13-16
![Page 17: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/17.jpg)
Records in Old-Master and Trans-File must be in order by same key field
Compare key fields to determine if given master record is to be updated
13-17
![Page 18: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/18.jpg)
For accounts receivable file, account number may be selected as key field
Records in both input files in sequence by account number◦ Old-Master key field is M-Acct-No◦ Trans-file key field is T-Acct-No
New-Master file also created in account number sequence (Acct-No-Out)
13-18
![Page 19: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/19.jpg)
One transaction record for each master record to be updated (p. 570)◦ Contains total amount to be added to amount
field in corresponding master record Initially, record read from both Old-Master
and Trans-File Comparison of M-Acct-No and T-Acct-No
determines next step
13-19
![Page 20: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/20.jpg)
Means transaction record exists with same account number as master record
Perform regular update, adding Trans-File amount to Old-Master amount, storing result in New-Master field
Write record to New-Master file Read next record from both Old-Master and
Trans-File
13-20
![Page 21: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/21.jpg)
Means master record exists for which there is no corresponding transaction record
Write record from Old-Master to New-Master as is, since no changes need to be made to it
Read next record from Old-Master Basically do nothing but copy The most likely thing to happen
13-21
![Page 22: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/22.jpg)
Means transaction record exists for which there is no corresponding master record
Two ways to process this transaction◦ Create record in New-Master file for this
transaction (maybe a new client?)◦ May assume that T-Acct-No is invalid since no
match found in Old-Master file and treat as error condition (depends on how the accounting works)
13-22
![Page 23: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/23.jpg)
COBOL reserved word HIGH-VALUES Move it into a variable (p. 573) Refers to largest value in computer's
collating sequence Used so all records from both Old-Master
and Trans-File are processed So the program keeps transferring the old
trans data to the new trans data May reach end of Old-Master file before
reaching end of Trans-File or vice versa
13-23
![Page 24: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/24.jpg)
When last record read from Old-Master, M-Acct-No set to HIGH-VALUES◦ For all remaining transaction records ◦ T-Acct-No < M-Acct-No ◦ Processed as new accounts and added to New-
Master◦ This allows the transaction file to keep going
when you are out of files from the old master file
13-24
![Page 25: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/25.jpg)
When last record read from Trans-File, T-Acct-No set to HIGH-VALUES◦ For all remaining Old-Master records T-Acct-
No > M-Acct-No ◦ Old-Master records added to New-Master without
changes◦ Old keeps going
13-25
![Page 26: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/26.jpg)
Loop to process records ends only when both account numbers equal HIGH-VALUES
May be used only with fields defined as alphanumeric◦ Define account number fields with PIC of Xs even
though fields contain numbers
13-26
![Page 27: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/27.jpg)
Code field may be added to each transaction record to indicate whether transaction is◦ New account to be added◦ Update to existing account◦ Deletion of existing account
Comparison of keys and transaction code type enable program to detect other update errors
13-27
![Page 28: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/28.jpg)
To process more than one change for each master record requires different update procedure
In accounts receivable file example, transaction record may be created for each purchase or credit by customer
Amounts in all transaction records for one customer need to be added to amount in Old-Master file record
13-28
![Page 29: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/29.jpg)
Add loop to regular update routine to read and process multiple transaction records for same Old-Master record◦ Continue to read records from Trans-File until T-Acct-No Not = M-Acct-No
13-29
![Page 30: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/30.jpg)
Technique to update master file ◦ With any number of transactions◦ With checks for error conditions
Viewed as most efficient and effective sequential file updating method
Two new fields used to control updating◦ WS-Control-Key◦ WS-Allocated-Switch
13-30
![Page 31: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/31.jpg)
Determines type of processing Called control or active key field Set to smaller of M-Acct-No or T-Acct-No Then comparison of M-Acct-No or T-Acct-No
to WS-Control-Key used to control further processing
Kind of like the control break processing
13-31
![Page 32: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/32.jpg)
Used for error control◦ To ensure records processed correctly◦ To detect erroneous codes in transactions
Set to 'YES' when record should be written to New-Master file
Set to 'NO' if record should not be written to New-Master file
13-32
![Page 33: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/33.jpg)
WS-Control-Key set to M-Acct-No WS-Allocated-Switch set to 'YES' because
WS-Control-Key and M-Acct-No are same Since M-Acct-No and T-Acct-No not equal,
Old-Master has no transactions◦ Old-Master record written to New-Master record
as is
13-33
![Page 34: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/34.jpg)
WS-Control-Key set to M-Acct-No WS-Allocated-Switch set to 'YES' because
WS-Control-Key and M-Acct-No are same Transactions with T-Acct-No = M-Acct-No
processed
13-34
![Page 35: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/35.jpg)
Processing transactions with T-Acct-No = M-Acct-No◦ Updates posted to New-Master◦ Additions displayed as errors because WS-
Allocated-Switch set to 'YES' (master record with this M-Acct-No already exists)
◦ Deletions move 'NO' to WS-Allocated-Switch to ensure this Old-Master record is not written to New-Master file
13-35
![Page 36: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/36.jpg)
WS-Control-Key set to T-Acct-No WS-Allocated-Switch set to 'NO' because
WS-Control-Key not equal to M-Acct-No◦ No master record exists for this transaction
13-36
![Page 37: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/37.jpg)
Only additions acceptable◦ Reset WS-ALLOCATED-SWITCH to 'YES'◦ New-Master record created from transaction
record Update or deletion transaction treated as
error Full example p. 588-590
13-37
![Page 38: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/38.jpg)
May read a master disk record, make changes directly to same record, and rewrite it or update it in place
Only two files needed◦ Master-File OPEN as I-O◦ Trans-File OPEN as INPUT
Use REWRITE statement to replace master disk record, currently in storage, that was accessed by preceding READ
13-38
![Page 39: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/39.jpg)
To delete a record, establish each record with an activity code field◦ For example, Code-X = 1 if record is active, or 2
if record is inactive◦ Probably want this code anyway for various
bookkeeping reasons All master records initially active (1 in
Code-X) Master record deactivated by changing
activity code to 2, not actually deleting it.
13-39
![Page 40: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/40.jpg)
New records cannot be added in sequence when file open for I-O
Can add records at end of file by opening file in EXTEND mode
OPEN EXTEND file-name Disk automatically positioned at end of
file, immediately after last record Sort file after records added to arrange
them in sequence Issues here, you need to close then
open and records are added unsorted
13-40
![Page 41: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/41.jpg)
Sequential updating by creating new master uses three files◦ Incoming master file◦ Transaction file with change records◦ New output master file that will incorporate all
changes
13-41
![Page 42: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/42.jpg)
Sequential updating technique◦ All three files must be in sequence by same key
field◦ Record read from each file◦ Routine performed depends on whether key fields
match
13-42
![Page 43: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/43.jpg)
Sequential updating technique ◦ Transaction record may include coded field to
designate update, deletion, addition◦ Use HIGH-VALUES to ensure all records in both old
master and transaction files are processed Balanced line algorithm used for sequential
updates
13-43
![Page 44: 13- 1 Chapter 13. Overview of Sequential File Processing Sequential File Updating - Creating a New Master File Validity Checking in Update Procedures](https://reader035.vdocuments.mx/reader035/viewer/2022062222/5697bff01a28abf838cbad40/html5/thumbnails/44.jpg)
Can also update records in sequential file by rewriting them in place◦ Must open file as I-O
Records can be added to end of sequential file◦ Open in EXTEND mode
13-44