You are developing a COBOL program that reads data from an external file. What would you do if the file does not exist when you attempt to open it?

  • Check the FILE STATUS after the OPEN statement
  • Perform a manual check using IF conditions
  • Use the INVALID KEY clause in the file control entry
  • Utilize the EXIT PROGRAM statement
When attempting to open a file, using the INVALID KEY clause in the file control entry allows you to handle the situation where the file does not exist. You can specify a set of actions to be taken if the file opening fails, providing a mechanism for graceful error handling.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *