Introduction to ENFORM

Connecting Files
Using ENFORM to Produce Complete Reports
4–10 058051 Tandem Computers Incorporated
The report in Figure 4-9 contains items from both files based on the connecting
relationship expressed by the WHERE clause of the LIST statement. There are several
things that you should notice about this LIST statement:
1. suppnum had to be qualified as fromsup.suppnum to identify which file to select it
from. If you forget to do this and try to list the field, ENFORM will generate the
following message:
Name not sufficiently qualified to avoid ambiguity:
SUPPNUM
2. The BY clauses sort the report in ascending order by suppnum and by suppname,
and suppress the printing of multiple values of these fields.
3. The WHERE clause expresses the connecting relationship. Basically, it specifies
that ENFORM should select items from both files only when the suppnum field of a
record in the supplier file equals the suppnum field of a record in the fromsup file.
Again, notice that the field names had to be qualified with their respective file
names.
Using WHERE to connect files allows you to qualify the connection by using logical
expressions to further define what information should appear on the report.
For example, entering:
>OPEN fromsup,supplier;
>LIST BY fromsup.suppnum, BY suppname, partname, partcost,
WHERE fromsup.suppnum = 1 AND
fromsup, suppnum = supplier.suppnum:
will generate the report in Figure 4-10.
Figure 4-10. Connecting Files Using WHERE and Logical Expressions
SUPPNUM SUPPNAME PARTNUM PARTCOST
1 TANDEM COMPUTERS 212 92000.00
244 87000.00
6201 5800.00
7301 2400.00
In this report, the information has been more precisely defined by first testing the
records to be selected to determine if they meet the condition—suppnum equal to 1;
otherwise, it is the same as the report in Figure 4-9.
Using the LINK Statement
to Connect Files
The LINK statement is a convenient way of expressing a connecting relationship.
Actually, LINK is just another form of a WHERE qualification with one difference—
the linked file description is stored in an internal table and remains available for use in
all subsequent LIST statements until it is cleared by an ENFORM command or the
session is terminated.