When you define a segment in the IMS database as a unique descendant of its immediate parent, each instance of the parent can have at most one occurrence of that type of child. In the Master File, you identify a unique segment with SEGTYPE=U.
Normally, you define a segment as unique if the IMS segment is defined with no twin pointer (PTR=NOTWIN). However, since FOCUS has no way of verifying that the DBD describes the segment in this way, you can define a segment as unique whenever you want to retrieve only the first logical instance of that segment (per parent). This technique can be useful when the first instance is the current instance, and only current data from that segment is of interest.
FOCUS retrieves unique segments prior to retrieving any non-unique children of the same parent. You can see the order in which FOCUS retrieves segments by issuing the following command:
CHECK FILE filename PICTURE RETRIEVE
Unique segments have two useful properties that reduce the complexity of the file:
When a report request references a non-unique child segment, FOCUS, by default, omits parent segments that have no instance of that child from the report. This retrieval path is called a short path. The retrieval of a unique child segment never results in a short path because FOCUS supplies default values for fields from absent unique children.
For example, in the preceding diagram, if the request references data from segment B, but segment A has no instance of segment B, the adapter generates suitable default values (blank if the field is alphanumeric, zero if numeric) to make it appear that a B instance was retrieved. Had segment B not been defined as unique, FOCUS would have omitted segment A from the report.
These concepts also apply to joins. In a non-unique join, a host segment that lacks a matching cross-referenced segment represents a short path and is omitted from the resulting report. However, with a unique join, as with a unique segment, FOCUS supplies default values for missing cross-referenced fields in the resulting report.
For example, the following request references a unique join between two IMS databases that have no matching records:
JOIN SSN IN EMPDB01 TAG F1 TO SSNALPHA IN EMPDB02 TAG F2 AS J1 TABLE FILE EMPDB01 PRINT F1.SSN F2.SSNALPHA END
Although the two files have no matching segments, the request produces a report that includes every segment from the host file. It assigns a blank value to each SSNALPHA field:
NUMBER OF RECORDS IN TABLE= 1667 LINES= 1667 PAGE 1 SSN SSNALPHA --- -------- 1 2 3 4 5 6 7 8 9 10 . . .
The next request is identical to the previous one, except for the keyword ALL in the JOIN command. Once again, there are no matching records in the host and cross-referenced databases:
JOIN SSN IN EMPDB01 TAG F1 TO ALL SSNALPHA IN EMPDB02 TAG F2 AS J1 TABLE FILE EMPDB01 PRINT F1.SSN F2.SSNALPHA END
This request produces no report because the join is non-unique, and short paths are omitted:
NUMBER OF RECORDS IN TABLE= 0 LINES= 0
For a complete discussion of short path behavior, consult the Creating Reports manual.
Information Builders |