IEBGENER Program

IEBGENER utility program uses are

  • To copy sequential datasets
  • To reformat records while copying
  • To specify conditions while copying
  • To re-block copied records
  • To concatenate datasets
  • To write instream data into a dataset

To copy using IEBGENER

This utility program is used to copy sequential datasets for backup purpose and expanding the space allocation for existing datasets. 

//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN= Input
//SYSUT2 DD DSN= output
//SYSIN DD DUMMY
//

Input and output dataset can be a PS or a member of PDS.

There are control statements that are used along with the desired function

Statement Use
GENERATE Indicates the number of member names and alias names, record identifiers, literals, and editing information contained in the control data set.
RECORD Defines a record group to be processed and supplies editing information.
LABELS Specifies user-label processing.
EXITS Indicates that user routines are provided.
MEMBER Specifies the member name and alias of a member of a partitioned data set or PDSE to be created.


GENERATE Statement

GENERATE control card can be used while copying and reformatting data during copying. It is required when output is to be partitioned or editing is to be performed or user routines are provided or label processing is specified. Lets look at an example where copying an input sequential dataset to many members of a PDS

//PROGPUBA JOB NOTIFY=PROGPUB
//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=input
//SYSUT2 DD DSN=output
//SYSIN DD *
<strong>  Generate Maxname</strong>=3 -> To create 3 members in the output
<strong>  Member name</strong>=(mem1,mem2,mem3) -> (mem1,mem2,mem3 will have the contents of sysut1
/*

If you take a close look at the GENERATE statement, it has a parameter called Maxname. These are the following parameters that can be used with GENERATE statement

  • MAXNAME
  • MAXFLDS
  • MAXGPS
  • MAXLITS
  • DBCS

MAXNAME

specifies a number, from 1 to 3276, that is greater than or equal to the total number of member names and aliases appearing in subsequent MEMBER statements. MAXNAME is required if there are one or more MEMBER statements.

MAXFLDS

Specifies a number, from 1 to 4095, that is greater than or equal to the total number of FIELD parameters appearing in subsequent RECORD statements. MAXFLDS is required if there are any FIELD parameters in subsequent RECORD statements.

While reformatting, you can select data-bytes to be output. For example, to output only the Empnum and Salary data-bytes, in the order of Salary and Empnum

//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=INPUT DSN
//SYSUT2 DD DSN=OUTPUT DSN
//SYSIN DD *
   Generate <strong>Maxflds</strong>=2
   Record field=(5,1,CH,6)
   field=(5,46,CH,1)
         (Length,Location in input,Format,Location in the output)

MAXGPS

Specifies a number, from 1 to 2520, that is greater than or equal to the total number of IDENT or IDENTG parameters appearing in subsequent RECORD statements. MAXGPS is required if there are any IDENT or IDENTG parameters in subsequent RECORD statements.

To select rows of records based on some criteria, say, employees getting a salary of 1000, code Maxgps and Record Ident (similar to Include / Omit Cond of Sort utility)

//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=INPUT DSN
//SYSUT2 DD DSN=OUTPUT DSN
//SYSIN DD *
  Generate Maxgps=1
  Record Ident=(5,’01000’,46)
  (length,,start-byte)

MAXLITS

Specifies a number, from 1 to 2730, that is greater than or equal to the total number of characters contained in the FIELD literals of subsequent RECORD statements. Any DBCS characters used as literals on FIELD parameters count as two characters each.
MAXLITS is required if the FIELD parameters of subsequent RECORD statements contain literals. MAXLITS does not apply to literals used in IDENT or IDENTG parameters.For example, to have some character-literals in the output, say, two asteriks between Salary and Empnum fields (similar to ‘X’ in the Sort utility), code Maxlits:


//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=INPUT DSN
//SYSUT2 DD DSN=OUTPUT DSN
//SYSIN DD *
   Generate Maxflds=2,<strong>Maxlits</strong>=2
   Record field=(5,1,CH,8)
          field=(5,46,CH,1)
                (Length,Location in input,Format,Location in the output)
          field=(2,’**’,,6)

DBCS={YES|NO}

Specifies if the input data set contains double-byte character set data.

RECORD Statement

Record statement can be used when you want to modify a particular member while copying to PDS members. For example,

//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=INPUT DSN
//SYSUT2 DD DSN=OUTPUT DSN
//SYSIN DD *
   Generate Maxname=3,Maxflds=2
   Member name=mem2
<strong>   Record field</strong>=(5,1,ch,8)
          field=(5,46,ch,1)
          field=(2,’**’,,6)
   Member name=(mem1,mem3)

MEMBER Statement

The MEMBER statement is used when the output data set is to be partitioned. One MEMBER statement must be included for each member to be created by IEBGENER.

//PROGPUBA JOB NOTIFY=PROGPUB
//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=INPUT DSN
//SYSUT2 DD DSN=OUTPUT DSN
//SYSIN DD *
<strong>  Generate Maxname</strong>=3 -> To create 3 members in the output
<strong>  Member name</strong>=(mem1,mem2,mem3) -> (mem1,mem2,mem3 will have the contents of sysut1
/*

EXITS Statement

The EXITS statement is used to identify exit routines you want IEBGENER to use

//PROGPUBA JOB NOTIFY=PROGPUB
//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=INPUT DSN
//SYSUT2 DD DSN=OUTPUT DSN
//SYSIN DD *
<strong>  Generate Maxname</strong>=3
<strong>  EXITS INHDR=ROUTINE1, INTLR=ROUTINE2</strong>
/*

INHDR
specifies the name of the routine that processes user input header labels.

OUTHDR
specifies the name of the routine that creates user output header labels. OUTHDR is ignored if the output data set is partitioned.

INTLR=routinename
specifies the name of the routine that processes user input trailer labels.

OUTTLR=routinename
specifies the name of the routine that processes user output trailer labels. OUTTLR is ignored if the output data set is partitioned.

KEY=routinename
specifies the name of the routine that creates the output record key. This routine does not receive control when a data set consisting of variable spanned (VS) or variable blocked spanned (VBS) type records is processed because no processing of keys is permitted for this type of data.

DATA=routinename
specifies the name of the routine that modifies the physical record (logical record for variable blocked type records) before it is processed by IEBGENER.

IOERROR=routinename
specifies the name of the routine that handles permanent input/output error conditions.

TOTAL=(routinename,size)
specifies that a user exit routine is to be provided before writing each record. The keyword OPTCD=T must be specified for the SYSUT2 DD statement. TOTAL is valid only when IEBGENER is used to process sequential data sets.

These values must be coded:
routinename - specifies the name of your totaling routine.
size - specifies the number of bytes needed to contain totals, counters, pointers, and so forth. Size should be coded as a whole decimal number.

LABELS Statement

The LABELS statement specifies if user labels are to be treated as data by IEBGENER. The parameters used with the LABELS statements are

YES
specifies that any user labels that are not rejected by a label processing routine you have specified on the EXITS statement are to be treated as data. Processing of labels as data ends in compliance with standard return codes. YES is the default.

NO
specifies that user labels are not to be treated as data. In order to make standard user label (SUL) exits inactive, NO must be specified when processing input/output data sets with nonstandard labels (NSL).

ALL
specifies that all user labels in the group currently being processed are to be treated as data. A return code of 16 causes IEBGENER to complete processing the remainder of the group of user labels and to stop the job step.

ONLY
specifies that only user header labels are to be treated as data. User header labels are processed as data regardless of any return code. The job ends upon return from the OPEN routine.

INPUT
specifies that user labels for the output data set are supplied as 80-byte input records in the data portion of SYSIN. The number of input records that should be treated as user labels must be identified by a RECORD statement.

LABELS DATA=NO must be specified to make standard user labels (SUL) exits inactive when input/output data sets with nonstandard labels (NSL) are to be processed.

To Re-block records (ALTER BLKSIZE)

Re-blocking can involve altering the BLKSIZE sub-parameter of the DCB in the output and altering the logical record length LRECL.
For example to alter LRECL in the output

//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=INPUT DSN
//SYSUT2 DD DSN=OUTPUT DSN, …….
DCB=(LRECL=100,……..,BLKSIZE=10000)
//SYSIN DD *
Generate Maxflds=1
Record field=(80,1,CH,1)
 /*

To concatenate datasets

To concatenate datasets using IEBGENER add the unsorted datasets in SYSUT1 parameter like shown in the example

//PROGPUBA JOB NOTIFY=PROGPUB
//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=
//       DD DSN=
//SYSUT2 DD DSN=
//SYSIN DD DUMMY
//

To write in-stream data

To write in-stream data into a dataset, put the instream data after SYSUT1 DD * like shown in the example

//PROGPUBA JOB NOTIFY=PROGPUB
//STEP010 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD *
  
/*
//SYSUT2 DD DSN=OUTPUT DSN
//SYSIN DD DUMMY
//