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.
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, or national. 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.
related concepts
VSAM files
related tasks
Using alternate keys
Using an alternate index
related references
RECORD KEY clause (Enterprise COBOL Language Reference)
Classes and categories of data (Enterprise COBOL Language Reference)