MainframeMaster

JCL Tutorial

IEBCOPY Utility

Copy, merge, and manage partitioned datasets efficiently

Progress0 of 0 lessons

Introduction to IEBCOPY

IEBCOPY is an IBM utility specifically designed for working with partitioned datasets (PDS and PDSE). While IEBGENER handles sequential datasets effectively, IEBCOPY is the go-to utility for operations involving libraries and their members. It provides powerful capabilities for copying, merging, compressing, and managing members within partitioned datasets.

This utility is commonly used for maintaining program libraries, copying selected members between libraries, creating backups of partitioned datasets, and optimizing library space through compression.

Purpose and Function

IEBCOPY provides several key capabilities for managing partitioned datasets:

Copy Entire PDSs

Transfer all members from one partitioned dataset to another

Select Specific Members

Copy only specific members from a source PDS

Merge Libraries

Combine members from multiple input libraries into one output library

Compress PDSs

Eliminate wasted space within a partitioned dataset

Exclude Members

Exclude specific members from the copy operation

Load Module Management

Special handling for executable program libraries

Common Use Cases:

  • Maintaining program libraries (load modules)
  • Creating backups of critical partitioned datasets
  • Migrating selected members to a new library
  • Consolidating scattered members into a single library
  • Recovering space in datasets with many deleted members
  • Creating subsets of large libraries for specific applications

IEBCOPY JCL Requirements

To use IEBCOPY, you need to include specific DD statements in your JCL. The configuration varies slightly depending on whether you're performing a library-to-library copy or a compress operation.

Required DD Statements for Copy Operations

DD NamePurpose
SYSUT1Input partitioned dataset (when no INDD is specified in control statements)
SYSUT2Output partitioned dataset (when no OUTDD is specified in control statements)
anyname1, anyname2, ...Additional input or output datasets referenced by INDD or OUTDD in control statements
SYSINControl statements (can be DUMMY for a simple full copy from SYSUT1 to SYSUT2)
SYSPRINTMessages and diagnostics output

Required DD Statements for Compress Operations

DD NamePurpose
SYSUT1Partitioned dataset to be compressed (also used as output)
SYSINControl statements with COMPRESS command
SYSPRINTMessages and diagnostics output
SYSUT3Work dataset (required for compress operations)
SYSUT4Work dataset (required for compress operations)

Basic IEBCOPY JCL Example

jcl
1
2
3
4
5
//COPY EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=MY.SOURCE.PDS,DISP=SHR //SYSUT2 DD DSN=MY.TARGET.PDS,DISP=SHR //SYSIN DD DUMMY

This simple example copies all members from MY.SOURCE.PDS to MY.TARGET.PDS without any control statements.

Control Statements

IEBCOPY control statements specify the operations to be performed. These statements are provided in the SYSIN dataset and allow you to perform complex operations beyond simple full copies.

Main Control Statements

StatementPurpose
COPYCopies members from input dataset(s) to output dataset
SELECTSpecifies which members to include in the copy operation
EXCLUDESpecifies which members to exclude from the copy operation
INDDSpecifies the DDname of input dataset(s)
OUTDDSpecifies the DDname of the output dataset
COMPRESSCompresses a partitioned dataset in place

Basic COPY Statement

The COPY statement is the primary control statement in IEBCOPY. It specifies what is to be copied and to where:

jcl
1
COPY INDD=INPDS,OUTDD=OUTPDS

This copies all members from the dataset defined by DDname INPDS to the dataset defined by DDname OUTPDS.

Using SELECT with COPY

To copy only specific members:

jcl
1
2
COPY INDD=INPDS,OUTDD=OUTPDS SELECT MEMBER=(MEMBER1,MEMBER2,MEMBER3)

This copies only MEMBER1, MEMBER2, and MEMBER3 from INPDS to OUTPDS.

Using EXCLUDE with COPY

To copy all members except specific ones:

jcl
1
2
COPY INDD=INPDS,OUTDD=OUTPDS EXCLUDE MEMBER=(MEMBER1,MEMBER2)

This copies all members from INPDS to OUTPDS except MEMBER1 and MEMBER2.

Using Wildcards in SELECT

To copy members matching a pattern:

jcl
1
2
COPY INDD=INPDS,OUTDD=OUTPDS SELECT MEMBER=(PAY*,GL*)

This copies all members whose names start with "PAY" or "GL".

COMPRESS Statement

To compress a PDS in place:

jcl
1
COPY INDD=SYSUT1,OUTDD=SYSUT1

This compresses the dataset defined by SYSUT1. Note that both INDD and OUTDD point to the same dataset.

Control Statement Rules:

  • Control statements must begin in column 2 or beyond
  • Continuation is indicated by a non-blank character in column 72, with the continuation starting in column 16 of the next line
  • Multiple COPY statements can be used in a single IEBCOPY job
  • Each COPY statement can operate on different input and output datasets
  • SELECT and EXCLUDE statements apply only to the immediately preceding COPY statement

Copying, Merging, and Compressing PDS

Let's explore common IEBCOPY operations in more detail with practical examples.

Full PDS Copy

This example copies all members from one PDS to another:

jcl
1
2
3
4
5
6
7
//FULLCOPY EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=MY.SOURCE.PDS,DISP=SHR //SYSUT2 DD DSN=MY.TARGET.PDS,DISP=SHR //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 /*

This is equivalent to using SYSIN DD DUMMY when working with SYSUT1 and SYSUT2.

Merging Multiple PDSs

This example combines members from multiple PDSs into a single PDS:

jcl
1
2
3
4
5
6
7
8
9
10
11
//MERGE EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //PDS1 DD DSN=PROJECT1.SOURCE.PDS,DISP=SHR //PDS2 DD DSN=PROJECT2.SOURCE.PDS,DISP=SHR //PDS3 DD DSN=PROJECT3.SOURCE.PDS,DISP=SHR //COMBINED DD DSN=COMBINED.SOURCE.PDS,DISP=SHR //SYSIN DD * COPY INDD=PDS1,OUTDD=COMBINED COPY INDD=PDS2,OUTDD=COMBINED COPY INDD=PDS3,OUTDD=COMBINED /*

This copies all members from PDS1, PDS2, and PDS3 into COMBINED. If member names conflict, later copies will replace earlier ones.

Multiple Input PDSs in a Single Copy

Alternatively, you can merge PDSs using a single COPY statement:

jcl
1
2
3
4
5
6
7
8
9
//MERGE2 EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //PDS1 DD DSN=PROJECT1.SOURCE.PDS,DISP=SHR //PDS2 DD DSN=PROJECT2.SOURCE.PDS,DISP=SHR //PDS3 DD DSN=PROJECT3.SOURCE.PDS,DISP=SHR //COMBINED DD DSN=COMBINED.SOURCE.PDS,DISP=SHR //SYSIN DD * COPY INDD=((PDS1,R),(PDS2,R),(PDS3,R)),OUTDD=COMBINED /*

The 'R' parameter indicates that members from later-listed datasets will replace those with the same name from earlier-listed datasets.

Compressing a PDS

This example compresses a PDS in place, reclaiming unused space:

jcl
1
2
3
4
5
6
7
8
//COMPRESS EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=MY.SOURCE.PDS,DISP=OLD //SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(5,1)) //SYSUT4 DD UNIT=SYSDA,SPACE=(CYL,(5,1)) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT1 /*

The key to compression is specifying the same dataset for both INDD and OUTDD. The SYSUT3 and SYSUT4 work datasets are required for compression operations.

Important Considerations:

  • Space Requirements: The output PDS must have enough space to hold all copied members
  • Directory Blocks: The output PDS must have enough directory blocks for all member entries
  • Member Replacement: By default, if a member in the output PDS has the same name as one being copied, the member will be replaced
  • Backup First: Always back up important PDSs before compression in case of failure
  • DISP=OLD: For compression operations, the dataset must be allocated with DISP=OLD to ensure exclusive access

Selective Member Operations

One of IEBCOPY's most powerful features is its ability to selectively process members from partitioned datasets. This section explores various selective operations in detail.

Copying Specific Members

This example copies only specific members from a PDS:

jcl
1
2
3
4
5
6
7
8
//SELECT EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //INPDS DD DSN=DEV.SOURCE.PDS,DISP=SHR //OUTPDS DD DSN=PROD.SOURCE.PDS,DISP=SHR //SYSIN DD * COPY INDD=INPDS,OUTDD=OUTPDS SELECT MEMBER=(PAYROLL,BENEFITS,TAXCALC) /*

This copies only the PAYROLL, BENEFITS, and TAXCALC members from DEV.SOURCE.PDS to PROD.SOURCE.PDS.

Using Wildcards for Selection

This example uses wildcards to select members by pattern:

jcl
1
2
3
4
5
6
7
8
//PATTERN EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //INPDS DD DSN=DEV.SOURCE.PDS,DISP=SHR //OUTPDS DD DSN=PROD.SOURCE.PDS,DISP=SHR //SYSIN DD * COPY INDD=INPDS,OUTDD=OUTPDS SELECT MEMBER=(PAY*,GL*) /*

This copies all members whose names start with "PAY" or "GL" from DEV.SOURCE.PDS to PROD.SOURCE.PDS.

Excluding Members

This example copies all members except those specified:

jcl
1
2
3
4
5
6
7
8
//EXCLUDE EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //INPDS DD DSN=DEV.SOURCE.PDS,DISP=SHR //OUTPDS DD DSN=PROD.SOURCE.PDS,DISP=SHR //SYSIN DD * COPY INDD=INPDS,OUTDD=OUTPDS EXCLUDE MEMBER=(TEST*,SAMPLE*) /*

This copies all members except those whose names start with "TEST" or "SAMPLE" from DEV.SOURCE.PDS to PROD.SOURCE.PDS.

Replacing Selected Members Only

This example selectively updates only specific members in a target PDS:

jcl
1
2
3
4
5
6
7
8
//UPDATE EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //NEWPDS DD DSN=NEW.SOURCE.PDS,DISP=SHR //PRODPDS DD DSN=PROD.SOURCE.PDS,DISP=SHR //SYSIN DD * COPY INDD=NEWPDS,OUTDD=PRODPDS SELECT MEMBER=(PAYROLL,BENEFITS) /*

This updates only the PAYROLL and BENEFITS members in PROD.SOURCE.PDS with versions from NEW.SOURCE.PDS, leaving all other members unchanged.

Member Selection Best Practices:

  • Use SELECT when copying a small number of members from a large PDS
  • Use EXCLUDE when you want to copy most members except a few
  • Use wildcards (pattern matching) to handle groups of similarly named members
  • For complex selection criteria, consider using multiple COPY statements
  • Remember that member selection is case-sensitive (mainframe PDS members typically use uppercase names)

Unload/Reload Operations

IEBCOPY provides the ability to unload a partitioned dataset to a sequential dataset and later reload it. This is particularly useful for backup, transportation between systems, or handling very large PDSs.

Unloading a PDS to Sequential Format

This example unloads a PDS to a sequential dataset:

jcl
1
2
3
4
5
6
7
8
9
//UNLOAD EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=MY.SOURCE.PDS,DISP=SHR //SYSUT2 DD DSN=MY.UNLOADED.DATASET,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(10,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=32720) //SYSIN DD * COPY OUTDD=SYSUT2,INDD=SYSUT1 /*

The unloaded dataset can be transported to another system or saved as a backup.

Reloading a Sequential Dataset to PDS

This example reloads the unloaded dataset back to a PDS:

jcl
1
2
3
4
5
6
7
//RELOAD EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=MY.UNLOADED.DATASET,DISP=SHR //SYSUT2 DD DSN=MY.RELOADED.PDS,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(10,5,10)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=32720) //SYSIN DD DUMMY

Note that for the reload operation, the unloaded dataset is specified as SYSUT1 and the target PDS as SYSUT2.

Important Notes for Unload/Reload:

  • The unloaded dataset must be allocated with the correct DCB parameters
  • The target PDS for reloading must have sufficient directory blocks for all members
  • Unloaded datasets are platform-specific and may not be portable between different mainframe systems
  • For load modules, IEBCOPY preserves program attributes during unload/reload
  • Unloaded datasets are more space-efficient for transport than PDSs with many small members

Practical Examples

Let's look at some common real-world examples using IEBCOPY.

Example 1: Backing Up a Production Library

This example creates a backup copy of a production library with a date stamp:

jcl
1
2
3
4
5
6
7
//BACKUP EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=PROD.LOAD.LIBRARY,DISP=SHR //SYSUT2 DD DSN=PROD.LOAD.LIBRARY.D&YYMMDD,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(50,10,20)), // DCB=(RECFM=U,BLKSIZE=32760) //SYSIN DD DUMMY

This creates a dated backup copy of a production load library, preserving all members with their original attributes.

Example 2: Merging Testing and Production Libraries

This example promotes tested modules to production:

jcl
1
2
3
4
5
6
7
8
9
10
11
12
//PROMOTE EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //BACKUP DD DSN=PROD.COPYLIB.BACKUP,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(20,5,10)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //TESTLIB DD DSN=TEST.COPYLIB,DISP=SHR //PRODLIB DD DSN=PROD.COPYLIB,DISP=OLD //SYSIN DD * COPY INDD=PRODLIB,OUTDD=BACKUP COPY INDD=TESTLIB,OUTDD=PRODLIB SELECT MEMBER=(PAY100,PAY110,PAY120) /*

This job first backs up the entire production library, then copies only the specified tested modules to production.

Example 3: Creating an Application-Specific Subset

This example creates a subset library for a specific application:

jcl
1
2
3
4
5
6
7
8
9
10
//SUBSET EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //MAINLIB DD DSN=MAIN.COPYLIB,DISP=SHR //PAYLIB DD DSN=PAYROLL.COPYLIB,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(5,2,10)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //SYSIN DD * COPY INDD=MAINLIB,OUTDD=PAYLIB SELECT MEMBER=(PAY*,HR*) /*

This creates a specialized library containing only payroll and HR-related copybook members.

Example 4: Library Maintenance and Reorganization

This example performs comprehensive library maintenance:

jcl
1
2
3
4
5
6
7
8
9
10
//MAINT EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=* //OLDLIB DD DSN=OLD.MESSY.LIBRARY,DISP=SHR //NEWLIB DD DSN=NEW.CLEAN.LIBRARY,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA,SPACE=(CYL,(20,5,50)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //SYSIN DD * COPY INDD=OLDLIB,OUTDD=NEWLIB EXCLUDE MEMBER=(TEST*,TEMP*,OLD*) /*

This creates a clean, reorganized library by excluding test, temporary, and obsolete members.

Best Practices and Common Mistakes

While IEBCOPY is a powerful and reliable utility, following best practices can help avoid common issues.

Best Practices

  • Always back up important libraries before major operations
  • Allocate sufficient directory blocks in target PDSs
  • Use PDSEs for enhanced functionality and automatic space reclamation
  • Use DISP=OLD for compress operations to ensure exclusive access
  • Regularly compress frequently updated libraries
  • Document control statements for complex copy operations

Common Mistakes

  • Insufficient directory blocks in the target PDS
  • Insufficient space allocation for the target PDS
  • Incorrect DCB parameters for unload/reload operations
  • Forgetting to include SYSUT3 and SYSUT4 for compress operations
  • Using DISP=SHR when compressing a PDS
  • Incorrect syntax in control statements

IEBCOPY vs. Other Utilities

When to use IEBCOPY versus alternatives:

Use IEBCOPY WhenUse Alternatives When
Working with partitioned datasetsWorking with sequential datasets (use IEBGENER)
Copying load modulesWorking with VSAM datasets (use IDCAMS)
Merging multiple PDSsComplex data transformation needed (use custom program)
Selective member operationsContent-based filtering needed (use DFSORT)
Compressing PDSsWorking with PDSEs (they self-compress)

Common Questions and Issues

Test Your Knowledge

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

  • To sort datasets
  • To copy sequential datasets
  • To copy and manipulate partitioned datasets
  • To catalog datasets

2. Which statement is TRUE about IEBCOPY?

  • It can only copy entire PDSs
  • It can copy selected members from a PDS
  • It works primarily with VSAM datasets
  • It requires SORT parameters

3. What process can reduce the size of a PDS by eliminating unused space?

  • Concatenation
  • Compression
  • Conversion
  • Compilation

4. Which DD statement is used for output in IEBCOPY?

  • SYSUT1
  • SYSUT2
  • SYSIN
  • SYSPRINT

5. What control statement would you use to copy specific members from a PDS?

  • COPY INDD=IN,OUTDD=OUT,SELECT=MEMBER
  • SELECT MEMBER=NAME
  • COPY SELECT MEMBER=NAME
  • EXCLUDE MEMBER=NAME

6. What happens when IEBCOPY encounters a member in the output PDS with the same name as one being copied?

  • It skips the member
  • It replaces the member
  • It renames the new member
  • It terminates with an error