If the current record of run unit participates as a member in a set defined with either the optional or the manual set membership option, you cannot assume that that record occurrence is also current of set. For example, an optional record may never have been connected to the set, or a manual record may have been disconnected from the set.
For more information about optional and manual set membership, see Set Membership Options.
Failure to Test for Set Membership
The figure below shows the invalid conclusion that can result from not testing for set membership.
Since EMPLOYEE 480 is not currently connected to an occurrence of the OFFICE-EMPLOYEE set, the OBTAIN OWNER statement retrieves the owner of the current record of set (OFFICE 3). This leads to the invalid assumption that EMPLOYEE 480 works in OFFICE 3.
R. U. Record Set Area curr. currencies currencies currencies ┌─────┐┌─────┬─────┬─────┐┌─────┬─────┐┌─────┬─────┐ │ R ││ D │ E │ O ││ D │ O ││ O │ E │ │ U ││ E │ M │ F ││ E │ F ││ R │ M │ │ N ││ P │ P │ F ││ P │ F ││ G │ P │ │ ││ A │ L │ I ││ T │ I ││ - │ - │ │ U ││ R │ O │ C ││ - │ C ││ D │ D │ │ N ││ T │ Y │ E ││ E │ E ││ E │ E │ │ I ││ M │ E │ ││ M │ - ││ M │ M │ │ T ││ E │ E │ ││ P │ E ││ O │ O │ │ ││ N │ │ ││ L │ M ││ - │ - │ │ ││ T │ │ ││ O │ P ││ R │ R │ │ ││ │ │ ││ Y │ L ││ E │ E │ │ ││ │ │ ││ E │ O ││ G │ G │ │ ││ │ │ ││ E │ Y ││ I │ I │ │ ││ │ │ ││ │ E ││ O │ O │ │ ││ │ │ ││ │ E ││ N │ N │ │ ││ │ │ ││ │ ││ │ │ ┌────────────────────────┼─────┼┼─────┼─────┼─────┼┼─────┼─────┼┼─────┼─────┤ │PREVIOUSLY ESTABLISHED │5200 ││5200 │ 477 │ 3 ││5200 │ 477 ││ 477 │ 5200│ │CURRENCIES │ ││ │ │ ││ │ ││ │ │ ├────────────────────────┼─────┼┼─────┼─────┼─────┼┼─────┼─────┼┼─────┼─────┤ │OBTAIN FIRST WITHIN │ 480 ││5200 │ 480 │ 3 ││ 480 │ 477 ││ 480 │ 5200│ │DEPT-EMPLOYEE. │ ││ │ │ ││ │ ││ │ │ ├────────────────────────┼─────┼┼─────┼─────┼─────┼┼─────┼─────┼┼─────┼─────┤ │OBTAIN OWNER WITHIN │ 3 ││5200 │ 480 │ 3 ││ 480 │ 3 ││ 480 │ 3 │ │OFFICE-EMPLOYEE. │ ││ │ │ ││ │ ││ │ │ └────────────────────────┴─────┴┴─────┴─────┴─────┴┴─────┴─────┴┴─────┴─────┘
Steps in Testing for Set Membership
You can issue the IF MEMBER statement to ensure that a record occurrence currently participates as a member of a specified set.
To determine if a record participates as a member in a set, perform the following steps:
The program excerpt below uses the IF EMPTY and the IF MEMBER statements to facilitate database navigation.
The IF EMPTY statement determines if the DEPT-EMPLOYEE set is empty; the IF MEMBER statement determines whether the current of run unit (EMPLOYEE) participates as a member in the OFFICE-EMPLOYEE set.
PROCEDURE DIVISION. . . . A100-EMP-DEPT-OFF. MOVE DEPT-ID-IN TO DEPT-ID-0410. OBTAIN CALC DEPARTMENT IF DB-REC-NOT-FOUND GO TO GET-NEXT ELSE IF DB-STATUS-OK NEXT SENTENCE ELSE PERFORM IDMS-STATUS. *** TEST TO SEE IF SET IS EMPTY *** IF DEPT-EMPLOYEE IS EMPTY MOVE NO-EMP-MESSAGE TO TITLE-OUT ELSE PERFORM A100-WALK THRU A100-EXIT UNTIL DB-END-OF-SET. A100-WALK. OBTAIN NEXT WITHIN DEPT-EMPLOYEE. *** CHECK FOR ERROR-STATUS = 0307 *** IF DB-END-OF-SET GO TO A100-EXIT ELSE IF DB-STATUS-OK NEXT SENTENCE ELSE PERFORM IDMS-STATUS. *** TEST TO SEE IF EMPLOYEE IS CURRENTLY CONNECTED TO THE SET *** IF NOT OFFICE-EMPLOYEE MEMBER MOVE NO-OFF-MESSAGE TO TITLE-OUT ELSE OBTAIN OWNER WITHIN OFFICE-EMPLOYEE PERFORM IDMS-STATUS MOVE OFFICE-ADDRESS-0450 TO ADDRESS-OUT. PERFORM U100-PRINT. A100-EXIT. EXIT.
Copyright © 2013 CA.
All rights reserved.
|
|