Introduction to ENFORM
Listing Information From a File Onto a Report
Using ENFORM to Produce Complete Reports
4–6 058051 Tandem Computers Incorporated
Notice that the fields are printed in the order specified by the LIST statement.
Sorting a File Listing The report in Figure 4-3 could be hard to use if you scan it by the supplier number.
The numbers are in the order in which they occur in the file. If the list was very long,
it would be quite difficult to search the list for a specific number/part number
relationship.
To help the report reader in this kind of situation, ENFORM provides the capability of
sorting the report into ascending or descending order by providing clauses that
augment the LIST statement. Report sorting is controlled by the ASCD and DESC
clauses, and BY clauses. ASCD specifies that a report be sorted by a field in ascending
order. DESC specifies sorting in descending order. BY causes the report to be sorted
by a specified field and additionally suppresses the printing of subsequent occurrences
of that field with like values.
The ASCD or DESC clauses are placed before the field name that is to be sorted. For
example, to sort a report in ascending order by supplier number, you enter:
>LIST ASCD suppnum, partnum, partcost;
which will generate the report in Figure 4-4.
Figure 4-4. A Simple Report Sorted by a Field Value—Ascending
SUPPNUM PARTNUM PARTCOST
1 212 92000.00
1 244 87000.00
1 6201 5800.00
1 7301 2400.00
6 4102 14500.00
6 7103 24500.00
10 7102 68000.00
In Figure 4-4, one of the sorted values —supplier number —is duplicated in several
records. When there is duplication of values, it is often useful to use the BY clause (in
place of ASCD) to include the first occurrence of the value in the report and leave the
remaining values blank. For example, entering:
>LIST BY suppnum, partnum, partcost;
will generate the report in Figure 4-5.