| Introduction | MTB Statements | File System | Compiler | Applications | Reference Guide | Index |
| Language Structure | Data Division | I/O Format Division | Procedure Division | Mnemonics |
| Syntax: | REWRITE (lun, format-statement-label) KEY=index [,EXCP=statement-label] |
| Discussion: | The REWRITE statement functions just like the WRITE statement, except that an exception is reported if the record does not already exist. REWRITE can be used only on keyed files. |
| Example: |
REWRITE (1,400) KEY=KEYNO$,EXCP=1600In this example, the REWRITE statement is used to rewrite the data record defined in format-statement-label 400. If the record does not already exist, the exception branch is taken. |