The following topics discuss two specialized techniques associated with describing external data sources. |
In this section: |
Reading Complex Data Sources With User-Written Procedures in VSAM |
It is possible to describe external data sources that have two different types of descendant segments to FOCUS. The first segments are made up of multiple-occurrence fields within a single record of a given type. These you describe with the OCCURS attribute. You could also have descendant segments, describing separate, but related, records distinguished by a field that determines their record type. You describe this type of descendant segment using a RECTYPE field declaration in the Master File to describe the external field.
The external data structure below has both types of segments. The first record, of type 01, contains several different sequences of repeating fields, all of which are described in the FOCUS structure as descendant segments, possessing an OCCURS attribute. The file also contains two separate types of records, (02 and 03) that contain information related to that in record type 01. This relationship was established in the external data structure. Here, we are simply concerned with describing that relationship to FOCUS.
The relationship between the records of various types is also expressed as a parent-child relationship. The children containing record types 02 and 03 will not have OCCURS attributes. They are distinguished from their parent by the field declaration: FIELDNAME=RECTYPE.
01 |
T1 |
N1 |
B1 |
B2 |
C1 |
C1 |
C1 |
D1 |
D1 |
D1 |
D1 |
D1 |
D1 |
D1 |
B1 |
B2 |
C1 |
C1 |
D1 |
D1 |
D1 |
D1 |
D1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
02 |
E1 |
03 |
F1 |
The Master File for this data source is:
FILENAME=EXAMPLE1, SUFFIX=FIX,$
SEGNAME=A, SEGTYPE=S0 ,$
FIELDNAME=RECTYPE ,ALIAS=01 ,ACTUAL=A2 ,USAGE=A2 ,$
FIELDNAME=T1 ,ALIAS= ,ACTUAL=A1 ,USAGE=A2 ,$
FIELDNAME=N1 ,ALIAS= ,ACTUAL=A1 ,USAGE=A1 ,$
SEGNAME=B, SEGTYPE=S0, PARENT=A,OCCURS=VARIABLE,$
FIELDNAME=B1 ,ALIAS= ,ACTUAL=I2 ,USAGE=I2 ,$
FIELDNAME=B2 ,ALIAS= ,ACTUAL=I2 ,USAGE=I2 ,$
SEGNAME=C, SEGTYPE=S0, PARENT=B,OCCURS=B1,$
FIELDNAME=C1 ,ALIAS= ,ACTUAL=A1 ,USAGE=A1 ,$
SEGNAME=D, SEGTYPE=S0, PARENT=B,OCCURS=7,$
FIELDNAME=D1 ,ALIAS= ,ACTUAL=A1 ,USAGE=A1 ,$
SEGNAME=E, SEGTYPE=S0, PARENT=A,$
FIELDNAME=RECTYPE ,ALIAS=02 ,ACTUAL=A2 ,USAGE=A2 ,$
FIELDNAME=E1 ,ALIAS= ,ACTUAL=A1 ,USAGE=A1 ,$
SEGNAME=F, SEGTYPE=S0, PARENT=E,$
FIELDNAME=RECTYPE ,ALIAS=03 ,ACTUAL=A2 ,USAGE=A2 ,$
FIELDNAME=F1 ,ALIAS= ,ACTUAL=A1 ,USAGE=A1 ,$
It produces the following FOCUS data structure:
Segments A, B, C, and D all belong to the same physical record. Segments E and F are each stored on separate physical records in the external file.
Notes regarding this FOCUS data structure:
Segments A, E, and F are different physical records, related through their record types. The record type attribute consists of certain prescribed values and is stored in a fixed location in the external records. FOCUS expects to read the records in a given order. If the first record does not have a RECTYPE of 01, the file is considered to be in error. The next record can have a RECTYPE of either 01 (in which case the first record is considered to have no descendants except the OCCURS descendants) or 02. A record with a RECTYPE of 03 can only follow a record with a RECTYPE of 02 (its parent).
The OCCURS descendants all belong to the record whose RECTYPE is 01. (This is not a necessary condition; records of any type can have OCCURS descendants.) Note that the OCCURS=VARIABLE segment, Segment B, is the right-most segment within its own record type. If you look at the external data structure shown above, the pattern that makes up Segment B and its descendants (the repetition of fields B1, B2, C1, and D1) extends from the first mention of fields B1 and B2 to the end of the record.
Although fields C1 and D1 appear in separate segments, they are actually part of the repeating pattern that makes up the OCCURS=VARIABLE segment. Since they occur multiple times within Segment B, they are each assigned to their own descendant segment. The number of times field C1 occurs depends on the value of field B2. In the example, the first value of field B2 is 3, the second, 2. Field D1 occurs a fixed number of times, 7.
There are various ways to read complex external data sources with user-written procedures. You can invoke a user exit and combine user-written code with data driver logical functions. These techniques are described in User Exits for Non-FOCUS Data Sources.
You could also write your own routine to provide records to the FOCUS report writer from any source, which FOCUS will treat exactly as if they resided in a FOCUS data source. These user-written routines must be coded as subroutines in C, FORTRAN, COBOL or BAL, and they pass data to the FOCUS calling program through arguments in the subroutine. User Exits for Non-FOCUS Data Sources provides an example of implementing this approach in FORTRAN. When taking this approach, be sure to refer to the PTF documentation in the READMEF file for OS/390 Installation concerning any applicable language environment (LE) fixes
User Exits for Non-FOCUS Data Sources also demonstrates the use of a decompression exit (ZCOMP1) for working with compressed VSAM data sources and flat files.
Information Builders |