Focal Point
Variable VSAM files

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7361068331

June 03, 2005, 02:02 PM
JackieInLR
Variable VSAM files
I am having trouble trying to figure out how to do a simple Core Focus report displaying data from a variable portion of a VSAM file. I cannot find anything on how to do this in the Focus documentation. The variable portion is in an 'OCCURS DEPENDING ON' area. I only want to list the first 5 occurences something like this:

Store Dept1 Dept2 Dept3 Dept4 Dept5
xxx 111 222 333 444 555

The MFD is set up with an occurs with a variable as the number associated with the occurs.

Can anyone help? Confused

Thanks,
Jackie
June 03, 2005, 03:02 PM
<Joseph Coule>
Hi, Jackie,

A VSAM file with a segment described with OCCURS is exactly like a child segment in a FOCUS DB (or any other kind of DB for that matter). You're creating a logical hierarchy where the segment where STORE is located is the parent segment of the segment where DEPT is located. So FOCUS will treat each instance of DEPT as a separate record and, by default, will print each record on a separate line. So the question is really how can you get FOCUS to print 5 records on one line.

For this you'll probably need to use the McGuyver technique that is documented on the Tech Support web site so you can "flatten" out the records. But a simpler solution may be to create an alternate Master File Description to read the data for this particular report. This will only work if "DEPT" has at least 5 instances in each record. If you do not know this to be true, then don't try this.

Basically, what you would do is create a new Master file where you move the fields that are in the OCCURS=FIELDNAME segment up to the end of the parent segment and list these five times. If the only field in that segment is DEPT, then this is simple, just list DEPT 5 times, with different fieldnames (e.g., DEPT1, DEPT2, DEPT3, DEPT4, DEPT5), then follow this immediately with the existing child segment defined with OCCURS=VARIABLE (instead of OCCURS=FIELDNAME). This will allow FOCUS to keep reading the variable portion of the record, which you do not need for this particular report.

IF you can't create your own MFD, or if you're not sure that there are at least 5 instances of DEPT for each record, then you'd be best off going with the McGuyver technique which others on the board couple probably help you with more than I. But the fact that it's a VSAM file is not relevant to the reporting aspect of the question.

Hope that helps.

JC