COBOL Manual for TNS and TNS/R Programs
Environment Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
6-72
RECEIVE-CONTROL Paragraph
ERROR CODE Phrase
The ERROR CODE phrase of the RECEIVE-CONTROL paragraph provides a way for
a server process to appear as a device to its requesters. When the server process
sends an error code to a requester, the server process uses file-system error codes to
set the ERROR CODE item. How the server process sets the ERROR CODE item
depends on the device type of the device the server is simulating.
When the server makes a reply to a READ on $RECEIVE, the operating system
passes back the value of the ERROR CODE item separately from the reply-message
text. Additionally, the system passes back a condition code (CCE, CCG, or CCL) based
on the value of the file-system error number. (See the Guardian Programmer’s Guide
for information about file-system errors and condition codes.)
The requester checks for a condition code other than CCE (successful operation) after
its action to send a task message and receive a response. If there is an error (CCG or
CCL), the requester must call FILEINFO, a system procedure, to determine the error
code (from ERROR CODE item) passed by the operating system. When a requester
process is written in COBOL, condition code checking (including the call to FILEINFO)
is handled by the COBOL run-time library routines.
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 6-9. MESSAGE SOURCE Phrase (Non-CRE)
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 PROCESS-ID.
10 PROCESS-NAME PICTURE X(6).
10 CPU-PIN PICTURE X(2).
05 FILLER PICTURE X(16).