Specifying indexed organization for VSAM files
Identify a VSAM KSDS file in a COBOL program by using
the ORGANIZATION IS INDEXED
clause. Code a prime
key for the record by using the RECORD KEY
clause.
You can also use alternate keys and an alternate index.
About this task
RECORD KEY IS data-name
In the example above, data-name is the name of the prime key field as you
define it in the record description entry in the DATA DIVISION
. The
prime key data item can be class alphabetic, alphanumeric, DBCS, numeric, national, or UTF-8. If it has USAGE NATIONAL
, the prime key can be category national,
or can be a national-edited, numeric-edited, national decimal, or national floating-point data
item. The collation of record keys is based on the binary value of the keys regardless of the
class or category of the keys.
The following example
shows the statements for a VSAM indexed file (KSDS) that is accessed
dynamically. In addition to the primary key, COMMUTER-NO
,
an alternate key, LOCATION-NO
, is specified:
SELECT I-FILE
ASSIGN TO INDEXED-FILE
ORGANIZATION IS INDEXED
ACCESS IS DYNAMIC
RECORD KEY IS IFILE-RECORD-KEY
ALTERNATE RECORD KEY IS IFILE-ALTREC-KEY
FILE STATUS IS FSTAT-CODE VSAM-CODE.
RECORD KEY clause (Enterprise COBOL for z/OS® Language Reference)
Classes and categories of data (Enterprise COBOL for z/OS Language Reference)