Using KSAM/XL and KSAM 64 (32650-90886)

232 AppendixB
BASIC/V Intrinsics
BKCLOSE
Shared Access
Particular care must be taken when using the logical record pointer during shared access.
Since the record pointer is maintained in a separate control block for each open file, one
user may cause the record pointer to be inaccurate without other users being aware of it.
To avoid this problem, you should always lock the file in a shared environment before
calling any procedure that sets the pointer and leave the file locked until all procedures
that depend on that pointer have been executed. Thus, if you want to read the file
sequentially, delete a record, or modify a record, you should lock the file, call a procedure
that sets the pointer (such as BKSTART), and then call BKREAD, BKDELETE, or BKREWRITE.
When the operation is complete, you can then unlock the file to give other users access to
it.
BKCLOSE
A call to BKCLOSE terminates file processing for the specified KSAM file.
CALL BKCLOSE (
filenum, status
)
When processing is completed, a KSAM file should be closed with a call to BKCLOSE. No
further processing is allowed on the file until a BKOPEN procedure call reopens the file.
BKCLOSE can be executed only for a file that is open.
Parameters
filenum
A numeric variable containing the file number that identifies the file; this
number was returned by the last call to BKOPEN. It should not be altered
until the file is closed with a successful call to BKCLOSE. (
Required
parameter
)
status
A four-character string variable to which is returned a code that indicates
whether or not the file was successfully closed and if not, why not. The first
character is set to 0 if the close is successful, to another value if not.
(
Required parameter
)
Operation Notes
After calling BKCLOSE, you should check the
status
parameter to determine if the file was
closed successfully. A successfully closed file is no longer available for processing until it is
reopened. Note that a KSAM file can be closed and then reopened in order to specify a
different access mode or type of processing.
The BKCLOSE procedure does not remove the file from the system. To do this, you should
use the PURGE command of KSAMUTIL or MPE/iX.
The example in Figure B-1. closes a file identified by the file number in F. It then checks
the status and prints a message if the status shows any code except the zero for successful
completion.