FILE AVAILABILITY - IBM Mainframe

The concepts of file availability and creation affect OPEN processing, OPTIONAL files, and file status codes 05 and 35. The successful execution of an OPEN statement determines the availability of the file. Optional files are files that are not necessarily present each time the program is executed. You can define files opened in INPUT, l-O, or EXTEND mode as optional by defining them with the SELECT OPTIONAL phrase in the File-Control paragraph of your program. For example, an OPEN EXTEND of an optional file that is not available results in file status 35. If the file is OPTIONAL, the OPEN EXTEND will create the file and return file status 05. File availability and creation are defined differently for QSAM and VSAM files.

Availability of QSAM Files

A QSAM file is available if a DD statement or TSO ALLOCATE command is present for the file. If no DD statement or TSO ALLOCATE command is present for the file, it is considered unavailable. (A DD statement without a ddname or with a misspelled ddname is equivalent to a missing DD statement.) When a QSAM file is unavailable and the COBOL language defines that the file be created, the file may be allocated for you; VS COBOL II will dynamically allocate any file being opened as OUTPUT, regardless of the OPTIONAL phrase, or any OPTIONAL file being opened as EXTEND or l-O, using the system default attributes established at your installation and the attributes specified in the SELECT and FD statements in your program. Under MVS, these files are temporary data sets and will not exist after the VS COBQL II program completes execution.

Processing QSAM Files

Queued sequential access method (QSAM) files are unkeyed files in which the records are placed one after another, according to entry order. Your program can process these files only sequentially, retrieving (with theREADstatement) records in the same order as they are in the file. Each record is placed after the preceding record. To process QSAM files in your program, use COBOL language statements that:

  • Identify and describe the QSAM files in theENVIRONMENT DIVISIONand theDATA DIVISION.
  • Process the records in these files in thePROCEDURE DIVISION.

After you have created a record, you cannot change its length or its position in the file, and you cannot delete it. You can, however, update QSAM files on direct-access storage devices (usingREWRITE), though not in the HFS.

QSAM files can be on tape, direct-access storage devices (DASDs), unit-record devices, and terminals. QSAM processing is best for tables and intermediate storage.

You can also access byte-stream files in the HFS using QSAM. These files are binary byte-oriented sequential files with no record structure. The record definitions that you code in your COBOL program and the length of the variables that you read into and write from determine the amount of data transferred.

Availability of VSAM Files

A VSAM file is available if it has a DD statement, has been defined by access method services, and has previously contained a record. A VSAM file is unavailable if it has a DD statement, has been defined by access method services, but has never contained a record. If an indexed or relative file is unavailable and the COBOL language defines that the file be created, VS COBOL II will write a dummy record to the file and then delete the record. This prepares the file for use. File status code 00 will always be returned upon successful completion of the OPEN statement for a VSAM sequential file. File status code 05 does not apply to VSAM sequential files. The IDCAMS REPRO command can be used to empty a file. Deleting records in this manner will reset the files high-use Relative Byte Address (RBA) to zero. The file is effectively empty and appears to COBOL as if it never contained a record.

Processing VSAM Files

Virtual storage access method (VSAM) is an access method for files on direct-access storage devices. With VSAM you can load files, retrieve records from files, update files, and add, replace, and delete records in files.

VSAM processing has these advantages over QSAM:

  • Protection of data against unauthorized access
  • Compatibility across systems
  • Independence of devices (no need to be concerned with block size and other control information)
  • Simpler JCL (information needed by the system is provided in integrated catalogs)
  • Ability to use indexed file organization or relative file organization


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

IBM Mainframe Topics