MainframeMaster

JCL Tutorial

IEBGENER Utility

Copy, convert, and manipulate sequential datasets efficiently

Progress0 of 0 lessons

Introduction to IEBGENER

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.

Purpose and Function

IEBGENER provides several key functions for dataset manipulation:

Copy Datasets

Create an exact copy of a sequential dataset or a PDS member

Convert Record Formats

Change between fixed, variable, and undefined record formats

Reblock Records

Change block sizes to optimize I/O performance

Add or Remove Records

Insert new records or remove existing ones

Edit Records

Modify record content using control statements

Print Datasets

Convert datasets to printable format

Common Use Cases:

  • Copying data from one dataset to another
  • Converting legacy data formats to modern formats
  • Creating printable reports from raw data
  • Moving data between different storage devices
  • Generating test data from templates

IEBGENER JCL Requirements

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.

Required DD Statements

DD NamePurpose
SYSUT1Input dataset to be copied
SYSUT2Output dataset where the copied/converted data will be placed
SYSINControl statements (can be DUMMY if no control statements are needed)
SYSPRINTMessages and diagnostics output

Basic IEBGENER JCL Example

jcl
1
2
3
4
5
6
//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.

Copying and Converting Datasets

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.

Simple Dataset Copy

To copy a dataset without any changes:

jcl
1
2
3
4
5
6
//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

Converting Record Format

To change the record format during copying:

jcl
1
2
3
4
5
6
7
//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.

Reblocking a Dataset

To change the block size for performance optimization:

jcl
1
2
3
4
5
6
7
//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.

Copying In-stream Data

To create a dataset from in-stream (inline) data:

jcl
1
2
3
4
5
6
7
8
9
10
11
//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

Control Statements

For more advanced operations, IEBGENER accepts control statements in the SYSIN dataset. These statements allow you to perform more complex manipulations of your data.

Main Control Statements

StatementPurpose
GENERATESpecifies processing options for the entire operation
RECORDDefines record manipulations (field editing, positioning)
LABELSHandles label processing for tape datasets
MEMBERUsed when processing members of partitioned datasets

Using the GENERATE Statement

The GENERATE statement specifies general processing options:

jcl
1
2
3
4
5
6
7
8
//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.

Record Manipulation with the RECORD Statement

The RECORD statement allows field-level manipulation:

jcl
1
2
3
4
5
6
7
8
9
10
//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'.

Control Statement Format Tips:

  • Control statements must start in column 2 or beyond
  • Statements can be continued by ending a line with a comma and continuing on the next line
  • Comment statements can be included by placing an asterisk (*) in column 1
  • IEBGENER is sensitive to statement syntax - check documentation for exact formats

Adding or Modifying Records

IEBGENER can also be used to add new records to a dataset or modify existing ones.

Adding a Header and Footer

To add header and footer records to a dataset:

jcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//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.

Inserting Records at Specific Positions

To insert records at specific positions using control statements:

jcl
1
2
3
4
5
6
7
8
9
10
11
//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.

Practical Examples

Let's look at some common real-world use cases for IEBGENER.

Example 1: Creating a Report from Raw Data

This example formats raw data into a printable report:

jcl
1
2
3
4
5
6
7
8
9
10
//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.

Example 2: Converting Legacy Data Format

Converting an old variable-length dataset to fixed format for modern applications:

jcl
1
2
3
4
5
6
7
8
9
10
//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.

Example 3: Simple Backup Copy

Creating a backup copy of a critical dataset:

jcl
1
2
3
4
5
6
7
8
//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.

Best Practices and Common Mistakes

While IEBGENER is a straightforward utility, there are several best practices to follow and common mistakes to avoid.

Best Practices

  • Use DCB=(*.SYSUT1) to preserve input dataset characteristics when appropriate
  • Specify sufficient space for the output dataset
  • Use DUMMY for SYSIN when no control statements are needed
  • Always check return codes in production jobs
  • Consider using more modern utilities like DFSORT for complex operations

Common Mistakes

  • Not providing enough space for the output dataset
  • Forgetting to specify DCB parameters when needed
  • Using incorrect control statement syntax
  • Trying to use IEBGENER for complex manipulations better suited to other utilities
  • Not checking for truncation when converting between record formats

When to Use Alternatives

While IEBGENER is versatile, there are cases where other utilities might be more appropriate:

ScenarioRecommended Utility
Copying VSAM datasetsIDCAMS REPRO
Complex data manipulationsDFSORT, ICETOOL
Copying partitioned datasetsIEBCOPY
Sophisticated report formattingCustom programs, DFSORT ICETOOL

Common Questions and Issues

Test Your Knowledge

1. What is the primary purpose of the IEBGENER utility?

  • To sort datasets
  • To copy and convert datasets
  • To compress partitioned datasets
  • To catalog datasets

2. Which DD statement is used for input in IEBGENER?

  • SYSUT1
  • SYSIN
  • INPUT
  • SORTIN

3. Which DD statement is used for output in IEBGENER?

  • SYSUT2
  • SYSOUT
  • OUTPUT
  • SORTOUT

4. What statement would you use to change record format during a copy operation in IEBGENER?

  • RECFM=FB
  • DCB=(RECFM=FB,...)
  • CONVERT=FB
  • FORMAT=FB

5. Which of these is NOT a valid function of IEBGENER?

  • Copy sequential dataset
  • Convert record formats
  • Reblock records
  • Index a VSAM dataset

6. When copying a dataset with IEBGENER, how would you specify the block size for the output dataset?

  • BLKSIZE=32760
  • DCB=(BLKSIZE=32760)
  • BLOCK=32760
  • SIZE=32760