IBM AS/400 Manual Do Utilizador

Página de 489
 
Using Program-Described Disk Files
 
 
On the file description specifications, the length of the key field is defined as 10 in
positions 29 through 33 (the combined number of positions required for the ORDER
and ITEM fields). The starting position of the key field is described as 15 using the
keyword KEYLOC (starting in position 44). The starting position must specify the
first position of the first key field.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++++++++++++
FORDDTLL 
IP 
F
120
10AIDISK
KEYLOC(15)
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++++++
DKEY 
DS
D K1
1
5
D K2
6
10
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
MOVE
ORDER
K1
MOVE
ITEM
K2
KEY
CHAIN 
ORDDTLL
99
Figure  143.  (Part 2 of 2). Using Data Description Specifications to Define the Access Path
(Composite Key) for an Indexed File
When the DDS specifies a composite key, you must build a search argument in the
program to CHAIN to the file. (A KLIST cannot be used for a program-described
file.) One way is to create a data structure (using definition specifications) with sub-
fields equal to the key fields defined in the DDS. Then, in the calculations, set the
subfields equal to the value of the key fields, and use the data-structure name as
the search argument in the CHAIN operation.
In this example, the MOVE operations set the subfields K1 and K2 equal to the
value of ORDER and ITEM, respectively. The data-structure name (KEY) is then
used as the search argument in the CHAIN operation.
 Sequential File
Sequential files are files where the order of the records in the file is based on the
order the records are placed in the file (that is, in arrival sequence). For example,
the tenth record placed in the file occupies the tenth record position.
Sequential files can be processed randomly by relative record number, consec-
utively, or by a record-address file. You can use either the SETLL or SETGT opera-
tion code to set limits on the file.
Record Address File
You can use a record-address file to process another file. A record-address file can
contain (1) limits records that are used to process a file sequentially within limits, or
(2) relative record numbers that are used to process a file by relative record
numbers. The record-address file itself must be processed sequentially.
A record-address file is identified by an R in position 18 of the file description spec-
ifications. If the record-address file contains relative record numbers, position 35
must contain a T. The name of the file to be processed by the record-address file
must be specified on the file description specification. You identify the file using the
keyword RAFDATA(
file-name).
290
ILE RPG for AS/400 Programmer's Guide