IEBCOPY Utility
IEBCOPY is a data set utility program in a mainframe environment that is used to copy members from one or more PDS (Partitioned Data Set) or PDSE (Partitioned Data Set Extended) to another. It is also used to merge members between one or more PDS, or PDSE. The copying or merging can be full or partial.
IEBCOPY stands for "IEB Input-Output COPY" and it is only used to manage PDS or PDSE and not applicable on PS (Physical sequential).
This utility is most commonly used for the below purposes -
- Copy all or selected members from one PDS to another.
- Unload a PDS into a unique sequential data set (file).
- Load a unloaded sequential data set (sequential file) and recreate the original partitioned data set.
- To compress partitioned data sets (in place) to recover lost space.
Syntax -
----+----1----+----2----+----3----+----4----+----5----+
//job-Card-and-parameters
//STEP1 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSDUMP DD SYSOUT=*
//SYSUT1 DD DSN=...
//SYSUT2 DD DSN=...
//SYSUT3 DD UNIT=..
//SYSUT4 DD UNIT=..
//SYSIN DD *
control-statements
/*
- SYSPRINT - Optional. Utility programs use it for their output.
- SYSOUT - Optional. SYSOUT specifies a system-defined DD name for file status codes, system abend codes information, and the display statement output.
- SYSDUMP - Optional. The system uses it for dumping when an abend occurs.
- SYSUT01/any-ddname - Mandatory. This is an input DD statement. Multiple DD statements can be provided as input.
- SYSUT02/any-ddname - Mandatory. This is an output DD statement.
- SYSUT03/SYSUT04 - Optional. These are buffer memory DD statements (SYSUT03 for input and SYSUT04 for output) for processing the task.
- SYSIN - Contains the control statements for processing the task.
- control-statements - utility control statements that are used to perform a task.
Return Codes -
- IEBCOPY returns a code in register 15 to specify the results of utility execution status.
- The return codes of IEBCOPY and the meanings are -
- 00 (X'00') - Successful completion.
- 04 (X'04') - One or more COPY or COPYGRP operations completed unsuccessfully or uncompleted.
Recovery may be possible for this case. - 08 (X'08') - An unrecoverable error exists. The utility ends.
Copy members from PDS to PDS
IEBCOPY is used for copying members from one PDS to other. It can be used to backup the entire dataset, copy members between different datasets, and perform various members manipulation tasks. The copy can be full or partial.
Practical Example -
Scenario - Copying all members from one dataset to another.
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//STEP10 EXEC PGM=IEBCOPY
//SYSUT1 DD DSN=MATEPK.IEBCOPY.INPPDS,DISP=SHR
//SYSUT2 DD DSN=MATEPK.IEBCOPY.OUTPDS,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(10,10,10),RLSE),
// UNIT=3390,VOL=SER=DEVHD4,
// DCB=(DSORG=PO,RECFM=FB,LRECL=80,BLKSIZE=800)
//SYSIN DD *
COPY INDD=SYSUT1,OUTDD=SYSUT2
/*
...
Selecting Members for Copy
IEBCOPY SELECT statement is used to select members from one or more PDS during the copy. Selected members are searched in an a-to-z order, regardless of the coded order in the SELECT statement.
Practical Example -
Scenario - Copying specific members (COPY) from one PDS to another.
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//STEP10 EXEC PGM=IEBCOPY
//SYSUT1 DD DSN=MATEPK.IEBCOPY.INPPDS,DISP=SHR
//SYSUT2 DD DSN=MATEPK.IEBCOPY.OUTPDS,DISP=OLD
//SYSIN DD *
COPY INDD=SYSUT1,OUTDD=SYSUT2
SELECT MEMBER=FIRSTPRG,IDENTDIV,LEVELNUM
/*
...
Excluding Members from a Copy
IEBCOPY EXCLUDE statement used to exclude the coded members during the copy, unload, and load operations. The excluded member is searched on every input PDS and is omitted.
Practical Example -
Scenario - Excluding a members while copying from one PDS to another.
Input -
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//STEP10 EXEC PGM=IEBCOPY
//SYSUT1 DD DSN=MATEPK.IEBCOPY.INPPDS,DISP=SHR
//SYSUT2 DD DSN=MATEPK.IEBCOPY.OUTPDS,DISP=OLD
//SYSIN DD *
COPY INDD=SYSUT1,OUTDD=SYSUT2
EXCLUDE MEMBER=MAINPROG
/*
...
Rename Members during Copy
IEBCOPY COPY statement used to rename the members while copying from source to destination PDS. This process helps when copying from two or more members from source PDS that has the same name.
Practical Example -
Scenario - Renaming members while copying from one PDS to another.
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//STEP10 EXEC PGM=IEBCOPY
//SYSUT1 DD DSN=MATEPK.IEBCOPY.INPPDS,DISP=SHR
//SYSUT2 DD DSN=MATEPK.IEBCOPY.OUTPDS,DISP=OLD
//SYSIN DD *
COPY INDD=SYSUT1,OUTDD=SYSUT2
SELECT MEMBER=(FIRSTPRG,FRSTPRG1,R)
/*
...
Compress PDS
IEBCOPY can be used to compress a PDS. A PDS may contain unused areas from a deleted member, or the old version of an updated member. Compressing a PDS involves removing unused or deleted members and reclaiming space within the dataset. This helps in optimizing storage usage.
Practical Example -
Scenario - Compressing a PDS.
JCL -
----+----1----+----2----+----3----+----4----+----5----+
...
//STEP10 EXEC PGM=IEBCOPY
//SYSUT1 DD DSN=MATEPK.IEBCOPY.INPPDS,DISP=SHR
//SYSIN DD *
COPY OUTDD=SYSUT1,INDD=SYSUT1
/*
...
Want to Learn More?
If you want to learn more about IEBCOPY utility, go through the below topics explained with examples -