Generation data groups

A generation data group (GDG) is a chronological collection of related files. GDGs simplify the processing of multiple versions of related data.

Each file within a GDG is called a generation data set (GDS) or generation. (In this information, generation data sets are referred to as generation files. The term file on the workstation is equivalent to the term data set on the host.)

Within a GDG, the generations can have like or unlike attributes including ORGANIZATION, record format, and record length. If all generations in a group have consistent attributes and sequential organization, you can retrieve the generations together as a single file.

There are advantages to grouping related files. For example:
  • The files in the group can be referred to by a common name.
  • The files in the group are kept in generation order.
  • The outdated files can be automatically discarded.

The generations within a GDG have sequentially ordered relative and absolute names that represent their age.

The relative name of a generation file is the group name followed by an integer in parentheses. For example, if the name of a group is hlq.PAY:
  • hlq.PAY(0) refers to the most current generation.
  • hlq.PAY(-1) refers to the previous generation.
  • hlq.PAY(+1) specifies a new generation to be added.
The absolute name of a generation file contains the generation number and version number. For example, if the name of a group is hlq.PAY:
  • hlq.PAY.g0005v00 refers to generation file 5, version 0.
  • hlq.PAY.g0006v00 refers to generation file 6, version 0.

For more information about forming absolute and relative names, see the Related tasks.

Generation order is typically but not necessarily the same as the order in which files were added to a group. Depending on how you add generation files using absolute and relative names, you might insert a generation into an unexpected position in a group. For details, see the related reference about insertion and wrapping of generation files.

GDGs are supported in all of the COBOL for Linux® file systems.

Restriction: A GDG cannot contain either an SFS indexed file that has any alternate indexes, or an SdU indexed file that requires a list of alternate indexes in the file name. The restriction is due to the ambiguity between the syntax of a parenthesized alternate index list and the syntax of GDG relative names, which also require a parenthesized expression.

For information about creating and initializing generation data groups, see the appropriate related task.

To delete, rebuild, clean up, modify, or list generation groups, or add or delete generations within a group, use the gdgmgr utility. To see a summary of gdgmgr functions, issue the following command: gdgmgr -h. For further details about the gdgmgr utility, see its man page via the following command: gdgmgr -man.

Use case

A GDG can be used to store and combine data to produce an aggregate daily, monthly, quarterly, or yearly reporting application. The below list defines each frequency:
  • A maximum of 7 days a week
  • A maximum of 31 days in a month
  • A maximum of 3 months in a quarter
  • A maximum of 4 quarters in a year
You keep writing daily reports automatically, but only keep the 7 most recent reports. The COBOL program opens a file named daily.reports(+1); the runtime will generate a unique name for the new file, and do any cleanup necessary to ensure older generations are properly aged out. If you are summarizing a yearly report instead, the COBOL program opens a file named quarterly.reports(*) to signify that it wants all the data and in sequential order.

Example

Follow these steps to create different versions of GDG:
  1. Export the filesystem name.
  2. Compile and link your program as usual. To learn more, see Compiling, linking, and running programs.
  3. Create a GDG base gdg_test and list the contents using this command: gdgmgr -e -s -L 2 -c gdg_test -l.
    The output is as follows:
    GDG: gdg_test 
      Catalogue   = ./gdg_test.catalogue
      Limit       = 2
      Days        = 0
      NoEmpty
      Scratch
      Entries     = 0
    
  4. Execute the program.
  5. Create different GDG versions and list the contents using this command: gdgmgr -l gdg_test.
The source file is as follows:
cbl compile,pgmname(mixed) 
ID DIVISION.
PROGRAM-ID. 'ins_gdg'.
 
ENVIRONMENT DIVISION.
INPUT-OUTPUT Section.
 
FILE-CONTROL.
    SELECT GDS_File
       ASSIGN using gds_filename
       ORGANIZATION is sequential.
 
DATA DIVISION.
 
FILE SECTION.
FD GDS_File
    Record contains 80 characters
    RECORDING MODE is F.
01 GDS_File-record pic x(80).
 
Working-Storage Section.
01 record-in            pic x(80) value spaces.
01 record-out           pic x(80) value spaces.
01 gds_filename         pic x(64) value spaces.
 
Linkage Section.
 
Procedure Division.
    move 0 to return-code.
 
    display "     Start ..."
 
    move 'gdg_test.g0001v00' to gds_filename.
    move '   Initial GDS 0001    [gdg_test.g0001v00]'
         to record-out.
    open output GDS_File
    write GDS_File-record from record-out
    close GDS_File
    move 'gdg_test(+1)' to gds_filename. 
    move '   Increment of +1 (1) [gdg_test.g0002v00]'
         to record-out.
    open output GDS_File
    write GDS_File-record from record-out
    close GDS_File
 
    move 'gdg_test(+1)' to gds_filename.
    move '   Increment of +1 (2) [gdg_test.g0003v00]'
         to record-out.
    open output GDS_File
    write GDS_File-record from record-out
    close GDS_File
    display "     End   ..."
 
    goback.
 
END PROGRAM 'ins_gdg'.