What is IEBCOPY?
IEBCOPY is a utility program in the IBM z/OS operating system that is used to copy data from one data set to another. It is particularly useful when you want to copy data sets with large block sizes, or when you want to copy data sets with different organization, record format, or block size. IEBCOPY can also be used to copy data between data sets with different data formats, such as ASCII and EBCDIC. It can also be used to reformat data while it is being copied, by using the “INDDN” (input data definition name) and “OUTDDN” (output data definition name) parameters to specify different data definitions for the input and output data sets.
A sample JCL of IEBCOPY:
Here is an example of a simple JCL job that uses the IEBCOPY utility to copy data from one data set to another:
//IEBCOPY JOB (123456),'COPY DATA',CLASS=A,MSGCLASS=H
//COPY EXEC PGM=IEBCOPY,PARM='FROMDSN(INPUT.DATASET) TODSN(OUTPUT.DATASET)'
//FROMDD DSN=INPUT.DATASET,DISP=SHR
//TODD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(5,5)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
Note: Please read the language as JCL.
In this example, the FROMDD DD statement defines the input data set (INPUT.DATASET), and the TODD DD statement defines the output data set (OUTPUT.DATASET). The FROMDSN and TODSN parameters in the IEBCOPY utility specify the names of the input and output data sets. The DISP parameter in the TODD DD statement specifies the disposition of the output data set: in this case, the data set will be created (NEW), cataloged (CATLG), and deleted (DELETE) after the job completes.
The UNIT and SPACE parameters specify the device and space allocation for the output data set, and the DCB parameter specifies the record format (RECFM), logical record length (LRECL), and block size (BLKSIZE) of the output data set. The SYSPRINT DD statement directs any output messages generated by the IEBCOPY utility to the system print device (SYSOUT). The SYSIN DD statement specifies that any additional parameters or options for the IEBCOPY utility are to be read from standard input (in this case, from the * symbol, which indicates that the parameters are not specified in the JCL).
Special usage example of JCLs for IEBCOPY
Here are a couple of examples of more advanced uses of the IEBCOPY utility in JCL:
Copying data between data sets with different block sizes:
//IEBCOPY JOB (123456),'COPY DATA',CLASS=A,MSGCLASS=H
//COPY EXEC PGM=IEBCOPY,PARM='FROMDSN(INPUT.DATASET) TODSN(OUTPUT.DATASET) BLKSIZE(4000)'
//FROMDD DSN=INPUT.DATASET,DISP=SHR
//TODD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(5,5)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000)
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
Note: Please read the language as JCL above.
In this example, the BLKSIZE parameter is used to specify a block size of 4000 bytes for the output data set. This allows the IEBCOPY utility to copy data between data sets with different block sizes.
Copying data and reformatting it using different data definitions:
//IEBCOPY JOB (123456),'COPY DATA',CLASS=A,MSGCLASS=H
//COPY EXEC PGM=IEBCOPY,PARM='FROMDSN(INPUT.DATASET) TODSN(OUTPUT.DATASET) INDDN(INPUT.DD) OUTDDN(OUTPUT.DD)'
//FROMDD DSN=INPUT.DATASET,DISP=SHR
//TODD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(5,5)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000)
//INDD DSN=INPUT.DD,DISP=SHR
//OUTDD DSN=OUTPUT.DD,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
//*
Note: Please read the language as JCL above.
In this example, the INDDN and OUTDDN parameters are used to specify different data definitions (INPUT.DD and OUTPUT.DD) for the input and output data sets. This allows the IEBCOPY utility to reformat the data while it is being copied, using the different data definitions. The INDD and OUTDD DD statements are used to define the input and output data definitions, respectively.
Clever usage of IEBCOPY
Here are a few more advanced examples of using the IEBCOPY utility in JCL:
Copying data and renaming it in the process:
//IEBCOPY JOB (123456),'COPY DATA',CLASS=A,MSGCLASS=H
//COPY EXEC PGM=IEBCOPY,PARM='FROMDSN(INPUT.DATASET) TODSN(OUTPUT.DATASET) NEWNAME'
//FROMDD DSN=INPUT.DATASET,DISP=SHR
//TODD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(5,5)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000)
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
Note: Please read the language as JCL above.
In this example, the NEWNAME parameter is used to specify that the IEBCOPY utility should rename the output data set to a new name. The new name will be generated automatically by the IEBCOPY utility.
Copying data and updating data in the process:
//IEBCOPY JOB (123456),'COPY DATA',CLASS=A,MSGCLASS=H
//COPY EXEC PGM=IEBCOPY,PARM='FROMDSN(INPUT.DATASET) TODSN(OUTPUT.DATASET) UPDATE'
//FROMDD DSN=INPUT.DATASET,DISP=SHR
//TODD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(5,5)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000)
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
//*
Note: Please read the language as JCL above.
In this example, the UPDATE parameter is used to specify that the IEBCOPY utility should update the data in the output data set as it is being copied. This can be useful if you want to update certain fields in the data while it is being copied, or if you want to add new records to the output data set.
Copying data and skipping over certain records:
//IEBCOPY JOB (123456),'COPY DATA',CLASS=A,MSGCLASS=H
//COPY EXEC PGM=IEBCOPY,PARM='FROMDSN(INPUT.DATASET) TODSN(OUTPUT.DATASET) SKIP.CONDITION(00001,00005,00020)'
//FROMDD DSN=INPUT.DATASET,DISP=SHR
//TODD DSN=OUTPUT.DATASET,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(TRK,(5,5)),DCB=(RECFM=FB,LRECL=80,BLKSIZE=4000)
//SYSPRINT DD SYSOUT=*
//*
Note: Please read the language as JCL above.