HPlogo Using KSAM XL and KSAM 64 > Appendix A COBOL Intrinsics

Calling a KSAM Procedure

MPE documents

Complete PDF
Table of Contents
Index

E0300 Edition 4 ♥
E0394 Edition 3

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. The COBOL procedures provided with KSAM/3000 correspond to the INDEXED I/O module statements in COBOL 74.

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 be 16 bit aligned.

The KSAM interface procedures are called using a CALL statement of the following general form.

  CALL "name" USING filetable, status [,parameter[,...] ]

Where:
"name"

identifies the procedure to which control is transferred.

filetable

an 8-halfword table that identifies the file by name and in which access mode and input/output type are specified, and to which is returned the file number on open, and a code identifying the previous operation.

status

One halfword to which a two-character code is returned that indicates the status of the input/output operation performed on the file by the called procedure.

parameter

One or more parameters, depending on the particular procedure called, that further define operations to be performed on the file.

The first two parameters, filetable and status, are included in every KSAM procedure call except CKERROR; other parameters may be specified depending on the particular procedure. If a parameter is included in the procedure format, then it must be included in the procedure call. All parameters are required.

Another characteristic of KSAM procedure call parameters is that they must always start on a halfword boundary. In order to ensure this, the parameters should be defined in the WORKING-STORAGE SECTION as 01 record items, 77 level elementary items, or else the SYNCHRONIZED clause should be included in their definition.

A literal value cannot be used as a parameter to these procedures. Any value assigned to a data item used as a parameter is passed to the procedure, but a literal value causes an error.

Depending on the procedure, certain data items may be assigned values as a result of executing the procedure.


NOTE: There are no COBOL procedures to read a KSAM file in physical order or to access a record by its physical record number. (Physical order is the order in which the data records were written to the file.)




Appendix A COBOL Intrinsics


Filetable Parameter