Getting Started with TRANSACT (32247-90007)

102 Chapter6
Data Structures
Line 9 defines a second dimension of this array. The first dimension holds the data for 10
regions. The second dimension is made up of 12 months of data for each region.
As we have seen, Transact does have definite data structures which in many respects
correlate quite closely with those in COBOL.
Transact works best when you keep in mind that you only want to add new information to
your data structure, not define anything twice. For example, the orders database has
several sets which contain the item part-number. Two of these sets are inventory and
parts. If a program needs to have access to all information contained in both of these sets,
it should only list each item one time. Since part-number is common to both sets, it should
only be listed once. To illustrate, if a program first retrieves an inventory record and then
needs to retrieve the corresponding parts record to get the part description, a good way to
do this is:
Figure 6-13. LISTing Items From Multiple Datasets
This technique can be used when an item in two or more datasets refers to the same data.
However, there are times when two datasets or files contain the same item name, but they
are independent of each other. For example, the database we have been using for examples
has two datasets that contain an item called quantity. Even though these data items share
a common name, the meaning is quite different for each set. In the inventory set, quantity
is the inventory at a particular location. In the orderline set, quantity is the quantity
ordered on this line of an order.
Perhaps we need to generate a report which lists all part numbers ordered, the order
quantity, and the total inventory on hand. The following program is one way to do this.
1 list part-number:
2 location:
3 quantity:
4 description;
5 get(serial) inventory,list=(part-number:quantity);
6 set(key) list (part-number);
7 get parts,list=(description);