Coding input and output statements for QSAM files

You can code the following input and output statements to process a QSAM file or a byte-stream file in the z/OS® UNIX file system using QSAM: OPEN, READ, WRITE, REWRITE, and CLOSE.

About this task

OPEN
Initiates the processing of files. You can open all QSAM files as INPUT, OUTPUT, or EXTEND (depending on device capabilities).

You can also open QSAM files on direct access storage devices as I-O. You cannot open z/OS UNIX files as I-O; a file status of 37 results if you attempt to do so.

READ
Reads a record from the file. With sequential processing, your program reads one record after another in the same order in which they were entered when the file was created.
WRITE
Creates a record in the file. Your program writes new records to the end of the file.
REWRITE
Updates a record. You cannot update a file in the z/OS UNIX file system using REWRITE.
CLOSE
Releases the connection between the file and your program.

Related references  
OPEN statement (Enterprise COBOL for z/OS Language Reference)  
READ statement (Enterprise COBOL for z/OS Language Reference)  
WRITE statement (Enterprise COBOL for z/OS Language Reference)  
REWRITE statement (Enterprise COBOL for z/OS Language Reference)  
CLOSE statement (Enterprise COBOL for z/OS Language Reference)  
File status key (Enterprise COBOL for z/OS Language Reference)