In this example, two members (A and B) are selected from two input
partitioned data sets (DATASET5 and DATASET6) and copied to an existing
output partitioned data set (DATASET1). Member B replaces an identically
named member that already exists on the output data set. Figure 1 shows the input and output data sets before and after
processing.
Figure 1. Selective Copy with Replace
specified on the Member Level
//COPY JOB ...
//JOBSTEP EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//OUT1 DD DSNAME=DATASET1,UNIT=disk,VOL=SER=111112,
// DISP=(OLD,KEEP)
//IN6 DD DSNAME=DATASET6,UNIT=disk,VOL=SER=111115,
// DISP=OLD
//IN5 DD DSNAME=DATASET5,UNIT=disk,VOL=SER=111116,
// DISP=(OLD,KEEP)
//SYSUT3 DD UNIT=SYSDA,SPACE=(TRK,(1))
//SYSUT4 DD UNIT=SYSDA,SPACE=(TRK,(1))
//SYSIN DD *
COPYOPER COPY OUTDD=OUT1
INDD=IN5,IN6
SELECT MEMBER=((B,,R),A)
/*
The control statements are discussed below:
- OUT1 DD defines a partitioned data set (DATASET1), which contains
three members (A, B and F).
- IN6 DD defines a partitioned data set (DATASET6), which contains
three members (B, C and D).
- IN5 DD defines a partitioned data set (DATASET5), which contains
two members (A and C).
- SYSUT3 and SYSUT4 DD define temporary spill data sets. One track
is allocated for each on a disk volume.
- SYSIN DD defines the control data set, which follows in the input
stream. The data set contains a COPY statement, an INDD statement,
and a SELECT statement.
- COPY indicates the start of the copy operation. The use of a SELECT
statement causes a selective copy. The OUTDD parameter specifies DATASET1
as the output data set.
- INDD specifies DATASET5 as the first input data set to be processed
and DATASET6 as the second input data set to be processed. Processing
occurs as follows:
- Selected members are searched for on DATASET5.
- Member A is found, but is not copied to DATASET1 because DATASET1
already has a member named "A", and the replace option is not
specified for member A.
- Selected members not found on DATASET5 are searched for on DATASET6.
- Member B is found and copied to DATASET1, even though there is
already a DATASET1 member "B" in DATASET1, because the replace
option is specified for member B on the member level. The pointer
in DATASET1's directory is changed to point to the new (copied)
member B; thus, the space occupied by the old member B is unused.
- SELECT specifies the members to be selected from the input data
sets (DATASET5 and DATASET6) to be copied to the output data set (DATASET1).