Pathway/iTS SCREEN COBOL Reference Manual (H06.10+, J06.03+)

Procedure Division
HP NonStop Pathway/iTS SCREEN COBOL Reference Manual426750-003
6-102
SEND Statement
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.
ERR-PARAGRAPH.
IF TERMINATION-STATUS = 11
MOVE length-mismatch TO err-flag
ELSE
MOVE genuine-err TO err-flag.
ADJUST-RP-LEN.
IF rp-cd = 15 PERFORM set-rp-1-len
ELSE IF rp-cd = 37 PERFORM set-rp-2-len.
SET-RP-1-LEN.
IF rp-len > max-rp-1-len
MOVE max-rp-1-len TO rp-len.
SET-RP-2-LEN.
IF rp-len > max-rp-2-len
MOVE max-rp-2-len TO rp-len.