ENFORM User's Guide

Using an ENFORM Server
ENFORM Servers
058058 Tandem Computers Incorporated 7–29
1-PROCESS-REQUEST.
*============================================================
* Based on the value of the position code in the message
* buffer get the first (or the next) record to return to
* the QP.
*============================================================
IF FIRST-RCD OF MSG-RCD
PERFORM 2-GET-FIRST-RECORD
ELSE IF NEXT-RCD OF MSG-RCD
PERFORM 2-GET-NEXT-RECORD
ELSE PERFORM 9-INVALID-MSG.
2-GET-FIRST-RECORD.
*============================================================
* Read the first record in the file and return the part
* number and the first occurrence of supplier and cost in
* that record.
*============================================================
MOVE ZEROES TO PARTNUM OF FRMSUP.
PERFORM 90-FIRST-POSITION.
IF NO-ERROR
PERFORM 90-READ-PARTSUP
IF NO-ERROR
MOVE 1 TO I
PERFORM 9-FORMAT-REPLY.
2-GET-NEXT-RECORD.
*============================================================
* The QP returns the data that it was sent in the previous
* reply. Use that partnum to position the file and read
* that record. Then compare the occurrence number of the
* last supplier sent(CB-INT) to the number of suppliers in
* the record. If = then read the next record in the file
* and return the new part number and the first occurrence of
* supplier in that record; otherwise, return the next
* supplier in the same record. Any end of file indications
* are handled by the declarative procedure.
*============================================================
PERFORM 90-NEXT-POSITION.
IF NO-ERROR
PERFORM 90-READ-PARTSUP
IF NO-ERROR
IF CB-INT OF MSG-RCD LESS THAN NUM-SUPS
COMPUTE I = CB-INT OF MSG-RCD + 1
PERFORM 9-FORMAT-REPLY
ELSE
PERFORM 90-READ-PARTSUP
IF NO-ERROR
MOVE 1 TO I
PERFORM 9-FORMAT-REPLY.