COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
$RECEIVE as Input-Output File
In this case, $RECEIVE is opened in I-O mode to receive requests and reply to them through the
same file. Each request is acted upon and paired with a reply message sent back in response to
the task.
Figure 41 $RECEIVE as Input/Output File
The requesting process follows the outline in Example 302.
Example 302 Requester Code
...
SELECT TRANSACTIONS ASSIGN TO "$BAL"
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
...
FD TRANSACTIONS
LABEL RECORDS ARE OMITTED
RECORD CONTAINS 1 TO 8 CHARACTERS.
01 TRAN-RESPONSE.
05 RESULT-CODE PICTURE 9.
88 RESULT-OK VALUE IS 1.
88 RESULT-ERROR VALUE IS 2....
05 NEW-BALANCE PICTURE 9(7)....
WORKING-STORAGE SECTION....
01 TRAN-REQUEST.
05 TRAN-CODE PICTURE 9.
88 TRAN-PMT VALUE IS 1....
05 ACCOUNT-NUMBER PICTURE 9(6)....
PROCEDURE DIVISION.
...
OPEN I-O TRANSACTIONS SYNCDEPTH 1....
MOVE TCODE TO TRAN-CODE.
MOVE ACCOUNT-IN TO ACCOUNT-NUMBER.
READ TRANSACTIONS WITH PROMPT TRAN-REQUEST....
The server process receives the account number and transaction code from $RECEIVE and sends
a response back to the requester, as Example 303 shows.
Example 303 Server Code
INPUT-OUTPUT SECTION.
FILE-CONTROL.
...
SELECT TASKS-IN ASSIGN TO "$RECEIVE"
ORGANIZATION IS SEQUENTIAL
ACCESS MODE IS SEQUENTIAL.
...
RECEIVE-CONTROL.
Communicating With a Process 919










