In this section: |
A group provides a convenient alternate name for one or more contiguous fields. The group redefines a sequence of fields and does not require any storage of its own.
Group fields enable you to:
How to: |
Reference: |
The component fields can contain alphanumeric or numeric data. However, the group field should always have an alphanumeric format. The length of the group field must be the sum of the actual lengths of the component fields. For example, integer fields always have an actual length of four bytes, regardless of the USAGE format that determines how many characters appear on a report.
GROUP=groupname, [ALIAS=groupalias,] USAGE=An, [FIELDTYPE=I,] $ FIELDNAME=field1, ALIAS=alias1, USAGE=fmt1,$ FIELDNAME=field2, ALIAS=alias2, USAGE=fmt2,$ . . . FIELDNAME=fieldn, ALIAS=aliasn, USAGE=fmtn,$
where:
Is the name of the group.
Is an optional alias name for the group.
Is the format for the group field. Its length is the sum of the internal lengths of the component fields:
Describing the group field with a format other than A does not generate an error message. However, it is not recommended and may produce unpredictable results.
Are the component fields in the group.
Are the alias names for the component fields in the group.
Are the USAGE formats of the component fields in the group.
Creates a separate index for the group.
Note that using slashes makes it easier to specify values when the component fields contain trailing blanks, because you do not have to account for those blanks.
The only masks supported in screening criteria for group fields are those that accept any combination of characters for all group components after the first component. For example, if the FULL_NAME group consists of LAST_NAME and FIRST_NAME, the following mask is supported:
WHERE FULL_NAME EQ '$R$$$$*'
(FOC439) WARNING. A MATCH CONDITION HAS BEEN ASSUMED FOR:
GROUP = ..., ,$ FIELDNAME = FIELDG1, ... ,$ FIELDNAME = FIELDG2, ... ,$ FIELDNAME = FIELD3, ... ,$
In the following group field definition, the group length is 25, the sum of the lengths of the LAST_NAME and FIRST_NAME fields:
FILENAME=EMPLOYEE, SUFFIX=FOC SEGNAME=EMPINFO, SEGTYPE=S1 FIELDNAME=EMP_ID, ALIAS=EID, FORMAT=A9, $ GROUP=FULL_NAME, , FORMAT=A25, $ FIELDNAME=LAST_NAME, ALIAS=LN, FORMAT=A15, $ FIELDNAME=FIRST_NAME, ALIAS=FN, FORMAT=A10, $
The WHERE test on the group field does not need slashes between the component values, because both component fields are alphanumeric:
TABLE FILE EMPLOYEE PRINT EMP_ID HIRE_DATE BY FULL_NAME WHERE FULL_NAME GT 'CROSSBARBARA' END
The output is:
FULL_NAME EMP_ID HIRE_DATE --------- ------ --------- GREENSPAN MARY 543729165 82/04/01 IRVING JOAN 123764317 82/01/04 JONES DIANE 117593129 82/05/01 MCCOY JOHN 219984371 81/07/01 MCKNIGHT ROGER 451123478 82/02/02 ROMANS ANTHONY 126724188 82/07/01 SMITH MARY 112847612 81/07/01 SMITH RICHARD 119265415 82/01/04 STEVENS ALFRED 071382660 80/06/02
In the following group field definition, the group length is 29, the sum of the lengths of the LAST_NAME, FIRST_NAME, and HIRE_DATE fields. Because HIRE_DATE is an integer field, its internal length is 4:
FILENAME=EMPLOYEE, SUFFIX=FOC SEGNAME=EMPINFO, SEGTYPE=S1 FIELDNAME=EMP_ID, ALIAS=EID, FORMAT=A9, $ GROUP=FULL_NAME, , FORMAT=A29, $ FIELDNAME=LAST_NAME, ALIAS=LN, FORMAT=A15, $ FIELDNAME=FIRST_NAME, ALIAS=FN, FORMAT=A10, $ FIELDNAME=HIRE_DATE, ALIAS=HDT, FORMAT=I6YMD, $
In the following request, the component field values must be separated by slashes in the WHERE test. The request does not display the group field, because the integer component would not appear correctly:
TABLE FILE EMPGROUP PRINT EMP_ID LAST_NAME FIRST_NAME HIRE_DATE BY FULL_NAME NOPRINT WHERE FULL_NAME GT 'CROSS/BARBARA/811102' END
The output is:
EMP_ID LAST_NAME FIRST_NAME HIRE_DATE ------ --------- ---------- --------- 543729165 GREENSPAN MARY 82/04/01 123764317 IRVING JOAN 82/01/04 117593129 JONES DIANE 82/05/01 219984371 MCCOY JOHN 81/07/01 451123478 MCKNIGHT ROGER 82/02/02 126724188 ROMANS ANTHONY 82/07/01 112847612 SMITH MARY 81/07/01 119265415 SMITH RICHARD 82/01/04 071382660 STEVENS ALFRED 80/06/02
How to: |
Reference: |
A GROUP declaration in a Master File describes several fields as a single entity. One use of a group is to describe Group keys in a VSAM data source. Sometimes referring to several fields by one group name facilitates ease of reporting.
Traditionally, when describing a GROUP field, you had to take account of the fact that while the USAGE and ACTUAL format for the GROUP field are both alphanumeric, the length portion of the USAGE format for the group had to be calculated as the sum of the component lengths, where each integer or single precision field counted as 4 bytes, each double precision field as 8 bytes, and each packed field counted as either 8 or 16 bytes depending on its size.
To avoid the need to calculate these lengths, you can use the GROUP ELEMENTS option, which describes a group as a set of elements without USAGE and ACTUAL formats.
GROUP=group1, ALIAS=g1alias,ELEMENTS=n1,$ FIELDNAME=field11, ALIAS=alias11, USAGE=ufmt11, ACTUAL=afmt11, $ . . . FIELDNAME=field1h, ALIAS=alias1h, USAGE=ufmt1h, ACTUAL=afmt1h, $ GROUP=group2,ALIAS=g2alias,ELEMENTS=n2,$ FIELDNAME=field21, ALIAS=alias21, USAGE=ufmt21, ACTUAL=afmt21, $ . . . FIELDNAME=field2k, ALIAS=alias2k, USAGE=ufmt2k, ACTUAL=afmt2k, $
where:
Are valid names assigned to a group of fields. The rules for acceptable group names are the same as the rules for acceptable field names.
Are the number of elements (fields and/or groups) that compose the group. If a group is defined within another group, the subgroup (with all of its elements) counts as one element of the parent group.
Are valid field names.
Are valid alias names.
Are USAGE formats for each field.
Are ACTUAL formats for each field.
In the following Master File, GRP2 consists of two elements, fields FIELDA and FIELDB. GRP1 consists of two elements, GRP2 and field FIELDC. Field FIELDD is not part of a group:
FILENAME=XYZ , SUFFIX=FIX , $ SEGMENT=XYZ, SEGTYPE=S2, $ GROUP=GRP1,ALIAS=CCR,ELEMENTS=2,$ GROUP=GRP2,ALIAS=CC,ELEMENTS=2,$ FIELDNAME=FIELDA, ALIAS=E01, USAGE=A10, ACTUAL=A10, $ FIELDNAME=FIELDB, ALIAS=E02, USAGE=A16, ACTUAL=A16, $ FIELDNAME=FIELDC, ALIAS=E03, USAGE=P27, ACTUAL=A07, $ FIELDNAME=FIELDD, ALIAS=E04, USAGE=D7, ACTUAL=A07, $
The following chart shows the offsets and formats of these fields.
|