COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

When you use ERROR CODE error, but the server is not executing a WRITE for each READ on
$RECEIVE, the system acknowledges each message from a requester and also passes the value
of error with each internal reply. If you take this approach, be careful to have the right value
in error at all times.
The operating system also returns the value of error with explicit or system-generated replies to
reported system messages (system messages are reported when the REPORT message-type
MESSAGES option is used). When system messages are not reported, the COBOL run-time library
replies to them and generates an error code.
MESSAGE SOURCE Phrase
The MESSAGE SOURCE phrase provides a mechanism through which a COBOL program can
discover the sender of each message received. During the successful execution of a read operation
on $RECEIVE, the $RECEIVE mechanism assigns a set of values to the storage space designated
in the MESSAGE SOURCE phrase.
Example 33 MESSAGE SOURCE Phrase
01 SOURCE-MESSAGE.
05 MESSAGE-TYPE PICTURE S999 USAGE IS COMPUTATIONAL.
05 ENTRY-NUMBER PICTURE 999 USAGE IS COMPUTATIONAL.
05 FILLER PICTURE X(4).
05 PHANDLE PICTURE X(20).
05 FILLER PICTURE X(4).
MESSAGE-TYPE
is one of:
MeaningValue
Message sent by the requesting processZero or greater
Message sent by the operating systemLess than zero
ENTRY-NUMBER
is the number assigned to the receive-control table entry for a requesting process. It is in the
range set by table-length. When certain system messages not associated with any requester,
such as CPU-UP and CPU-DOWN, are received, the number is 0.
PHANDLE
is a unique identifier that specifies a process to process-related procedure calls (for more
information, see the Guardian Programmer’s Guide).
REPORT Phrase
Normally, the $RECEIVE mechanism automatically intercepts and processes all messages sent to
the run unit by the operating system. By specifying the REPORT clause, you state that the $RECEIVE
mechanism is not to intercept certain classes of system messages, but pass them back to the program
for processing. The program then supplies the appropriate error code (if the ERROR CODE clause
appears), and generates the appropriate response (by performing a write operation or another
read operation on $RECEIVE).
The file must have a record length of at least 255 characters.
“System” is an abbreviation for the messages that are generated under program control.
Input-Output Section 149