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

194 AppendixA
COBOL Intrinsics
CKOPEN
CKOPEN
A call to procedure CKOPEN initiates KSAM file processing.
CALL "CKOPEN" USING
filetable, status
In order to process a KSAM file, it must be opened with a call to the CKOPEN procedure.
CKOPEN initiates processing, specifies the type of processing and the access mode; the file
must have been created previously.
To open a file means to make it available for processing, to specify the type of processing
(input only, output only, or both), and to specify the access method (sequential, random, or
dynamic). If a different type of processing or access method is needed, the file must be
closed and opened again with the parameters set to new values.
NOTE
If you want to open the file for shared access, you must use a call to
CKOPENSHR, rather than CKOPEN.
Parameters
filetable
An 8 halfword record containing the name of the file, its input/output type,
and access mode. When the open is successful, the first word of this table is
set to the file number that identifies the opened file. (Refer to Filetable
Parameter discussion earlier in this section.)
status
One halfword (two 8-bit characters) set to a pair of values upon completion
of the call to CKOPEN to indicate whether or not the file was successfully
opened and if not why not. The left character is set to 0 if open is
successful, to 9 if not. The right character is set to 0 if the open is
successful, to the file system error code if not. (Refer to Status Parameter
discussion earlier in this section.)
Operation Notes
Upon successful execution of CKOPEN, the file named in
filetable
is available for the type
of processing specified in
filetable
. Before the file is successfully opened with CKOPEN,no
operation can be executed that references the file either explicitly or implicitly.
The input/output procedures that can be called to process the file depend on the value of
the halfwords in
filetable
that specify input/output type and access mode. (Refer to
Figure A-3. for the procedures allowed with the various combinations of input/output type
and access mode.)
A file may be opened for input, output, or input/output, and for sequential, random, or
dynamic access in the same program by specifying a different call to CKOPEN for each
change in input-output type or access mode. Following the initial execution of CKOPEN, each
subsequent call to CKOPEN for the same file must be preceded by a call to CKCLOSE for that
file.
When files are opened for input or input/output, the call to CKOPEN sets the current record