VSAM - Coding input and output statements for VSAM files - www.cadcobol.com.br



Desenvolvido por DORNELLES Carlos Alberto - Analista de Sistemas - Brasília DF. - cad_cobol@hotmail.com

Coding input and output statements for VSAM files

Enterprise COBOL for z/OS, Version 4.2, Programming Guide


Use the COBOL statements shown below to process VSAM files.

COBOL statement Description
OPEN To connect the VSAM data set to your COBOL program for processing.
WRITE To add records to a file or load a file.
START To establish the current location in the cluster for a READ NEXT statement.
START does not retrieve a record; it only sets the current record pointer.
READ and READ NEXT To retrieve records from a file.
REWRITE To update records.
DELETE To logically remove records from indexed and relative files only.
CLOSE To disconnect the VSAM data set from your program.

All of the following factors determine which input and output statements you can use for a given VSAM data set:

  • Access mode (sequential, random, or dynamic)
  • File organization (ESDS, KSDS, or RRDS)
  • Mode of OPEN statement (INPUT, OUTPUT, I-O, or EXTEND)

The following table shows the possible combinations of statements and open modes for sequential files (ESDS).
The X indicates that you can use a statement with the open mode shown at the top of the column.

Valid COBOL Statements with Sequential Files (ESDS)

Access mode COBOL statement OPEN INPUT OPEN OUTPUT OPEN I-O OPEN EXTEND
Sequential OPEN X X X X
WRITE X X
START
READ X X
REWRITE X
DELETE
CLOSE X X X X

The following table shows the possible combinations of statements and open modes you can use with indexed (KSDS) files and relative (RRDS) files.
The X indicates that you can use the statement with the open mode shown at the top of the column.

Valid COBOL Statements with Indexed Files (KSDS) and Relative Files (RRDS)

Access mode COBOL statement OPEN INPUT OPEN OUTPUT OPEN I-O OPEN EXTEND
Sequential OPEN X X X X
WRITE X X
START X X
READ X X
REWRITE X
DELETE X
CLOSE X X X X
Random OPEN X X X
WRITE X X
START
READ X X
REWRITE X
DELETE X
CLOSE X X X
Dynamic OPEN X X X
WRITE X X
START X X
READ X X
REWRITE X
DELETE X
CLOSE X X X

The fields that you code in the FILE STATUS clause are updated by VSAM after each input-output statement to indicate the success or failure of the operation.

Related tasks



© Copyright tutorialspoint.com