In this topic, we described about the Merge Datasets with detailed example.
IEBCOPY can be used to merge the datasets. Merging data sets can be done by copying or loading the additional members to an existing PDS.
The merge operation can be performed by IEBCOPY. Ordering of the directory of the output data set after merge can be done automatically.
Members are copied from three input partitioned data sets (DATASET1, DATASET2, and DATASET3) to an existing output partitioned data set (DATASETO).
//MERGEDS JOB ... //STEP01 EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=A //IN1 DD DSNAME=DATASET1,UNIT=disk,VOL=SER=111111, // DISP=SHR //IN2 DD DSNAME=DATASET2,UNIT=disk,VOL=SER=111112, // DISP=OLD //OUT1 DD DSNAME=DATASET4,UNIT=disk,VOL=SER=111114, // DISP=(OLD,KEEP) //SYSUT3 DD UNIT=SYSDA,SPACE=(TRK,(1)) //SYSIN DD * COPYOPER COPY OUTDD=OUT1 INDD=IN1 INDD=IN2 /*
Let’s discuss the example in detail.
- IN1 DD defines a PDS (DATASET1). This data set contains three members (A, B, and F) in fixed format with a logical record length of 80 bytes and a block size of 80 bytes.
- IN2 DD defines a PDS (DATASET2). This data set contains two members (A and C) in fixed blocked format with a logical record length of 80 bytes and a block size of 160 bytes.
- OUT1 DD defines a PDS (DATASET2). This data set contains two members (C and E) in fixed-block format. The members have a logical record length of 80 bytes and a block size of 360 bytes.
- SYSUT3 defines a temporary data set.
- SYSIN DD defines the control data set, which follows in the input stream.
- COPY indicates the start of the copy operation. The OUTDD parameter specifies DATASET2 as the output data set.
- The first INDD statement specifies DATASET1 as the first input data set to be processed. All members (A, B and F) are copied to DATASET2.
- The second INDD statement specifies DATASET2 as the second input data set to be processed. Processing occurs as follows:
- Since replacement is not specified, members B and C, which already exist in DATASET4, are not copied to DATASET4.
- Member D is copied to DATASET4.
- All members in DATASET2 are lost when the data set is deleted.