Coding ERROR declaratives

You can code one or more ERROR declarative procedures that will be given control if an input or output error occurs during the execution of your program. If you do not code such procedures, your job could be canceled or abnormally terminated after an input or output error occurs.

About this task

Place each such procedure in the declaratives section of the PROCEDURE DIVISION. You can code:

  • A single, common procedure for the entire program
  • Procedures for each file open mode (whether INPUT, OUTPUT, I-O, or EXTEND)
  • Individual procedures for each file

In an ERROR declarative procedure, you can code corrective action, retry the operation, continue, or end execution. (If you continue processing a blocked file, though, you might lose the remaining records in a block after the record that caused the error.) You can use the ERROR declaratives procedure in combination with the file status key if you want a further analysis of the error.

Results

Related references  
EXCEPTION/ERROR declarative (COBOL for Linux® on x86 Language Reference)