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

5- 9
names of employees matching a selected department number.
Columns 27-32 contain AR which is the name of the last names
array.
Columns 36-39 contain 10 to specify that there are 10 elements
in the array.
Columns 40-42 contain 29 to specify that each element in the
array is 29 characters long.
4 This line begins the input record description for the employee
master file, MASTFL.
5 This line begins the input record description for the terminal
file, TERMINAL.
6 This line reads a department number entered from the terminal.
7 This line reads a record (for the department) in the employee
master file, MASTFL.
8 This line increments the index, I, to the AR array. (An
employee record matched the department entered by the user.)
9 This line compares the AR index I to its maximum value. If the
array is full, indicator 21 is turned on.
10 This line begins the output record description for the teminal
file, TERMINAL. This record is displayed when indicator 21 is
turned on.
11 This line specifies that the second field to be displayed in the
TERMINAL output record is contained in the AR array.
Using Data Structures
A data structure is an area of storage that contains subfields. You can
use data structures to describe input areas in more than one way. You
may want to do this because:
* You need to process records in the same file and they have different
formats.
* You need to reference subfields of fields as well as the fields
themselves.
* You can process input fields more conveniently if they are
rearranged.
Data structures can also be used to exchange information between other
RPG programs.
You use Input Specifications to define a data structure. Place data
structures at the end of all of the other Input Specifications in the
program.
The "data structure" sections which follow in this chapter discuss the
ways you can use data structures to accomplish the objectives listed
above.
NOTE HP implements data structures differently from some RPG vendors.
Data structures occupy separate memory areas from the areas they
redefine. Thus, you should not use data structures simply to
reduce memory requirements in your program.
Using Data Structures to Define Data More Than One Way
This section explains how to use data structures to describe the same
data areas in more than one way. This enables you to use the same data
several different ways. For example, you can use data structures to