Information Technology Reference
In-Depth Information
16. The called program and using
As already mentioned, the called program will have a new file called the next
number file, which is defined with the key of account number and set up by the data base
analyst. It consists of an indicator, which will be a blank or
d
, and the next available
account number. Besides the next account number, there will also be records with
account numbers that are available due to the deletion of records from the account
number file. Once an account number is ready to be sent to the calling program, the next
number file will be updated.
Even though the next number file is a keyed file, we will read it sequentially so
we always read the first record on the file, taking the first available number and using it
until the next number file eventually winds up with one record again. If there are many
deletions, this may take a long time but at some point we should wind up with that single
record. In any event, our access to get a new account number will work. In the previous
chapter, I described what the called program will be doing, so I won't repeat it here. The
called program follows.
program-name
:
nextnumb
link
data-fields
define
data-fields
structure
new-account-number
integer(
9)
value
0
process-sw
integer value
0
define
file
numbfile
record
next-record
status
numb-status
key
account-number
structure
account-number
integer(
9)
indicator
character
account-number
= 0
readnext
numbfile
update
if
numb-status
= 0
perform
update-number
else
if
numb-status
= 3
process-sw
= 3
else
process-sw
= 9
end-if
end-if
go to
end-program
update-number:
process-sw
= 0
new-account-number
=
account-number
delete
numbfile
if
numb-status
> 0
process-sw
= 9
else
if
indicator
= space
account-number
=
account-number
+ 1