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

5- 15
1 This line defines the input field, KEY05. It occupies positions
71 to 75 in the input record, TRANS.
2 This line begins the data structure, KEY06.
3 This line defines the first subfield, ALPHA, in the data
structure. ALPHA occupies the first position of KEY06.
4 This line defines the position in the data structure that KEY05
occupies. It is the second field and occupies positions 2
through 6.
5 This line is part of the initialization operations. It sets the
field, ALPHA, to A (it remains A for the duration of the
program).
6 This line reads the file, FILE1, by key value. The specific key
value used has already been placed into the data structure,
KEY06, by previous operations.
Figure 5-11 shows how to reorganize an input record so that its fields
closely match those of an output record. When TRANS is read, RPG
automatically moves its input fields to the appropriate areas in the
KEYDS data structure. Notice that the input fields, QTY and CODE, are
not included in the data structure. The PRTKEY field is optional. It
can be used to refer to all 16 positions of the KEYDS data structure
(KEYDS also refers to these positions).
Figure 5-11. Using a Data Structure to Reorganize Input Fields
Comments
1 This line begins the description of the data structure, KEYDS.
2 This line defines LOCATN as the first field in KEYDS. Since
LOCATN is also defined in the input record, its value is moved