Technical data

Example 6–2 Owner and Member Test Condition
.
.
.
000130 MAIL-LINE ROUTINE.
000140 MOVE "PART D" TO PART_DESC.
000150 PERFORM FIND-PARTS.
000160 MOVE "PART L" TO PART_DESC.
000170 PERFORM FIND-PARTS.
000180 GO TO ALL-FINISHED.
000190 FIND-PARTS.
000200 FIND FIRST PART USING PART_DESC.
000210 IF PART-IS-MISSING
000220 PERFORM PART-MISSING.
000230 PERFORM PARTS-ANALYSIS.
000240 FIND OWNER WITHIN RESPONSIBLE_FOR.
000250 PERFORM WORKLOAD-ANALYSIS.
000250 DONE-ANALYSIS.
000260 EXIT.
.
.
.
When PART L becomes current of run unit, a FIND OWNER (statement 000240)
finds PART D’s owner, thus producing incorrect results. This is because a FIND
OWNER WITHIN set-name uses the current of set type and PART L is not a
member of any RESPONSIBLE_FOR set type occurrence. To prevent this error,
statement 000240 should read:
IF RESPONSIBLE_FOR MEMBER
FIND OWNER WITHIN RESPONSIBLE_FOR
ELSE
PERFORM PART-HAS-NO-OWNER.
6.4 Using IF EMPTY Instead of IF OWNER
The OWNER test condition does not test whether the current record owns any
member records. Rather, this condition tests if the current record participates
as an owner record. If a record type is declared as the owner of a set type, an
OWNER test for that record type will always be true. Therefore, referring to
Figure 6–2, if EMP4 is the object of an IF RESPONSIBLE_FOR OWNER test, the
result is true because EMP4 is an owner record, even though the set occurrence
is empty.
To test if an owner record owns any members, use the EMPTY test condition. For
example:
IF RESPONSIBLE_FOR IS EMPTY PERFORM EMPTY-ROUTINE
ELSE ...
Thus, if EMP4 is the object of an IF RESPONSIBLE_FOR IS EMPTY test, the
result is true because the set occurrence has no members.
6.5 Modifying Members of Sorted Sets
If the schema defines a set’s order to be SORTED and you modify any data items
specified in the ORDER IS clause of the schema, the record may change position
within the set occurrence. If the record does change position, the set’s currency
changes to point to the member record’s new position.
6–6 DML Programming—Tips and Techniques