Handling errors in line-sequential files

When an input or output statement fails, COBOL does not take corrective action for you. You choose whether your program should continue running after an input or output statement fails.

About this task

COBOL provides these language elements for intercepting and handling certain line-sequential input and output errors:

  • End-of-file phrase (AT END)
  • EXCEPTION/ERROR declarative
  • FILE STATUS clause

If you do not use one of these techniques, an error in processing input or output raises a Language Environment® condition.

If you use the FILE STATUS clause, be sure to check the key and take appropriate action based on its value. If you do not check the key, your program might continue, but the results will probably not be what you expected.