To replace a record in a file, use REWRITE on a file that you opened as I-O. If the file was not opened as I-O, the record is not replaced and the status key is set to 49. Check the file status key after each REWRITE statement.
For sequential files, the length of the replacement record must be the same as the length of the original record. For indexed files or variable-length relative files, you can change the length of the record you replace.
To replace a record randomly or dynamically, you do not have to first READ the record. Instead, locate the record you want to replace as follows:
You cannot open as I-O an extended-format data set that you allocate in the compressed format.
related concepts
File organization and access mode
related tasks
Opening a file
Using file status keys
related references
FILE STATUS clause
(COBOL for Windows Language Reference)