Page 127 - Accounting Information Systems
P. 127
98 PART I Overview of Accounting Information Systems
Assuming the second condition is true, the remaining records on the M file must be copied to the
new master file. Some file structures indicate EOF with a record containing high key values (that is, the
key field is filled with 9s) to force a permanent T > M condition, in which case all remaining M records
will be read and copied to the new file. Other structures use a special EOF marker. The logic in this exam-
ple assumes the latter approach. When the EOF condition is reached for the master and all the M records
are copied, the update procedure is terminated.
DIRECT ACCESS FILE UPDATE
Figure 2-49 presents the general logic for updating direct access files. The two sample files of data pro-
vided will be used to illustrate this process. Notice that this logic is simpler than that used for sequential
files. There are three reasons for this. First, because record sequencing is irrelevant, the logic does not
need to consider the relationship between the T and M key values. Consequently, the update program
does not need to deal explicitly with the problem of multiple T records for a given M record. Second,
unprocessed master records are not copied to a new master file. Third, complex procedures for searching
the master file and retrieving the desired M record are performed by the computer’s operating system
rather than by the update program.
The transaction file in Figure 2-49 is read from top to bottom. Each record is processed as it is
encountered and without regard for its key sequence. First, T9 is read into memory. The operating system
then searches for and retrieves the corresponding record (M9) from the master file. The current record is
updated in memory and immediately written back to its original location on the master file. Records T2,
T5, and T3 are all processed in the same manner. Finally, the second T9 transaction is processed just as
the first, resulting in M9 being updated twice.
FI GU RE
2-49 LOGIC FOR DIRECT ACCESS FILE UPDATE
Transaction Master
File File
Start (T) (M)
Records Records
(Key) (Key)
Order of 9 Data 1 Data
Read T Processing
record 2 Updated
2
3 Updated
5
4
EOF
3 5 Updated
Stop
6
9
7
Search M file
and read
selected 8
record
9 Updated
10
Write
Update M in updated
memory value to M