Before your program can use a WRITE, START, READ, REWRITE, or DELETE statement to process records in a file, the program must first open the file with an OPEN statement.
PROCEDURE DIVISION.
. . .
OPEN iomode filename
In the example above, iomode specifies the open mode. If you are only reading from the file, code INPUT for the open mode. If you are only writing to the file, code either OUTPUT (to open a new file or write over an existing one) or EXTEND (to add records to the end of the file) for the open mode.
To open a file that already contains records, use OPEN INPUT, OPEN I-O (not valid for line-sequential files), or OPEN EXTEND.
If you open a sequential, line-sequential, or relative file as EXTEND, the added records are placed after the last existing record in the file. If you open an indexed file as EXTEND, each record that you add must have a record key that is higher than the highest record in the file.
related concepts
File organization and access mode
related tasks
Protecting against errors when opening files
related references
Valid COBOL statements for sequential files
Valid COBOL statements for line-sequential files
Valid COBOL statements for indexed and relative files
OPEN statement
(COBOL for Windows Language Reference)