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

Appendix A 199
COBOL Intrinsics
CKREAD
CKREAD
A call to procedure CKREAD makes available the next logical record from a KSAM file.
CALL "CKREAD" USING
filetable, status, record, recordsize
In order to read records in sequential order by key value, call procedure CKREAD. The file
must have been opened in input or input/output mode with access mode specified as either
sequential or dynamic.
Parameters
filetable
An 8 halfword record containing the number and name of the file, its
input/output type, access mode, and a code indicating whether the
previous operation was successful and if so, what it was.
status
One halfword (two 8-bit characters) set to a pair of values upon completion
of the call to CKREAD to indicate whether or not the record was successfully
read and if not, why not.
record
A record defined in the WORKING-STORAGE SECTION into which the
contents of the next sequential KSAM record is read.
recordsize
An integer (S9(4)COMP) containing the length in characters of the record
being read. It must not exceed the maximum record length established for
the file when it was created.
Operation Notes
The file from which the record is read must be opened for sequential or dynamic access
(access mode = 0 or 2). It may be opened for input only or input/output (input/output type =
0 or 2), but not for output only.
When the file is opened initially for input or input/output, the logical record pointer is
positioned at the first sequential record; that is, at the record with the lowest key value.
The key used is the primary key unless a previous call to CKSTART has specified an
alternate key. When a call to CKREAD is executed, the record at which the record pointer is
currently positioned is read into the location specified by
record
.
If, when CKREAD is executed, there is no next logical record in the file, the at end condition
is returned to
status
; that is,
status
is set to 10. Note that a call to the procedure
CKSTART can be used to reposition the pointer for subsequent sequential access according
to primary or alternate key order.
In order to update records in sequential order, CKREAD must be called before executing
either of the update procedures CKREWRITE or CKDELETE. When access is shared, it is
important to include the call to CKREAD within the same locked portion of code that
includes the call to CKREWRITE or CKDELETE. This ensures that the correct record is
modified or deleted.
Because CKREAD is a pointer-dependent procedure, the actual record read depends on the
current position of the logical record pointer. When access is shared, this pointer position