USING KSAM FILES IN COBOL PROGRAMS [ KSAM/3000 Reference Manual ] MPE/iX 5.0 Documentation
KSAM/3000 Reference Manual
Chapter 3 USING KSAM FILES IN COBOL PROGRAMS
OVERVIEW
KSAM files are accessed from COBOL programs through calls to a set of
procedures. These procedures allow you to open, open for shared access,
write records to, read records from, lock, unlock, update, position, and
close a KSAM file. (Refer to Table 3-1 for a list of the procedures and
their associated functions.) The COBOL procedures provided with
KSAM/3000 correspond to the INDEXED I-O module statements in COBOL 74.
Note: The following applies when using KSAM with COBOL.
* The KSAM file must be created with KSAMUTIL's >BUILD command.
* To access a KSAM file in chronological order, the KSAM file must be
copied to a non-KSAM file.
* KSAM permits duplicate primary keys as an extension to the ANSII
standards.
In HP COBOL/3000, the procedures that are used to access KSAM files
differ in form from the COBOL input/output statements used to access
non-KSAM files. The KSAM interface procedures use parameters for
information that would otherwise be specified in the FILE-CONTROL
paragraph and the FD entry of the DATA DIVISION. These parameters are
themselves defined in the WORKING-STORAGE section of the DATA DIVISION.
The main restriction on the KSAM interface call parameters is that they
must start on word boundaries.
Table 3-1. KSAM Procedures for COBOL Interface
--------------------------------------------------------------------------------------------------
| | | | |
| PROCEDURE | PARAMETERS | FUNCTION | PAGE |
| NAME | | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKCLOSE | filetable | Terminates processing of KSAM file | 3-12 |
| | | identified by filetable. | |
| | status | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKDELETE | filetable | Logically removes record from KSAM file; | 3-13 |
| | | deleted record is identified by previous | |
| | status | read. | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKERROR | status, | Converts numeric value returned in status | 3-17 |
| | | to character string result. | |
| | result | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKLOCK | filetable | Dynamically locks file opened for shared | 3-18 |
| | | access, conditionally depending on | |
| | status | lockcond. | |
| | | | |
| | lockcond | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKOPEN | filetable | Initiates processing of file named in | 3-20 |
| | | filetable; returns file number to first | |
| | status | word of filetable. | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKOPENSHR | filetable | Initiates processing with dynamic locking | 3-25 |
| | | and shared access of file named in | |
| | status | filetable. | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKREAD | filetable | Reads next sequential record from KSAM file | 3-26 |
| | | identified by filetable into record. | |
| | status | | |
| | | | |
| | record | | |
| | | | |
| | recordsize | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKREADBYKEY | filetable | Reads into record first record with a key | 3-29 |
| | | in location keyloc whose value matches that | |
| | status | of key, from KSAM file identified by | |
| | | filetable. | |
| | record | | |
| | | | |
| | key | | |
| | | | |
| | keyloc | | |
| | | | |
| | recordsize | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKREWRITE | filetable | Replaces last sequential record read by | 3-32 |
| | | CKREAD, or replaces record whose primary | |
| | status | key matches the value of key item in | |
| | | record, with the contents of record. | |
| | record | | |
| | | | |
| | recordsize | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKSTART | filetable | Positions record pointer in preparation for | 3-36 |
| | | a sequential read to the first record with | |
| | status | a key in location keyloc whose value has | |
| | | the relation relop to the value of key. | |
| | relop | | |
| | | | |
| | key | | |
| | | | |
| | keyloc | | |
| | | | |
| | keylength | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKUNLOCK | filetable | Unlocks file dynamically locked by CKLOCK. | 3-40 |
| | | | |
| | status | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| CKWRITE | filetable | Writes record of length recordsize from | 3-42 |
| | | record to a KSAM file identified by | |
| | status | filetable. | |
| | | | |
| | record | | |
| | | | |
| | recordsize | | |
| | | | |
--------------------------------------------------------------------------------------------------
MPE/iX 5.0 Documentation