Technical data
Figure 5–16 Bachman Diagram of a Many-to-Many Relationship Between
Records of the Same Type
COMPONENT
ZK−1494−GE
PART
PART_USED_ON
PART_USES
For example, assume you are creating a bill of materials and you have a
finished part, a stool, made from one stool seat and four stool legs. Figure 5–17,
Figure 5–18, Figure 5–19, and Figure 5–20 show occurrence diagrams of the bill
of materials you would need to build a stool.
To complete the bill of materials you have to link the stool seat and stool legs to
the finished part, the stool. You would:
1. Use the FIND statement to locate the stool.
PROCEDURE DIVISION.
100-FIND-STOOL.
MOVE "STOOL" TO PART_DESC.
FIND FIRST PART USING PART_DESC.
Figure 5–17 Current of PART_USES and PART_USED_ON
STOOL
(CURRENT OF PART_USES AND PART_USED_ON)
ZK−1495−GE
2. Use the FIND statement to locate the stool seat retaining PART_USES
currency. Because PART usually owns both sets, using a FIND or FETCH
statement to locate PART changes both set currency indicators. Retaining
PART_USES currency keeps a pointer at STOOL; otherwise, STOOL SEAT
would be current for both sets. Section 5.13 discusses currency indicators in
more detail.
200-FIND-STOOL-SEAT.
MOVE "STOOL SEAT" TO PART_DESC.
FIND FIRST PART USING PART_DESC
RETAINING PART_USES.
5–18 Database Programming with HP COBOL