COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
position
specifies that a combination of alternate key or prime key (specified by key in the KEY
phrase) and position-key (specified either by the file prime key or by a unique alternate
key) is to be used to position the file. This phrase is not permitted for files having sequential
organization, or files having the INSERTIONORDER attribute.
BEFORE
specifies that the file position indicator is set to the record before the position defined
by the values of key and position-key
.
NOTE: Only use BEFORE when the file will subsequently be read in reverse. If the
file is not read in reverse, reading is slightly less efficient.
AFTER
specifies that the file-position indicator is set to the record after the position defined by
the values of key and position-key.
If neither BEFORE nor AFTER is present, the file-position indicator is set to the record at the
position defined by the values of key and position-key.
position-key
is either the file prime key or a unique alternate key. If position-key is the file prime
key (the prime record key of an indexed or queue file or the relative key of a relative
file), then key must refer to one of:
• The prime key
• A leftmost subordinate of the prime key
• An alternate key
• A leftmost subordinate of an alternate key
If position-key is a unique alternate key (a key described without the DUPLICATES
clause), then key must refer to the same alternate key (or to a leftmost subordinate of
that alternate key).
If position-key is a leftmost subordinate of a prime or alternate key, see GENERIC.
APPROXIMATE
is the default positioning mode. APPROXIMATE means that reading begins at the first record
that satisfies the relationship that the KEY phrase specifies. Subsequent READ statements read
the records in file key order or physical order, depending on the file’s organization, until the
end of the file is reached.
GENERIC
is an alternative positioning mode. If GENERIC is used, then relationship must be EQUAL,
EQUAL TO, or =. Reading begins at the first record that satisfies the relationship and continues
until the relationship is not satisfied (logical end of file).
GENERIC is usually used with a partial key; that is, a subordinate item of the key defined for
the file. Use of the leftmost subordinate governs the action of the GENERIC clause, but the
452 Procedure Division Verbs










