Simple ISAM and Key-Sequenced VSAM Data Sources

Most techniques for describing fixed-format records described in the FOCUS documentation assume sequential QSAM or entry-sequenced VSAM files without keys. A new element is introduced with VSAM, the key or group key. Group keys consist of one or more fields identifying the various record types in the file. In FOCUS representations of such files, each unique record type is assigned its own segment.

In this section:

Attributes Used to Describe VSAM Data Sources

File Suffixes for VSAM Data Sources

Segment Name for VSAM Data Sources

SEGTYPE for VSAM Data Sources

Describing Groups in VSAM

How to:

Code GROUP Declarations in VSAM

Example:

Describing a Group Field in VSAM

Note: For VSAM data sources, you must allocate (in OS/390) or DLBL (in DOS/VSE and VM/ESA) the Master File name to the data source's CLUSTER component.


Top of page

Attributes Used to Describe VSAM Data Sources

Standard FOCUS attributes for describing files, segments, and fields apply to VSAM data sources, with the following conditions.


Top of page

File Suffixes for VSAM Data Sources

The SUFFIX attribute in a VSAM data source declaration must have a value of ISAM or VSAM.


Top of page

Segment Name for VSAM Data Sources

The SEGNAME for the first or root segment of a VSAM data source must be ROOT. Remaining segments can have any valid name. The only exception is files with unrelated RECTYPES, for which the first SEGNAME must be DUMMY.

All non-repeating data goes in the root segment. The remaining segments may be given any valid 1- to 8-character name.

Every segment except the root is a descendant, or child, of another segment. The PARENT attribute supplies the segment name of the hierarchical parent or owner of the current segment. If no PARENT attribute appears, the default is the immediate preceding segment. PARENT names may be one to eight characters.


Top of page

SEGTYPE for VSAM Data Sources

The SEGTYPE attribute must be S0 for VSAM data sources.


Top of page

Describing Groups in VSAM

Keys of VSAM data sources are defined in SEGMENT declarations as GROUPs consisting of one or more fields. The GROUP declaration has the following syntax


Top of page

Syntax: How to Code GROUP Declarations in VSAM

GROUP=keyname,ALIAS=KEY,USAGE=Ann,ACTUAL=Ann,$ 

where:

keyname
Can have up to 66 characters.

Single-segment VSAM structures may only have one key field but you must still describe that with a GROUP declaration. Each group must have ALIAS=KEY to create a mapping to the offset and length of the VSAM key.

Groups can be assigned to provide convenient names for referencing groups of fields. If, for instance, you had three fields for employee: last name; first name; and social security number and used them frequently to identify the employee. You could identify them in your Master File as a GROUP named EMPINFO to reference them as a unit. When using the GROUP feature for non-key fields, the parameter ALIAS= must still be used, but should not be named KEY.

For group fields you must supply both USAGE and ACTUAL formats for alphanumeric fields. Their format lengths must exactly equal the sum of all subordinate field lengths.

If the fields making up a group key are not alphanumeric fields, the format of the group key is still alphanumeric, but its length is determined differently. The ACTUAL length still equals the sum of the subordinate field lengths. The USAGE format, however, is the sum of the internal storage lengths of the subordinate fields.

Determine the internal storage lengths as follows:


Top of page

Example: Describing a Group Field in VSAM

Consider the following example:

GROUP=A        ALIAS=KEY ,USAGE=A14    ,ACTUAL=A8   ,$
FIELDNAME=F1 ,ALIAS=F1 ,USAGE=P6 ,ACTUAL=P2 ,$
FIELDNAME=F2 ,ALIAS=F2 ,USAGE=I9 ,ACTUAL=I4 ,$
FIELDNAME=F3 ,ALIAS=F3 ,USAGE=A2 ,ACTUAL=A2 ,$

The lengths of the ACTUAL attributes for subordinate fields F1, F2, and F3 total 8, which is the length of the ACTUAL attribute of the group key. The lengths of the USAGE attributes for the subordinate fields total 17. However, the length of the group key USAGE attribute is found by adding their internal storage lengths as specified by their field types: 8 for USAGE=P6, 4 for USAGE=I9, and 2 for USAGE=A2, for a total of 14.

The GROUP declaration USAGE attribute tells FOCUS how many positions to use for the group key. If a Master File does not completely describe the full key at least once, FOCUS returns the following warning message:

(FOC1016) INVALID KEY DESCRIPTION IN MASTER FILE

When you expand on the key in a RECTYPE file, describe the key length in full on the last non-OCCURS segment on each data path. Do not describe a group with ALIAS=KEY for OCCURS segments.

Note: Since all group fields must be defined in alphanumeric format, those that include numeric component fields should not be used as verb objects in a report request.

Using a library example, the first field, PUBNO, could be described as a group key. The publisher's number consists of three elements, a number that identifies the publisher, one that identifies the author, and one that identifies the title. Until now they have been described as a single, ten-digit number made up of these elements. They could have been described as a group key, consisting of a separate field for each element if the file were a VSAM data structure. The FOCUS description of this would look as follows:

FILE=LIBRARY5, SUFFIX=VSAM,$
SEGMENT=ROOT, SEGTYPE=S0,$
GROUP=BOOKKEY ,ALIAS=KEY ,USAGE=A10 ,ACTUAL=A10 ,$
FIELDNAME=PUBNO ,ALIAS=PN ,USAGE=A3 ,ACTUAL=A3 ,$
FIELDNAME=AUTHNO ,ALIAS=AN ,USAGE=A3 ,ACTUAL=A3 ,$
FIELDNAME=TITLNO ,ALIAS=TN ,USAGE=A4 ,ACTUAL=A4 ,$
FIELDNAME=AUTHOR ,ALIAS=AT ,USAGE=A25 ,ACTUAL=A25 ,$
FIELDNAME=TITLE ,ALIAS=TL ,USAGE=A50 ,ACTUAL=A50 ,$
FIELDNAME=BINDING ,ALIAS=BI ,USAGE=A1 ,ACTUAL=A1 ,$
FIELDNAME=PRICE ,ALIAS=PR ,USAGE=D8.2N ,ACTUAL=D8 ,$
FIELDNAME=SERIAL ,ALIAS=SN ,USAGE=A15 ,ACTUAL=A15 ,$
FIELDNAME=SYNOPSIS ,ALIAS=SY ,USAGE=A150 ,ACTUAL=A150 ,$
FIELDNAME=RECTYPE ,ALIAS=B ,USAGE=A1 ,ACTUAL=A1 ,$

When using group fields with multiple formats in queries, you must account for each position, including trailing blanks and leading zeros. The following example illustrates how to access a group field with multiple formats in a query.

GROUP=GRPGB ,ALIAS=KEY ,USAGE=A8 ,ACTUAL=A8 ,$
FIELDNAME=FIELD1 ,ALIAS=F1 ,USAGE=A2 ,ACTUAL=A2 ,$
FIELDNAME=FIELD2 ,ALIAS=F2 ,USAGE=I8 ,ACTUAL=I4 ,$
FIELDNAME=FIELD3 ,ALIAS=F3 ,USAGE=A2 ,ACTUAL=A2 ,$

The values in fields F1 and F3 may include some trailing blanks, and values in field F2 may include leading zeros. When issuing a query for the group, you must account for each position:

IF GRPB EQ 'A 0334BB'

This introduces the possibility of positional errors, but you can eliminate that possibility by using slashes (/) to separate the components of group keys:

IF GRPB EQ 'A/334/BB'

FOCUS assumes blanks and leading zeros as needed to fill out the key.


Information Builders