Technical data
Example 5–2 Using Forked Sets
PROCEDURE DIVISION.
.
.
.
100-GET-PART.
DISPLAY "TYPE PART ID".
ACCEPT PART_ID.
IF PART_ID = "DONE"
GO TO 900-DONE-PART-INQUIRY.
FETCH FIRST PART USING PART_ID
ON ERROR
DISPLAY "PART " PART_ID " NOT IN DATABASE"
GO TO 100-GET-PART.
200-GET-SUPPLY-INFO.
FETCH NEXT SUPPLY WITHIN PART_INFO
AT END
FETCH OWNER WITHIN PART_INFO
GO TO 300-GET-QUOTE-INFO.
*****************************************************
* The FETCH OWNER statement resets currency to *
* point to the owner. This allows the search for *
* PR_QUOTE records to begin with the first member *
* record occurrence rather than after the *
* last SUPPLY record occurrence. *
*****************************************************
PERFORM 500-SUPPLY-ANALYSIS.
GO TO 200-GET-SUPPLY-INFO.
300-GET-QUOTE-INFO.
FETCH NEXT PR_QUOTE WITHIN PART_INFO
AT END
GO TO 100-GET-PART.
PERFORM 600-QUOTE-ANALYSIS.
GO TO 300-GET-QUOTE-INFO.
Figure 5–13 is an occurrence diagram of a forked set. The figure shows a part
record owning five PART_INFO member records.
5–14 Database Programming with HP COBOL