HP RPG/XL Programmer's Guide (30318-90001)

3-: 18
is to be used for MASTERD.
5 This line reads MASTERC randomly by department number, DEPT.
Columns 28-32 are CHAIN to specify that chained (random)
processing be performed for the file MASTERC. The key is DEPT.
6 This line starts the code that processes MASTERD sequentially by
secondary key.
Columns 28-32 are SETLL to set the beginning secondary key value
for MASTERD. SETLL set the file pointer to the key value placed
in LNAME.
7 This line starts the loop that reads the KSAM file sequentially
by secondary key.
8 This line reads MASTERD until there are no more records having a
last name equal to LNAME.
Reading a KSAM File Chronologically. When you read a KSAM file in
chronological order, you're reading the KSAM data file from beginning to
end. Records are read from the data file in the order that they were
originally added to the file. The KSAM file key file is not used.
Figure 3-15 gives an example of how records are stored in a KSAM data
file. In this example, only the key values are shown and the key field
occupies the first two bytes of the record. Notice that the records are
not physically ordered by key value. Records that are inactive (deleted)
have a value of FFFF (hexadecimal) in the first two bytes (regardless of
where the key is located). When you read chronologically, inactive
records are bypassed automatically.
Figure 3-15. The Chronological Order of Records in a KSAM Data File
The following File Description Specification processes a KSAM file in
chronological order.
.
Figure 3-16. Reading a KSAM File in Chronological Order