Pathway/iTS SCREEN COBOL Reference Manual (G06.24+, H06.03+, Pathway/iTS 1.0+)

Procedure Division
Compaq NonStop™ Pathway/iTS SCREEN COBOL Reference Manual426750-001
6-74
SEND Statement
This example is executed as follows:
1. Regardless of the actual reply code, if the reply length equals the length of the
Working-Storage item rply-a, the reply is stored in rply-a, and the program branches
back to the paragraph that performed SAMPLE-PARAGRAPH-2.
2. If the reply is shorter than rply-a, the reply is stored in rply-a, the actual length of
the reply is stored in the special register TERMINATION-SUBSTATUS, and the
TERMINATION-STATUS value of 11 causes the program to branch to the
paragraph VAR-LEN-REPLY-RCD.
3. If the reply is longer than rply-a, the reply is truncated to the length of rply-a and
stored in rply-a, TERMINATION-STATUS is set to 11, TERMINATION-
SUBSTATUS is set to the actual reply length up to a maximum of 1 + max(len(msg-
a),len(rply-a)), an error 3115 is logged, and the program branches to VAR-LEN-
REPLY-RCD.
Additional Information on Variable Reply Length
In the following example, the reply is received into two Working-Storage items. The
first two bytes are stored into a common reply code, while the rest are stored into a
reply-specific buffer. The common reply code identifies which buffer contains the
reply, in the event that a length mismatch sets TERMINATION-STATUS to 11.
This requester accepts only a reply code of 15 or 37; any other reply code causes
error 3112 to be logged.
PERFORM SAMPLE-PARAGRAPH-3.
:
SAMPLE-PARAGRAPH-3.
MOVE no-err TO err-flag.
MOVE 0 TO rp-len.
PERFORM send-paragraph.
IF err-flag = no-err
PERFORM ONE OF
set-rp-1-len
set-rp-2-len
DEPENDING ON termination-status
PERFORM good-reply-paragraph
ELSE IF err-flag = length-mismatch
MOVE termination-substatus TO rp-len
* if excess length, truncate to buffer length
PERFORM adjust-rp-len
* subtract 2 bytes for reply code
SUBTRACT 2 FROM rp-len
ELSE IF err-flag = genuine-err
PERFORM genuine-reply-err-paragraph.
SEND-PARAGRAPH.
SEND msg-a TO srvr-x
REPLY CODE 15 YIELDS VARYING rp-cd rp-buf-1
CODE 37 YIELDS VARYING rp-cd rp-buf-2
ON ERROR PERFORM err-paragraph.