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

3-: 16
Column 32 is I to specify that this is a KSAM file.
2 This line defines the KSAM file, MASTERD.
Column 16 is D to indicate that MASTERD is a demand file.
Column 28 is L to specify that MASTERD will be processed within
key limits.
Column 32 contains I to specify that this is a KSAM file.
3 This line reads MASTERC randomly by department number, DEPT.
Columns 28-32 are CHAIN to specify that chained (sequential)
processing be performed for the file MASTERC. The key is DEPT.
4 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 sets the file pointer to the key value placed
in LNAME.
5 This line starts the loop that reads the KSAM file sequentially
by secondary key.
6 This line reads MASTERD until there are no more records having a
last name equal to LNAME.
Using File Description Continuation Lines.
The second way to read a KSAM more than one way in a program is to enter
two separate files in the program but include File Description
Continuation lines for each of them. These lines equate the two files to
the same physical KSAM file (you don't need FILE equations to do this).
Figure 3-14 shows how this is done. The file, MASTERC, is processed
randomly and the files, MASTERD is processed sequentially within key
limits. The File Description Continuation lines contain DSNAME entries
that equate the files to the KSAM file, MASTFL. When you use File
Description Continuation lines in this way, both files are treated as
one. They have the same file number and pointer and they share the same
buffer. Therefore, when you use this method, make sure that the read
operations restore the file pointer values properly.