Copy, merge, and manage partitioned datasets efficiently
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.
IEBCOPY provides several key capabilities for managing partitioned datasets:
Transfer all members from one partitioned dataset to another
Copy only specific members from a source PDS
Combine members from multiple input libraries into one output library
Eliminate wasted space within a partitioned dataset
Exclude specific members from the copy operation
Special handling for executable program libraries
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.
DD Name | Purpose |
---|---|
SYSUT1 | Input partitioned dataset (when no INDD is specified in control statements) |
SYSUT2 | Output 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 |
SYSIN | Control statements (can be DUMMY for a simple full copy from SYSUT1 to SYSUT2) |
SYSPRINT | Messages and diagnostics output |
DD Name | Purpose |
---|---|
SYSUT1 | Partitioned dataset to be compressed (also used as output) |
SYSIN | Control statements with COMPRESS command |
SYSPRINT | Messages and diagnostics output |
SYSUT3 | Work dataset (required for compress operations) |
SYSUT4 | Work dataset (required for compress operations) |
12345//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.
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.
Statement | Purpose |
---|---|
COPY | Copies members from input dataset(s) to output dataset |
SELECT | Specifies which members to include in the copy operation |
EXCLUDE | Specifies which members to exclude from the copy operation |
INDD | Specifies the DDname of input dataset(s) |
OUTDD | Specifies the DDname of the output dataset |
COMPRESS | Compresses a partitioned dataset in place |
The COPY statement is the primary control statement in IEBCOPY. It specifies what is to be copied and to where:
1COPY INDD=INPDS,OUTDD=OUTPDS
This copies all members from the dataset defined by DDname INPDS to the dataset defined by DDname OUTPDS.
To copy only specific members:
12COPY INDD=INPDS,OUTDD=OUTPDS SELECT MEMBER=(MEMBER1,MEMBER2,MEMBER3)
This copies only MEMBER1, MEMBER2, and MEMBER3 from INPDS to OUTPDS.
To copy all members except specific ones:
12COPY INDD=INPDS,OUTDD=OUTPDS EXCLUDE MEMBER=(MEMBER1,MEMBER2)
This copies all members from INPDS to OUTPDS except MEMBER1 and MEMBER2.
To copy members matching a pattern:
12COPY INDD=INPDS,OUTDD=OUTPDS SELECT MEMBER=(PAY*,GL*)
This copies all members whose names start with "PAY" or "GL".
To compress a PDS in place:
1COPY INDD=SYSUT1,OUTDD=SYSUT1
This compresses the dataset defined by SYSUT1. Note that both INDD and OUTDD point to the same dataset.
Let's explore common IEBCOPY operations in more detail with practical examples.
This example copies all members from one PDS to another:
1234567//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.
This example combines members from multiple PDSs into a single PDS:
1234567891011//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.
Alternatively, you can merge PDSs using a single COPY statement:
123456789//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.
This example compresses a PDS in place, reclaiming unused space:
12345678//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.
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.
This example copies only specific members from a PDS:
12345678//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.
This example uses wildcards to select members by pattern:
12345678//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.
This example copies all members except those specified:
12345678//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.
This example selectively updates only specific members in a target PDS:
12345678//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.
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.
This example unloads a PDS to a sequential dataset:
123456789//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.
This example reloads the unloaded dataset back to a PDS:
1234567//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.
Let's look at some common real-world examples using IEBCOPY.
This example creates a backup copy of a production library with a date stamp:
1234567//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.
This example promotes tested modules to production:
123456789101112//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.
This example creates a subset library for a specific application:
12345678910//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.
This example performs comprehensive library maintenance:
12345678910//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.
While IEBCOPY is a powerful and reliable utility, following best practices can help avoid common issues.
When to use IEBCOPY versus alternatives:
Use IEBCOPY When | Use Alternatives When |
---|---|
Working with partitioned datasets | Working with sequential datasets (use IEBGENER) |
Copying load modules | Working with VSAM datasets (use IDCAMS) |
Merging multiple PDSs | Complex data transformation needed (use custom program) |
Selective member operations | Content-based filtering needed (use DFSORT) |
Compressing PDSs | Working with PDSEs (they self-compress) |
1. What is the primary purpose of the IEBCOPY utility?
2. Which statement is TRUE about IEBCOPY?
3. What process can reduce the size of a PDS by eliminating unused space?
4. Which DD statement is used for output in IEBCOPY?
5. What control statement would you use to copy specific members from a PDS?
6. What happens when IEBCOPY encounters a member in the output PDS with the same name as one being copied?