COBOL Manual for TNS/E Programs (H06.03+)
Procedure Division Verbs
HP COBOL Manual for TNS/E Programs—520347-003
9-236
START
•
Determining Key Value of Last Record of an Indexed or Queue File
To determine the key value of the last record of an indexed or queue file, which is
especially important when using the READ REVERSED statement, move HIGH-
VALUES to the key and then use the START statement with the relationship
LESS THAN. START LESS THAN positions the indexed file so that a READ NEXT
or READ REVERSED statement accesses the last record in the file.
Table 9-11. Using the POSITION and KEY Phrases
Position-Key Key
Length Used and
Restriction Effect
Relative key
(ORGANIZATION
RELATIVE)
Alternate or
alternate(1:n )
Relative key
length (entire alternate)
+ 4 < 254
4 (which is the length of
the relative key)
Full value of alternate
AND of relative used
Relative key used alone
Prime key
(ORGANIZATION
INDEXED)
Alternate or
alternate (1:n )
Prime key
length (entire alternate)
+ length (prime) < 254
length (prime)
Full value of alternate
AND of prime used
Prime key used alone
Alternate key
(ORGANIZATION
RELATIVE or
INDEXED)
Same alternate
or alternate (1:n )
Full alternate must be
unique (no
DUPLICATES) < 254
Full value of alternate
used alone
Example 9-63. START Statement for Indexed File
SELECT RECEIVABLES-MASTER ASSIGN TO "RECMAST"
ORGANIZATION IS INDEXED
ACCESS MODE IS DYNAMIC
RECORD KEY IS INVOICE-NUMBER
ALTERNATE RECORD KEY IS COMPANY-NAME
WITH DUPLICATES.
...
PROCEDURE DIVISION.
...
OPEN I-O RECEIVABLES-MASTER
...
MOVE LOW-VALUES TO COMPANY-NAME
START RECEIVABLES-MASTER KEY NOT LESS THAN COMPANY-NAME
INVALID KEY
DISPLAY "ERROR STARTING READ FOR REPORT"
GO TO REPORT-EXIT
END-START.
GET-NEXT-RECORD.
READ RECEIVABLES-MASTER NEXT RECORD
AT END PERFORM...










