COBOL Manual for TNS and TNS/R Programs

Procedure Division Verbs
HP COBOL Manual for TNS and TNS/R Programs522555-006
9-250
START
Example 9-67, fragments of a server program, shows the use of a START statement
with a POSITION phrase. The query the server gets through $RECEIVE includes a
department number and a unique employee number. The server is to return an array
containing information about all employees in the specified department.
At the first call, the requester sends the chosen department number but an employee
number of zero. If there are more than ten employees in a department, the server
reports only the first ten it found. The requester can then send another query, but this
time it includes the employee number of the last array entry of the previous reply. By
using this technique, the server remains context-free, able to serve another requester.
When the server executes the START statement, the key of reference used with the
GENERIC phrase is still the department number, but the presence of a unique record
key value of EMP-NO in the AFTER POSITION phrase says to resume reading along
the DEPT-NO path after the record for the specified employee.
Example 9-67. START Statement With POSITION Phrase (page1of2)
SELECT EMP-FILE ASSIGN TO "EMPL1093"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS EMP-NO
ALTERNATE RECORD KEY IS DEPT-NO WITH DUPLICATES
ALTERNATE RECORD KEY IS EMP-NAME WITH DUPLICATES
FILE STATUS IS EMP-STATUS.
...
DATA DIVISION.
FILE SECTION.
...
FD EMP-FILE.
01 EMP-DATA.
05 EMP-NO PIC 9(6).
05 EMP-NAME PIC X(45).
05 EMP-DEPT PIC 9(7).
...