USE GROUP directive

Generally, only elementary data items correspond to columns. The USE GROUP directive indicates that the following group item is to correspond to a column as if it were an elementary item of the same width. This is necessary if the item is stored in your database as a group, rather than as individual fields.

By default, the USE GROUP directive implies that the consolidated field is alphanumeric. If you want a numeric field, add the word NUMERIC at the end of the directive.

Grouping data items in this way is efficient if the groups are usually processed as units.





You might use this directive with fields like multi-part account numbers or department numbers, or keys that are referenced as a unit but not by their individual pieces. In the sample file, you can group the year and seq_no fields to make a single account number column (acct_no), as shown below:

       FD  jr-file.
      $XFD COMMENT  This sample file demonstrates directives.
       01  jr-record.
           03  animal-info.
               05  patient-id                  pic x(5).
               05  atype                       pic x.
               05  ctype redefines atype       pic x.
               05  dtype redefines atype       pic x.
               05  otype redefines atype       pic x.
           03  owner-info.
               05  phone                       pic x(8).
               05  owner                       pic x(30). 
           03  financial.
               05  acct_no.
                   10  year                    pic x(2).
                   10  seq_no                  pic x(4).
               05  last_visit.
                   10  yyyy                    pic 9(4).
                   10  mm                      pic 9(2).
                   10  dd                      pic 9(2).
               05  fee                         pic s9(5)v99.

The resulting table looks similar to this:

If you are using an existing database in which certain fields are grouped, they must also be grouped in your COBOL FD.

Why group fields?

If the database does not yet exist, keep in mind that combining fields into groups typically improves execution speed. Whether to group fields or not also depends on how you want to process them. Do you always store and use the fields together? Someone who really knows how the data is being used might help to identify groups of fields that can be combined to speed processing.

Once you have grouped fields, you can apply other directives to them, such as DATE, NUMERIC, and ALPHA.