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

*************************************************************
* This program obtains and reports its own system number *
* and system name. *
*************************************************************
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. HP TXP.
OBJECT-COMPUTER. HP TXP.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 PROCESS-HANDLE PIC X(20).
01 CPU-PIN.
05 CPU NATIVE-2.
05 PIN NATIVE-2.
01 ERROR-NUMBER PIC S9(5) COMP.
01 SYSTEM-NAME PIC X(8).
01 SYSTEM-NUMBER NATIVE-2.
01 SYSTEM-NAME-LENGTH NATIVE-2.
PROCEDURE DIVISION.
WHERE-AM-I.
ENTER TAL "PROCESSHANDLE_GETMINE_"
USING PROCESS-HANDLE
GIVING ERROR-NUMBER.
ENTER TAL "PROCESSHANDLE_DECOMPOSE_"
USING PROCESS-HANDLE
CPU
PIN
GIVING ERROR-NUMBER.
ENTER TAL "NODENUMBER_TO_NODENAME_"
USING OMITTED
SYSTEM-NAME
SYSTEM-NAME-LENGTH
GIVING ERROR-NUMBER.
DISPLAY "I'm executing on system #"
SYSTEM-NUMBER
", named """
SYSTEM-NAME
"""".
STOP RUN.
Identifying the Message Source
To enable your process to determine the source of any message it receives, include a MESSAGE
SOURCE clause in the program’s RECEIVE-CONTROL paragraph. This causes the HP COBOL
run-time routines to automatically update the data item designated in the MESSAGE SOURCE
clause at every successful READ on $RECEIVE.
The capability of identifying the source of a message allows a process to respond differently to
the same request coming from different processes or even to reject certain requests from certain
processes.
Example 310 uses the MESSAGE SOURCE clause to acquire the message-source record. It reads
messages on $RECEIVE and displays the processor/PIN, process name, and message code of the
message, then displays the message. WHO-SENT-THAT detects whether the sender has an explicit
process name. If the sender had an explicit process name, the program determines the processor
number and PIN and displays them and the process name.
Example 310 MESSAGE-SOURCE Clause
DATA DIVISION.
FILE SECTION.
FD MESSAGE-IN-FILE
RECORD CONTAINS 1 TO 82 CHARACTERS
LABEL RECORDS ARE OMITTED.
930 Process Initiation, Communication, and Management