Saturday, December 17, 2011

Replacing Records in a VSAM File


   To replace records in a VSAM file, use REWRITE in a file that you have
   opened for I-O.  If you attempt to use REWRITE on a file that is not
   opened I-O, the record is not rewritten and the status key is set to 49.
   You should check the file status key after each REWRITE statement.

   °   For files accessed sequentially, you must read the record before you
       issue the REWRITE statement.

   °   For sequential files, the length of the record you rewrite must be the
       same as the length of the original record.

   °   For indexed files, you can change the length of the record you
       rewrite.

   °   For variable-length relative files, you can change the length of the
       record you rewrite.


   To replace records randomly or dynamically, the record to be rewritten
   need not be read by the COBOL program.  Instead, to position the record
   you want to update:

   °   For indexed files, move the record key to the RECORD KEY data item,
       and then issue the REWRITE.

   °   For relative files, move the relative record number to the RELATIVE
       KEY data item, and then issue the REWRITE.

No comments:

Post a Comment