QSAM stands for Queued Sequential Access Method. This is an extended version of the basic sequential access method (BSAM). When this method is used, a queue is formed of input data blocks that are awaiting processing or of output data blocks that have been processed and are awaiting transfer to auxiliary storage or to an output device.
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 the READ statement) 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 the ENVIRONMENT DIVISION and the DATA DIVISION.
- Process the records in these files in the PROCEDURE DIVISION.
After you have created a record, you cannot change its length or its position in the file, and you cannot delete it. (And this perhaps an interview question that — can we DELETE the records from a sequential File?). You can, however, update QSAM files on direct-access storage devices (using REWRITE), 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.