User guide

Connecting Record Descriptions to Form New Relationships
Developing an ENFORM Query
058058 Tandem Computers Incorporated 3–21
Since employee is linked optionally to both region and branch, the logical record
occurrences built for the linked record descriptions contain all of the employee records.
The SUPPRESS WHERE clause tells ENFORM that you are interested only in those
logical record occurrences that do not have data values in the fields that correspond to
the region and branch records. ENFORM, therefore, produces the following report:
EMPNAME REGNUM BRANCHNUM
------------------ ------ ---------
ALDEN SPROWLES 67 2
JOAN ZIMMERMAN 11 3
BOB CHAPIN 17 99
CHARLES WONG 9 0
LIZ CHAMBERS 59 1
By specifying multiple links, you can use ENFORM to produce a report that lists an
item and its component items. Suppose, for example, that your data base contains the
files described in the following record descriptions:
RECORD newpart. RECORD component.
FILE IS newpart KEY-SEQUENCED. FILE IS compon RELATIVE.
02 p-no PIC 9(4). 02 component-key.
02 p-name PIC X(20). 04 part-no PIC 9(4).
02 p-price PIC 9(4)V99. 04 compon-noPIC 9(4).
KEY 0 IS p-no. KEY "pn" IS part-no.
KEY "nm" IS p-name. KEY "cn" IS compon-no.
END END
You could produce a report that lists each part and its main components by opening
copies of these record descriptions and linking them appropriately. For example, you
could:
1. Open the original record descriptions (newpart and component) and a copy of
newpart (npart-1). The copy of newpart will be used to supply the name of the
component part.
OPEN newpart, component;
OPEN npart-1 AS COPY OF newpart;
2. Establish the appropriate links between the record descriptions. The LINK
OPTIONAL statement ensures that all part names (even those that do not have
components) appear on the report. The LINK statement links the component
number to the copy of newpart, thus allowing access to the name of the component.
LINK newpart.p-no TO OPTIONAL component.part-no;
LINK component.compon-no TO npart-1.p-no;
3. LIST the part name and the names of its main components.
LIST BY newpart.p-name HEADING "PART",
BY npart-1.p-name HEADING "MAIN COMPONENTS";