IEBCOPY in JCL with Examples

IEBCOPY in JCL tutorial, IEBCOPY examples and sample JCL/JOB

  • IEBCOPY is a copy utility that is used to perform copy functionalities for PDS and PDSE datasets.
  • Copy all or Selected members from one PDS to another.
  • Create multiple PDS in a single IEBCOPY job from one input PDS.
  • Compress PDS to release the unused space.
  • Moving PDS, PDSe’s from one volume to another.
  • To create an Unloaded partitioned datasets from PDS. This Unloaded Partitioned dataset is a special format sequential dataset generally written on to a tape.
  • Create a PDS back from UPDS.

Example-1:COPY ALL MEMBERS FROM ONE PDS TO ANOTHER 
To copy all members, SYSIN is not required. So it can be specified as DUMMY. Here it copies all the members from input to output intacting the existing members in output PDS. So it adds the members to the existing list of members in output PDS.

//*
//* COPY ALL MEMBERS FROM ONE PDS TO ANOTHER
//*
//STEP09 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=PKM.TR.SOURCE.B8,DISP=SHR
//SYSUT2 DD DSN=PKM.TR.SOURCE.B9,DISP=OLD
//SYSIN DD DUMMY
//*

By default it ignores the members with same name, It won’t override. To replace the members with same name, it needs to be specified in either in the copy option or in PARM parameter as shown below.

Example-2:To replace all the similar named members, specify it in the PARM parameter as shown below.

//**********************************************************************
//* IEBCOPY TO REPLACE ALL THE SIMILAR NAMED MEMBERS
//***************************************************************
//STEP01 EXEC PGM=IEBCOPY,PARM=REPLACE
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=PXG.PR.SOURCE,DISP=SHR
//SYSUT2 DD DSN=PXG.PR.SOURCE.B6,DISP=OLD
//* UNIT=SYSDA,SPACE=(CYL,(5,5))
//* DCB=(RECFM=FB,LRECL=110,BLKSIZE=1100)
//SYSIN DD *
COPY OUTDD=SYSUT2,INDD=SYSUT1
/*

Example-3:To replace only the specified members in the target PDS, it needs to be specified in the SYSIN as below:

//**********************************************************************
//* IEBCOPY TO REPLACE SPECIFIED MEMBERS OF SAME NAMES
//***************************************************************
//STEP00 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=PXG.TR.SRCE,DISP=SHR
//SYSUT2 DD DSN=PXG.TR.SRCE.B6,DISP=OLD
//* UNIT=SYSDA,SPACE=(CYL,(5,5))
//* DCB=(RECFM=FB,LRECL=110,BLKSIZE=1100)
//SYSIN DD *
COPY OUTDD=SYSUT2,INDD=SYSUT1
SELECT MEMBER=((JCL700,,R))
/*
//

Example-4:Copy selected members from One PDS to another existing PDS.

//*
//* COPY MEMBERS TO AN EXISTING OUTPUT PDS
//*
//STEP02 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=CPY.TEST.SOURCE,DISP=SHR
//SYSUT2 DD DSN=CPY.TEST.OUT.PDS,DISP=OLD,
// UNIT=SYSDA,SPACE=(CYL,(5,5))
//SYSIN DD *
COPY OUTDD=SYSUT2,INDD=SYSUT1
SELECT MEMBER=JCLTST1,JCLTST2
/*
//

Example-5: IEBCOPY SELECT -Copy selected members from One PDS in to multiple PDS.

//*
//* COPY SELECTED MEMBERS INTO MULTIPLE PDS DATSETS
//*
//STEP03 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=CPY.TEST.SOURCE,DISP=SHR
//SYSUT2 DD DSN=CPY.TEST.OUT.PDS1,DISP=OLD,
// UNIT=SYSDA,SPACE=(CYL,(5,5))
//SYSUT3 DD DSN=CPY.TEST.OUT.PDS2,DISP=OLD,
// UNIT=SYSDA,SPACE=(CYL,(5,5))
//SYSIN DD *
COPY OUTDD=SYSUT2,INDD=SYSUT1
SELECT MEMBER=JCLTST1,JCLTST2
COPY OUTDD=SYSUT3,INDD=SYSUT1
SELECT MEMBER=JCLTST3
/*
//

Example-6: IEBCOPY Exclude.

//*
//* COPY ALL MEMBERS EXCLUDING SELECTED MEMBERS
//*
//STEP04 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=TPY.TR.SRCE,DISP=SHR
//SYSUT2 DD DSN=TPY.TR.SRCE.O1,DISP=OLD,
// UNIT=SYSDA,SPACE=(CYL,(5,5))
//SYSUT3 DD DSN=TPY.TR.SRCE.O2,DISP=OLD,
// UNIT=SYSDA,SPACE=(CYL,(5,5))
//SYSIN DD *
COPY OUTDD=SYSUT2,INDD=SYSUT1
EXCLUDE MEMBER=JCLTST1
COPY OUTDD=SYSUT3,INDD=SYSUT1
EXCLUDE MEMBER=JCLTST2
/*
//
Here first output data set contains all the input PDS members except JCLTST1, in the same way 2nd output dataset contains all except the JCLTST2 member.

Example-7: Copy Members into a New PDS

To copy members to a new PDS, in JCL PDS Directory Blocks and DSNTYPE needs to be specified. Directory blocks should be specified in SPACEC parameter.

//*
//* COPY MEMBERS TO A NEW PDS
//*
//STEP05 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=KXG.TC.SRC,DISP=SHR
//SYSUT2 DD DSN=KXG.TC.SRC.B6,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5,5)),DSNTYPE=PDS,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
//SYSIN DD *
COPY OUTDD=SYSUT2,INDD=SYSUT1
SELECT MEMBER=JCL700
/*
//

Example-8: Creating Unloaded partitioned datasets (Taking PDS Backup on to a TAPE)

Generally PDS data sets are stored as a special format sequential data-sets on Tapes. So to take backup of any PDS, we copy it in to a PS. And IEBCOPY allocates its DCB parameters(Organization : PS , Record format : VS , Record length . . . : 9056 Block size . . . . : 9060). Later this PS can be restored(copied back in to PDS )

//* CREATING AN UNLOADED PARTITIONED DATASETS FROM PDS.
//*
//STEP06 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=KXG.TC.SRC,DISP=SHR
//SYSUT2 DD DSN=KXG.TC.SRC.U1,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5))
//SYSIN DD *
COPY OUTDD=SYSUT2,INDD=SYSUT1
SELECT MEMBER=JCL700
/*
//*

//*
//* CREATING PDS FROM UNLOADED PARTIONED DATASETS
//*
//STEP07 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=KMX.CR.SOURCE.U1,DISP=SHR
//SYSUT2 DD DSN=KMX.CR.SOURCE.B7,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(5,5,5)),DSNTYPE=PDS,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=8000)
//SYSIN DD DUMMY
/*
//*

Example-9: IEBCOPY Wild cards 

Copying from One PDS to another with Wild Card:

IEBCOPY supports wild cards in Select and Exclude statements. Below wild card allows to copy all the maps from source to target which starts with KDM and has 3 ore characters.

//********************************************************************
//JS10 EXEC PGM=IEBCOPY
//DD11 DD DSN=PT.PO.MAPS,DISP=SHR
//DD12 DD DSN=PT.TO.MAPS.BKUP,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
COPY INDD=((DD11,R)),OUTDD=DD12
SELECT MEMBER=KDM%%%
/*

SELECT MEMBER=KDM%, Then it copies members which starts with KDM + any other character. If we use ‘%’ AS WILD CHARECTOR, we need to give the exact number of ‘%’s to match the total members name length.
Instead ‘*’ can be used as a wild charecter, where if we use KDM*, it considers all the members that starts with KDM.

Example-10: IEBCOPY  Compress PDS 

Generally PDS requires maintenance as whenever a member is deleted, that space remains as unused space thus occupies the actual space which may result in space errors. So to delete or release that unused space compress is required. Using TSO/ISPF, Compress is performed by giving ‘Z’ against that PDS. To that in a batch job, IEBCOPY is used. Here input and output PDS are given same and performs a simple copy operation which eliminates the unused space and converts it into available space.

Multiple datasets can be compressed in a single job step by giving multiple input & output PDSs.

//********************************************************************
//JS20 EXEC PGM=IEBCOPY
//DD13 DD DSN=PT.PO.PDS,DISP=SHR
//DD14 DD DSN=PT.TO.PDS,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
COPY INDD=DD13,OUTDD=DD14
/*

IEBCOPY Errors:

IS SUPPOSED TO BE A PARTITIONED DATA SET BUT IT HAS NO DIRECTORY.

This is because, PDS mentioned in the output dataset is not an existing PDS. It is a new one and PDS allocation parameters DSNTYPE and directory blocks are missing.

 

Few More Notes:
  • IEBCOPY SYSUT1 & SYSUT2 etc are not the mandatory names. Any other names can be given.
  • Multiple input and/or output PDSs can be given.
  • Generally this utility is used as backup utility where to take backup of source code, MAPS.
  • Used to copy members from production to Test.
  • Schedules a JOB with IEBCOPY Compress option and runs it periodically to avoid any space errors.
  • While compressing a PDS, care must be taken as some times if the mainframe goes down or it gets disconnected, there is a chance of losing the data. So it is always advised to put a backup job, before compressing it.

If you feel anything else needs to be added to this post, please share it via comments.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

Bitnami