quote:
Originally posted by kiddpete:
[qb] Can this file structure be represented in FOCUS? I would like to extract data from two or more record types, and sort the results based on the common parent information without using an intermediate file such as HOLD. [/qb]
Yup. To do this, you simply define the fixed portion of the record as the PARENT segment - SEGNAME=ROOT - which is everything in the record up until the RECTYPE identifier.
Then define each logical child with "PARENT=ROOT, OCCURS=VARIABLE" because each child record may or may not exist for each parent record.
You begin each child record with your RECTYPE field and specify the VALUE in the ALIAS that defines each specific record type. Each RECTYPE gets its own SEGMENT (unless you have one segment that has multiple RECTYPE identifiers, in which case you can use the ACCEPT clause to specifiy a list or range of RECTYPE values).
The only way you'll get into trouble is if you try to print from multiple segments and you do WHERE or IF tests on values in one of the CHILD segments. This would get you a "testing on independent paths" error message since you'd be testing on one logical path and printing from another. But you might be able to do an alternate view to get around that. I'm pretty sure you can do this even on fixed files. Testing on fields in the ROOT segment will not cause any errors.
Here's a sample MFD so you can see the syntax. Search the doc for the section "Describing a VSAM Repeating Group With RECTYPEs" to see more examples.
In this example, RECTYPE values of "B" or "C" represent one type of child record, "D" is another type and "E" is the final record type.
FILENAME=SAMPLE,SUFFIX=VSAM,$
SEGNAME=ROOT,SEGTYPE=S0,$
GROUP=GRPKEY ,ALIAS=KEY ,USAGE=A8 ,ACTUAL=A8 ,$
FIELD=FLD000 ,E00 ,A08 ,A08 ,$
FIELD=A_DATA ,E01 ,A02 ,A02 ,$
SEGNAME=SEG001,PARENT=ROOT,OCCURS=VARIABLE,SEGTYPE=S0 ,$
FIELD=RECTYPE ,A01 ,A01 ,ACCEPT=B OR C ,$
FIELD=B_OR_C_DATA ,E02 ,A08 ,A08 ,$
SEGNAME=SEG002,PARENT=SEG001,OCCURS=VARIABLE,SEGTYPE=S0,$
FIELD=RECTYPE ,D ,A01 ,A01 ,$ FIELD=D_DATA ,E03 ,A07 ,A07 ,$
SEGNAME=SEG003,PARENT=ROOT,OCCURS=VARIABLE,SEGTYPE=S0 ,$
FIELD=RECTYPE ,E ,A01 ,A01 ,$ FIELD=E_DATA ,E04 ,A06 ,A06 ,$
If the RECTYPE does not appear at the very end of the fixed portion of the record, then you may be able to do this a little differently with MAPFIELD/MAPVALUE (similar to RECTYPE).
Hope this helps.
-Chris