GROUP Attribute

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:

Describing a Group Field With Formats

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.

Syntax: How to Define a Group Field With Formats

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:

groupname

Is the name of the group.

groupalias

Is an optional alias name for the group.

An

Is the format for the group field. Its length is the sum of the internal lengths of the component fields:

  • Fields of type I have an internal length of 4.
  • Fields of type F have an internal length of 4.
  • Fields of type P that have a USAGE format of P15 or P16 or smaller have an internal length of 8, and fields of type P that have a USAGE format of P17 or greater have an internal length of 16.
  • Fields of type D have an internal length of 8.
  • Fields of type A have an internal length equal to the number of characters (n) in their USAGE formats.

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.

field1, ..., fieldn

Are the component fields in the group.

alias1, ..., aliasn

Are the alias names for the component fields in the group.

fmt1, ..., fmtn

Are the USAGE formats of the component fields in the group.

FIELDTYPE=I

Creates a separate index for the group.

Reference: Usage Notes for Group Fields in FOCUS Data Sources

  • When at least one component of the group has a numeric or date format, the group field does not appear correctly. However, the value of the group field is correct, and the individual fields appear correctly. Use this type of group in a TABLE request for indexed retrieval on more than one component field or to join to more than one component field.
  • You can add or remove a non-key group field definition in a Master File at any time without impact. If the group field is indexed and you MODIFY the data source without the group field definition in the Master File, you must rebuild the index when you add the group field back to the Master File.
  • The MISSING attribute is not supported on a group field.
  • To use a group field that contains a numeric component in screening criteria, separate the component values with slashes. However, if the value of one the group components contains a slash '/', the slash may not be used as a delimiter and no test can be issued against this value.

    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$$$$*'
  • To use a group field that contains only alphanumeric components in screening criteria, separating the component values with a slash is optional.
  • A group format supports date display options.
  • In MODIFY, you can match on the group field when it is the first field in the segment (S1). A MATCH on a component field in the group without matching on the group generates the following:
    (FOC439) WARNING. A MATCH CONDITION HAS BEEN ASSUMED FOR:
  • If the group has an index, and the group components are also indexes, you can MATCH on the group level with no need to match on the group components.
  • Although MODIFY enables you to update group components even if they are key fields, this is not recommended. Instead, use SCAN or FSCAN to update key fields.
  • If both a group and the field following it are part of a key, the number specified for the SEGTYPE attribute must include the group field plus its component fields, plus the field following the group. For example, if the group key has two components and is followed by another field that is also part of the key, the SEGTYPE must be S4:
    GROUP = ...,               ,$
      FIELDNAME = FIELDG1, ... ,$
      FIELDNAME = FIELDG2, ... ,$
      FIELDNAME = FIELD3, ...  ,$

Example: Displaying an Alphanumeric Group Field

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

Example: Screening on a Group Field With an Integer Component

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

Describing a Group Field as a Set of Elements

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.

Syntax: How to Describe a GROUP Field as a Set of Elements

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:

group1, group2

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.

n1, n2

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.

field11, field2k

Are valid field names.

alias11, alias2k

Are valid alias names.

ufmt11, ufmt2k

Are USAGE formats for each field.

afmt11, afmt2k

Are ACTUAL formats for each field.

Reference: Usage Notes for Group Elements

  • To use the ELEMENTS attribute, the GROUP field declaration should specify only a group name and number of elements.
    • If a group declaration specifies USAGE and ACTUAL without the ELEMENTS attribute, the USAGE and ACTUAL are accepted as specified, even if incorrect.
    • If a group declaration specifies USAGE and ACTUAL with the ELEMENTS attribute, the ELEMENTS attribute takes precedence.
  • Each subgroup counts as one element. Its individual fields and subgroups do not count in the number of elements of the parent group.

Example: Declaring a GROUP With ELEMENTS

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.

Field Number

Field Name

Offset

USAGE

ACTUAL

1

GRP1

0

A42 - Supports 16 characters for FIELDC (P27)

A33

2

GRP2

0

A26

A26

3

FIELDA

0

A10

A10

4

FIELDB

10

A16

A16

5

FIELDC

26

P27

A7

6

FIELDD

42

D7

A7