COBOL Manual for TNS/E Programs (H06.08+, J06.03+)

If you have a structured file without alternate keys and you want it to have alternate keys, you can
use FUP to create the alternate-key file and to load the alternate-key file.
If you describe your database with DDL, the DDL compiler can produce the necessary FUP commands
to create prime-key and alternate-key files.
For more information about alternate keys, see the Guardian Programmer’s Guide.
CAUTION: Because updating the alternate-key file can require multiple write operations, certain
types of failures can cause the operating environment to fail to record alternate keys. The record
and some of its alternate keys might be updated while other alternate keys might not be updated.
To prevent this, use TMF to verify that an update to a file with alternate keys is either completed
or aborted. For information about TMF, see Chapter 32: Fault-Tolerant Processes (page 944).
Positioning
Enscribe provides three positioning modes: approximate, exact, and generic. Only approximate
positioning is available in COBOL; both approximate and generic positioning are available in
HP COBOL.
Neither COBOL nor HP COBOL supports exact positioning; it involves a variable-length key. In
using Enscribe directly, you specify a maximum key length for a key-sequenced file’s prime key or
for any alternate key. When you call the KEYPOSITION routine (analogous to HP COBOL’s START
statement), you can specify a length and a value: a compare length that is shorter than or equal
to the maximum key length, and a value of that length for the key. Exact positioning means that
the only records delivered are those whose key is the same length as the compare length and
whose value is the same as the key value. If the key is unique, at most one such record exists in
the file.
Table 124 Enscribe File Positioning Modes
Available in HP COBOL?End of File Is SignaledStarting Position Defined byPositioning Mode
NoWhen key no longer
identical to start key
Whole key valueExact Positioning
YesAt physical end of fileWhole or partial key valueApproximate Positioning
YesWhen key or partial key no
longer identical to start key
Whole or partial key valueGeneric Positioning
Approximate Positioning
With approximate positioning, you execute the START statement with a starting key, and the next
READ statement retrieves the next record in the access path that contains a value in the
corresponding data item that bears the stated relationship (equal to, greater than, or not less than)
to the starting key. Subsequent READ statements receive the records that follow in the access path.
An EOF condition arises when the actual end of the file is reached.
Approximate positioning is the default, but you can include an APPROXIMATE phrase in the START
statement for documentation purposes if necessary.
Generic Positioning
Generic positioning is like approximate positioning except that you specify a starting key that
(usually) has a shorter length than the key data item in the record. Also, the only relation permitted
with the key is the equal relation. Subsequent READ statements retrieve the records in the access
path whose key values match the starting key for as many characters as the start key has.
Suppose you want to read only the Adamses in the personnel file described in Key of Reference.
With the GENERIC phrase of the START statement (an HP extension to COBOL), you specify that
when a READ NEXT statement obtains a record with a LAST-NAME value that does not begin with
Establishing Starting Points in Files 871