Opening QSAM files
Before a program can use any READ
, WRITE
,
or REWRITE
statements to process records in a file,
it must
first open the file by using an OPEN
statement.
About this task
An OPEN
statement works if both
of the following conditions are true:
- The file is available or has been dynamically allocated.
- The fixed file attributes coded in the ddname
definition or
the data-set label for the file match the attributes coded for that
file in the
SELECT
clause andFD
entry.Mismatches in the file-organization attributes, code set, maximum record size, or record format (fixed or variable) result in file status code 39, and the failure of the
OPEN
statement. Mismatches in maximum record size and record format are not errors when opening files in the z/OS® UNIX file system.For fixed-length QSAM files, if you code
RECORD CONTAINS 0
in theFD
entry, the record size attributes are not in conflict. The record size is taken from theDD
statement or the data-set label, and theOPEN
statement is successful.
Code CLOSE WITH LOCK
so that the file cannot be opened
again
while the program is running.
Use the REVERSED
option of the OPEN
statement to process tape files in reverse order.
The file is positioned at the end,
and READ
statements read the data records in reverse
order,
starting with the last record.
The REVERSED
option is supported only for files that
have
fixed-length records.