Copy, convert, and manipulate sequential datasets efficiently
IEBGENER is one of the most commonly used IBM utilities in mainframe JCL. Its primary function is to copy sequential datasets and members of partitioned datasets, optionally performing data conversion during the copy operation. The name "GENER" stands for "General" as it provides general-purpose data manipulation capabilities.
While simple in concept, IEBGENER is incredibly versatile and can handle a wide variety of data manipulation tasks including record format conversion, reblocking, character translation, and more.
IEBGENER provides several key functions for dataset manipulation:
Create an exact copy of a sequential dataset or a PDS member
Change between fixed, variable, and undefined record formats
Change block sizes to optimize I/O performance
Insert new records or remove existing ones
Modify record content using control statements
Convert datasets to printable format
To use IEBGENER, you need to include specific DD statements in your JCL. Each DD statement serves a specific purpose in the utility's operation.
DD Name | Purpose |
---|---|
SYSUT1 | Input dataset to be copied |
SYSUT2 | Output dataset where the copied/converted data will be placed |
SYSIN | Control statements (can be DUMMY if no control statements are needed) |
SYSPRINT | Messages and diagnostics output |
123456//COPY EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=INPUT.DATASET,DISP=SHR //SYSUT2 DD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(10,5),RLSE) //SYSIN DD DUMMY
This simple example copies data from INPUT.DATASET to OUTPUT.DATASET without any modifications.
IEBGENER's most common use is straightforward dataset copying, but it's extremely powerful when you need to convert data characteristics during the copy process.
To copy a dataset without any changes:
123456//COPYSTEP EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=MY.INPUT.DATA,DISP=SHR //SYSUT2 DD DSN=MY.OUTPUT.DATA,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(5,2)) //SYSIN DD DUMMY
To change the record format during copying:
1234567//CONVERT EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=MY.VB.DATASET,DISP=SHR //SYSUT2 DD DSN=MY.FB.DATASET,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(5,2)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //SYSIN DD DUMMY
This example converts a variable-blocked (VB) dataset to fixed-blocked (FB) format.
To change the block size for performance optimization:
1234567//REBLOCK EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=MY.ORIGINAL.DATA,DISP=SHR //SYSUT2 DD DSN=MY.REBLOCKED.DATA,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(5,2)), // DCB=(BLKSIZE=32760) //SYSIN DD DUMMY
This example changes only the block size, optimizing it for better I/O performance.
To create a dataset from in-stream (inline) data:
1234567891011//INSTREAM EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD * This is line 1 of my sample data This is line 2 of my sample data This is line 3 of my sample data /* //SYSUT2 DD DSN=MY.NEW.DATA,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(1,1)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //SYSIN DD DUMMY
For more advanced operations, IEBGENER accepts control statements in the SYSIN dataset. These statements allow you to perform more complex manipulations of your data.
Statement | Purpose |
---|---|
GENERATE | Specifies processing options for the entire operation |
RECORD | Defines record manipulations (field editing, positioning) |
LABELS | Handles label processing for tape datasets |
MEMBER | Used when processing members of partitioned datasets |
The GENERATE statement specifies general processing options:
12345678//CTRLSTMT EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=INPUT.DATASET,DISP=SHR //SYSUT2 DD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(5,2)) //SYSIN DD * GENERATE MAXFLDS=5,MAXLITS=100 /*
This example specifies that up to 5 fields and 100 literals will be used in the operation.
The RECORD statement allows field-level manipulation:
12345678910//EDITRECS EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=INPUT.DATASET,DISP=SHR //SYSUT2 DD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(5,2)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //SYSIN DD * GENERATE MAXFLDS=3 RECORD FIELD=(10,1,1),FIELD=(15,11,50),FIELD=(5,26,'FIXED') /*
This example creates records with three fields: 10 bytes from position 1 of the input, 15 bytes from position 11, and a literal 'FIXED'.
IEBGENER can also be used to add new records to a dataset or modify existing ones.
To add header and footer records to a dataset:
12345678910111213141516171819//ADDRECS EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //HEADER DD * ***** REPORT HEADER ***** /* //CONTENT DD DSN=REPORT.DATA,DISP=SHR //FOOTER DD * ***** END OF REPORT ***** /* //SYSUT1 DD DSN=&&COMBINED,DISP=(NEW,PASS), // UNIT=SYSDA,SPACE=(TRK,(1,1)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) // DD DSN=*.HEADER // DD DSN=*.CONTENT // DD DSN=*.FOOTER //SYSUT2 DD DSN=FINAL.REPORT,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(5,2)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //SYSIN DD DUMMY
This example concatenates header records, content records, and footer records to create a complete report.
To insert records at specific positions using control statements:
1234567891011//INSERT EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=ORIGINAL.DATA,DISP=SHR //SYSUT2 DD DSN=MODIFIED.DATA,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(TRK,(5,2)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //SYSIN DD * GENERATE MAXLITS=80 RECORD IDENT=(8,'SECTION1',1),FIELD=(80,'NEW RECORD FOR SECTION 1') RECORD IDENT=(8,'SECTION2',1),FIELD=(80,'NEW RECORD FOR SECTION 2') /*
This example inserts new records after records that contain 'SECTION1' or 'SECTION2' in the first 8 positions.
Let's look at some common real-world use cases for IEBGENER.
This example formats raw data into a printable report:
12345678910//REPORT EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=SALES.DATA,DISP=SHR //SYSUT2 DD SYSOUT=A, // DCB=(RECFM=FBA,LRECL=133,BLKSIZE=1330) //SYSIN DD * GENERATE MAXFLDS=5,MAXLITS=100 RECORD FIELD=(1,1,10),FIELD=(20,11,'SALES REPORT FOR: '), FIELD=(10,31,20) /*
This creates a formatted report directed to the printer, with custom field placements and headers.
Converting an old variable-length dataset to fixed format for modern applications:
12345678910//CONVERT EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=LEGACY.VB.DATA,DISP=SHR //SYSUT2 DD DSN=MODERN.FB.DATA,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(1,1)), // DCB=(RECFM=FB,LRECL=100,BLKSIZE=27900) //SYSIN DD * GENERATE MAXFLDS=3 RECORD FIELD=(1,1,4,HE),FIELD=(8,5,8),FIELD=(87,13) /*
This example converts data and also rearranges fields to match a new record layout.
Creating a backup copy of a critical dataset:
12345678//BACKUP EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=CRITICAL.MASTER.FILE,DISP=SHR //SYSUT2 DD DSN=CRITICAL.MASTER.BACKUP.D&&YYMMDD, // DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(10,5),RLSE), // DCB=(*.SYSUT1) //SYSIN DD DUMMY
This example creates a date-stamped backup, using the DCB attributes of the input dataset.
While IEBGENER is a straightforward utility, there are several best practices to follow and common mistakes to avoid.
While IEBGENER is versatile, there are cases where other utilities might be more appropriate:
Scenario | Recommended Utility |
---|---|
Copying VSAM datasets | IDCAMS REPRO |
Complex data manipulations | DFSORT, ICETOOL |
Copying partitioned datasets | IEBCOPY |
Sophisticated report formatting | Custom programs, DFSORT ICETOOL |
1. What is the primary purpose of the IEBGENER utility?
2. Which DD statement is used for input in IEBGENER?
3. Which DD statement is used for output in IEBGENER?
4. What statement would you use to change record format during a copy operation in IEBGENER?
5. Which of these is NOT a valid function of IEBGENER?
6. When copying a dataset with IEBGENER, how would you specify the block size for the output dataset?