COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-251
START
In Example 9-67, suppose that department 1572 has 12 employees:
000131Smith Jan 0001572
001552Nguyen Tracy 0001572
001744Dietrich Pat 0001572
001745Wellhausen Robin 0001572
001746Thomas Kim 0001572
001991Chew Meredith 0001572
004451O'Hara Flemming 0001572
005433Logan Shannon 0001572
006112McClure Beck 0001572
009733Kinoshita Lynn 0001572
012255Bostrup Stacy 0001572
013146Tilden Tex 0001572
If the requester sends a request with an EMP-NO value of zero for department 1572,
the server returns the records for the first 10 employees (131 through 9733) in
response. If the requester sends EMP-NO as 9733 in the second request for
department 1572, the START AFTER positions the file to resume reading after that
number, so the server returns the last 2 records in the file.
PROCEDURE DIVISION.
...
OPEN INPUT EMP-FILE
...
* Read $RECEIVE to get the query
READ REC-IN ...
* If this is an initial request, do a nonposition start
IF DEPT-NO OF EMP-LIST-REQUEST = ZEROS
START EMP-FILE KEY = DEPT-NO OF EMP-DATA
GENERIC
* Otherwise, resume after record last reply array ended with
ELSE
START EMP-FILE KEY = DEPT-NO OF EMP-DATA
AFTER POSITION EMP-NO
GENERIC
END-IF
* Zero the counter
* Perform (with test after) until EOF or 10 employees found:
* Read EMP-FILE NEXT record
* If EOF, return array to requester with signal for EOF
* else add 1 to the counter
* copy info to the array
* end-if
Example 9-67. START Statement With POSITION Phrase (page2of2)