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). As a sequential data set it can on tape, sent by FTP, or used as a simple sequential data set.
  • 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
//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.
Note! We have explained about the IEBCOPY frequently performing tasks below. To learn more, use the left navigation '+' for the topics explained in detail.

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 - Copy from one dataset to another resides on different volume.

JCL -

----+----1----+----2----+----3----+----4----+----5----+
//MATEPKC  JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID 
//*****************************************************************
//* TO COPY PDS DATA SET ANOTHER PDS DATA SET ON DIFFERENT VOLUME
//*****************************************************************
//STEP10   EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSDUMP  DD SYSOUT=*
//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
/*

Explaining Example -

  • SYSUT1 DD DSN=MATEPK.IEBCOPY.INPPDS - Specifies the input PDS and resides on the volume STRVL2.
  • SYSUT2 DD DSN=MATEPK.IEBCOPY.OUTPDS,.. - Specifies the output new PDS and creating on the volume DEVHD4.
  • COPY INDD=SYSUT1,OUTDD=SYSUT2 - Copies all members from SYSUT1 to SYSUT2. Both input and output datasets are on different volumes.

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 members (COPY) from one PDS to another.

JCL -

----+----1----+----2----+----3----+----4----+----5----+
//MATEPKS  JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID
//***************************************************
//* SELETING MEMBER(S) FROM INPUT PDS DURING COPY
//***************************************************
//STEP10   EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSDUMP  DD SYSOUT=*
//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
/* 

Explaining Example -

  • SYSUT1 DD DSN=MATEPK.IEBCOPY.INPPDS - Specifies the input PDS.
  • SYSUT2 DD DSN=MATEPK.IEBCOPY.OUTPDS - Specifies the output PDS.
  • COPYGRP INDD=SYSUT1,OUTDD=SYSUT2 - Copies members from SYSUT1 to SYSUT2.
  • SELECT MEMBER=FIRSTPRG,IDENTDIV,LEVELNUM - Copies member FIRSTPRG,IDENTDIV and LEVELNUM from SYSUT1 to SYSUT2.

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 -

EXCLUDE Input

JCL -

----+----1----+----2----+----3----+----4----+----5----+
//MATEPKC  JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID
//*********************************************************
//* EXCLIDING MEMBERS WHILE COPY FROM ONE PDS TO ANOTHER
//*********************************************************
//STEP10   EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSDUMP  DD SYSOUT=*
//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
/*

Explaining Example -

  • SYSUT1 DD DSN=MATEPK.IEBCOPY.INPLOAD - Specifies the input load PDS.
  • SYSUT2 DD DSN=MATEPK.IEBCOPY.OUTLOAD,.. - Specifies the output load PDS.
  • COPY INDD=SYSUT1,OUTDD=SYSUT2
    EXCLUDE MEMBER=MAINPROG
    - Copies all other members except MAINPROG from SYSUT1 to SYSUT2.

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 source PDS that has the members with same name.

Practical Example -

Scenario - Copying members from one PDS to another renaming.

JCL -

----+----1----+----2----+----3----+----4----+----5----+
//MATEPKS  JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID
//**************************************************
//* SELETING MEMBER(S) FROM INPUT PDS DURING COPY
//**************************************************
//STEP10   EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSDUMP  DD SYSOUT=*
//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)
/* 

Explaining Example -

  • SYSUT1 DD DSN=MATEPK.IEBCOPY.INPPDS - Specifies the input PDS.
  • SYSUT2 DD DSN=MATEPK.IEBCOPY.OUTPDS - Specifies the output PDS.
  • COPYGRP INDD=SYSUT1,OUTDD=SYSUT2 - Copies members from SYSUT1 to SYSUT2.
  • SELECT MEMBER=(FIRSTPRG,FRSTPRG1,R) - Copies member FIRSTPRG and ranames it as FRSTPRG1.

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 - Compress a PDS.

JCL -

----+----1----+----2----+----3----+----4----+----5----+
//MATEPKC  JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID
//***************************************************
//* COMPRESS THE PDS
//***************************************************
//STEP10   EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSDUMP  DD SYSOUT=*
//SYSUT1   DD DSN=MATEPK.IEBCOPY.INPPDS,DISP=SHR
//SYSUT2   DD DSN=MATEPK.IEBCOPY.INPPDS,DISP=OLD
//SYSIN    DD *
  COPY OUTDD=SYSUT2,INDD=SYSUT1
/*

Job Status -

Compress PDS Job Status

Explaining Example -

  • SYSUT1 DD DSN=MATEPK.IEBCOPY.INPPDS
    SYSUT2 DD DSN=MATEPK.IEBCOPY.INPPDS
    - Specifies the PDS that needs to be compressed.
  • COPY OUTDD=SYSUT2,INDD=SYSUT1 - INDD, OUTDD should be same to compress it.

Want to Learn More?


If you want to learn more about IEBCOPY utility, go through the below topics explained in detail with examples -