Merging DataSets


IEBCOPY COPY statement performs the merge operation to merge multiple PDS into one PDS. The ordering of the members in the output PDS can be done automatically after the merge operation.

Practical Example -


Scenario - Merge two PDS and copy all members to output PDS.

JCL -

----+----1----+----2----+----3----+----4----+----5----+
//MATEPKM  JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID
//************************************************
//* TO MERGE MANY TO ONE PDS
//************************************************
//STEP50   EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSDUMP  DD SYSOUT=*
//INPPDS1  DD DSN=MATEPK.IEBCOPY.INPPDS,DISP=SHR
//INPPDS2  DD DSN=MATEPK.IEBCOPY.INPPDS1,DISP=SHR
//OUTPDS   DD DSN=MATEPK.IEBCOPY.OUTPDS,DISP=OLD
//SYSIN    DD *
    COPY  OUTDD=OUTPDS
          INDD=INPPDS1,INPPDS2
/* 

Job Status -

Merge Job Status

Output -

Merge Output

Explaining Example -

  • INPPDS1 DD DSN=MATEPK.IEBCOPY.INPPDS,..
    INPPDS2 DD DSN=MATEPK.IEBCOPY.INPPDS1,..
    - Specifies the input PDS file.
  • OUTPDS DD DSN=MATEPK.IEBCOPY.OUTPDS - Specifies the output PDS.
  • COPY OUTDD=OUTPDS
    INDD=INPPDS1,INPPDS2
    - Specified INPPDS1, INPPDS2 are inputs and OUTPDS is output.