Accessing Bill-of-Materials Structures
A bill-of-materials structure is a relationship between record occurrences of the same type. This structure is derived from the manufacturing environment where it is used to demonstrate relationships between parts: a part can be a component of another part and a part can contain other parts as its components.
idmscu19
A bill-of-materials structure is a relationship between record occurrences
of the same type
. This structure is derived from the manufacturing environment where it is used to demonstrate relationships between parts: a part can be a component of another part and a part can contain other parts as its components.This structure is typically represented as a many-to-many relationship (that is, by using two sets and a junction record).
This article describes the following information:
Example of a Bill-of-Materials Structure
In the EMPLOYEE database, a bill-of-materials structure signifies relationships between managers and subordinates: an employee can
manage
other employees through the MANAGES set, and can also be managed by
other employees through the REPORTS-TO set.The figure below shows this bill-of-materials structure. The STRUCTURE record serves as the junction record between employees and their managers. Note that one set is defined with the automatic set membership option and the other is defined with the manual set membership option.
┌──────────────────────────────┐ │ EMPLOYEE │ ├─────┬─────┬──────┬───────────┤ │ 415 │ F │ 116 │ CALC │ ├─────┴─────┴──────┴─────┬─────┤ │ EMP-ID-0415 │ DN │ ├────────────────────────┴─────┤ │ EMP-DEMO-REGION │ └───────────┬──────┬───────────┘ │ │ REPORTS-TO │ │ MANAGES NPO OM NEXT │ │ NPO MA NEXT │ │ │ │ ┌───────────▼──────▼───────────┐ │ STRUCTURE │ ├─────┬─────┬──────┬───────────┤ │ 440 │ F │ 3 │ VIA │ ├─────┴─────┴──────┴─────┬─────┤ │ MANAGES │ │ ├────────────────────────┴─────┤ │ EMP-DEMO-REGION │ └──────────────────────────────┘
Storing a Bill-of-Materials Structure
To store a bill-of-materials structure in the database, perform the following steps:
- Establish currency at the owner record in the automatic set:MOVE 15 TO EMP-ID-0415. OBTAIN CALC EMPLOYEE.
- Initialize and store the junction record:PERFORM A100-INITIALIZE-STRUCTURE. STORE STRUCTURE.The DBMS automatically connects the STRUCTURE record to the automatic set (MANAGES); EMPLOYEE 15 is now defined as the manager in the bill-of-materials structure.
- Set run-unit currency at the owner record in the manual set:MOVE 467 TO EMP-ID-0415. OBTAIN CALC EMPLOYEE.
- Connect the junction record to the manual set:CONNECT STRUCTURE TO REPORTS-TO.The bill-of-materials structure is now complete; EMPLOYEE 467 reports to EMPLOYEE 15.
Example of Storing a Bill-of-Materials Structure
The figure below shows the steps and currencies involved in storing an occurrence of a bill-of-materials structure.
To define EMPLOYEE 15 as the manager of EMPLOYEE 467, store and connect a STRUCTURE record as a member of the two EMPLOYEE records: EMPLOYEE 15 in the MANAGES set and EMPLOYEE 467 in the REPORTS-TO set.
Retrieving a Bill-of-Materials Structure
A bill-of-materials structure can contain a variable number of levels. Tracing all records under a given record (for example, finding a manager and all subordinates, and all of their subordinates, and so on) is called an
explosion
of the structure for that record. Tracing all records above a given record (for example, finding an employee and manager, and the manager's manager, and so on) is called an implosion
of the structure for that record.To perform a multilevel explosion or implosion, you must maintain a stack of db-keys in order to reestablish the appropriate currencies.
Steps to Retrieve One Bill-of-Materials Level
To retrieve a manager and one level of employees, perform the following steps:
- Retrieve the manager's EMPLOYEE record:MOVE 15 TO EMP-ID-0415. OBTAIN CALC EMPLOYEE.
- Retrieve the first STRUCTURE record in the MANAGES set:FIND NEXT STRUCTURE WITHIN MANAGES.
- Because REPORTS-TO is defined as OM, you must test for set membership:IF NOT REPORTS-TO MEMBER GO TO A100-EXIT.
- Retrieve the owner EMPLOYEE record in the REPORTS-TO set:OBTAIN OWNER WITHIN REPORTS-TO.
- FIND the current STRUCTURE record to reestablish the original currency within the MANAGES set:FIND CURRENT STRUCTURE.
- Retrieve the next STRUCTURE record in the MANAGES set:FIND NEXT STRUCTURE WITHIN MANAGES.Perform steps 3 through 6 iteratively until step 6 returns a status of 0307 (DB-END-OF-SET).
Example of One Bill-of-Materials Level
The figure below shows the relationship between manager and employees by showing all the employees managed by employee 15.
Steps to Retrieve Additional Levels
To retrieve an EMPLOYEE record, its manager's EMPLOYEE record, its manager's manager, and so on, perform the following steps:
- Retrieve the specified EMPLOYEE record:MOVE 91 TO EMP-ID-0415. OBTAIN CALC EMPLOYEE.
- Retrieve the STRUCTURE record in the REPORTS-TO set:FIND NEXT STRUCTURE WITHIN REPORTS-TO. IF ERROR-STATUS = '0307' GO TO A100-EXIT.
- Optionally, test the junction record for predetermined criteria (for example, if you only want managers for a specific project). Testing for selection criteria in the junction record can prevent looping if there are any circular structures defined.
- Retrieve the owner EMPLOYEE record in the MANAGES set:OBTAIN OWNER EMPLOYEE WITHIN MANAGES.Perform steps 2 through 4 iteratively until step 2 returns a status of 0307, indicating that the REPORTS-TO set is empty.
Example of Retrieving Additional Levels
The figure below shows the relationship between an employee and all managers on the P2 project by showing the hierarchy of managers above EMPLOYEE 91 on the project.