Messages and message monitors in files by the system

Displayed messages are the primary source of information for an operator or a programmer who is testing a new application.

A message typically contains more specific information than the file status code, the indicators, and the major and minor return code. The control language lets you monitor messages so that the CL program can intercept a message and take corrective action.

The Messages section in the CL topic has more information about message types and message monitors. In most high-level languages, the file status code and return codes (which are described in the following section) are more convenient sources of information.

Message numbers are assigned in categories to make it easier for a program to monitor for a group of related messages. The following table shows the message number ranges that are assigned for file error messages.


Table 1. Number ranges of the IBM i file management message. Message number ranges are assigned for file error messages to make it easier for a program to monitor for a group of related messages.
Message IDs Operation Message type
CPF4001-40FF Open Diagnostic and status.
     
CPF4101-43FF Open Escape messages that make the file unusable.
     
CPF4401-44FF Close Diagnostic and status.
     
CPF4501-46FF Close Escape messages that make the file unusable.
     
CPF4701-48FF I/O, Acquire, and Release Notify with a default reply of cancel, status, and escape messages that do not make the file or device unusable.
     
CPF4901-49FF I/O, Acquire, and Release Notify with a default reply of ignore or go.
     
CPF5001-50FF I/O, Acquire, and Release Notify with a default reply of cancel.
     
CPF5101-53FF I/O, Acquire, and Release Escape messages that make the file or device unusable.
     
CPF5501-56FF I/O, Acquire, and Release Escape messages that make the file or device unusable.

Some status messages, CPF4018 for example, are preceded by a diagnostic message that provides additional information. Diagnostic messages can be kept in the job log, depending on the message logging level of the job. If a CL program monitors for CPF4018, CPF5041, or similar messages, it can retrieve the accompanying diagnostic message from the program message queue.

If an error occurs for which an escape message is issued and the message is not monitored, your program will be ended and the message displayed for the operator. You can also monitor status messages, but if you do not monitor them the program continues. Most high-level languages except CL monitor for all the file errors that you are likely to encounter, and provide some standard recovery. Depending on the serverity of the error, the high-level language might end the program and issue a message of its own. Alternatively, the application programmer can code an error recovery routine to handle errors that are anticipated in that particular application.

Within these error-handling routines, it is typically necessary to examine the file status or major and minor return codes to determine the cause of the error. The books for the language you are using explain how to access file status and major and minor return codes. The information for each language also explains the file status codes as each language defines them.