Command of IDCAMS Repro - : Copying A Data Set Note
Command of IDCAMS Repro - : Copying A Data Set Note
REPRO –
Copying A Data Set
Note
The CFILE utility, which was used to copy sequential and ISAM data sets, is not supported.
Neither are ISAM data sets. All users with ISAM data sets should convert them to VSAM.
This document describes how to use IDCAMS/REPRO to copy a data set. It is intended as a
replacement for CFILE and is not intended as complete documentation on VSAM data sets or
the IDCAMS utility. For detailed information on IDCAMS and using VSAM data sets, see the
documentation section below.
IDCAMS is an IBM utility that allows you to create and manipulate VSAM data sets. It has
several commands. You can use the REPRO command of IDCAMS to copy VSAM and non-
VSAM data sets, VSAM clusters, and alternate indexes.
You cannot use REPRO to copy an entire partitioned data set (PDS) because REPRO does not
copy the information in the directories. You can, however, use REPRO to copy individual
members.
Parameters may be separated by either commas or blanks. You can continue the REPRO
statement by coding a hyphen (-) as the last character of a line. The command and parameters
may be typed anywhere betweeen columns 2-72.
Figure 18 shows the JCL for a basic job setup to access IDCAMS. The INFILE parameter names
the DD statement for the data set that is to be copied. The OUTFILE parameter names the DD
statement describing the output or target data set. You would replace "indd" and "outdd" with
DD names of your own choosing.
Figure 17. JCL to Use IDCAMS and the REPRO Command
REPRO Examples
Figure 19 shows how to use REPRO to copy a VSAM data set to a sequential data set. You could
use this to make a sequential backup copy of your VSAM data set. In this example, assume that
your VSAM data set has variable-length records. The maximum record size is 100 bytes and you
have embedded keys. When you specify your LRECL and BLKSIZE for your output data set,
make sure they are at least 4 bytes longer than the longest record in your VSAM data set.
Figure 20 shows an example of using REPRO to make a VSAM backup of your original VSAM
data set. This example assumes that you have already created the backup data set (using
IDCAMS). The OLD DD name defines your original VSAM data set. The NEW DD name defines
the output data set.
Suppose you want only to make a backup of part of your data set. You can use the SKIP(n) and
COUNT(m) keywords on the REPRO command to delimit the records to be copied. The following
form of the REPRO command would copy the input data set beginning with the 100th record and
copy 500 records.
REPRO -
INFILE(VSAM) -
OUTFILE(SEQ) -
SKIP(99) -
COUNT(500)
You can create an alternate index over an existing KSDS by using IDCAMS using JCL. If
the data set already has an alternate index that is defined, it is erased and then redefined.
After the alternate index is built, SAS is invoked to read the data set using the alternate
index and to write the records to the procedure output file.
/*
//*
//* Invoke SAS to read the data set via the alternate index
//* defined in STEP1.
//*
//STEP2 EXEC SAS,PARM=' VSAMREAD '
//SYSUDUMP DD SYSOUT=A
//PATH DD DISP=SHR,DSN=dsname.KSDS.STUDENT.PATH
//SYSIN DD *
/* Read the KSDS via the alternate key. Write the records
*/
/* to the procedure output file, putting the observation
number */
/* before each observation.
*/
data one;
infile path;
input;
file print;
put _n_ @5 _infile_;
/*
//
To access the data set by the alternate index, you must have a DD statement that
references the data set name in the DEFINE PATH statement. Also note that the STEP2
EXEC statement that invokes SAS specifies the SAS system option VSAMREAD, which is
needed only if your installation's default value for this option is NOVSAMREAD.
The AMS RECORDSIZE parameter requires the average and maximum record size, in
bytes, of the alternate index record. When you calculate the maximum record size, if the
alternate index record spans control intervals, the RECORDSIZE parameter can be larger
than the CONTROLINTERVALSIZE. Use the following formula to calculate the maximum
record size of spanned records:
MAXLRECL is the maximum spanned record size. CI/CA represents the number of control
intervals per control area. CA is the number of control areas. CISZ is the quantity control
interval size.
Use the following formulas to determine the average size of the alternate index record when
the alternate index supports ESDS or KSDS.
ESDS:
RECSZ= 5 + AIXKL + (n x 4)
KSDS:
RECSZ= 5 + AIXKL + (n x BCKL)
In the preceding examples, the average record size for alternate key STATE was calculated
as follows:
Specifying the same value for average and maximum identifies the records as fixed length.
See IBM documentation for more information on calculating record size.
Sequential Access
In all three cases, a record is located by its position relative to the last record accessed.
Direct Access
With direct access, data storage or retrieval depends only on the location of the record and
not on a reference to records previously accessed. Each record is stored or retrieved
directly, according to its logical address (its key or its relative-record number, or RRN), or
its address relative to the beginning of the data set (relative-byte address, or RBA). Thus,
there are two direct access modes: keyed by key or relative-record number, and
addressed by relative-byte address.
In keyed direct access, there are two methods in which records are retrieved or stored:
SAS supports keyed access to logical records in both KSDS and RRDS data sets. Keyed
access to data records in KSDS data sets is by key; in RRDS data sets, keyed access is by
the relative-record number.
In addressed direct access, the entire data set is treated as a continuous stream of bytes. A
record is retrieved and stored directly by its address relative to the beginning of the data set
(relative-byte address, or RBA), which is dependent on the record's location relative to
records previously accessed. SAS supports addressed access to logical records in ESDS
and KSDS data sets. It also supports addressed access (read-only) to control intervals in all
three data set types.
An alternate key index, commonly called an alternate index (AIX), provides another way to
access a VSAM data set. The advantage of an alternate index is that you effectively
reorganize the data set instead of keeping separate copies organized in different ways for
different applications. Suppose you have a KSDS with the employee number as the prime
key. By building alternate indexes using employee names and department numbers, you
can access the same data set in three ways: by employee name, by employee number, or
by department number. The alternate key does not have to be unique; that is, there can be
more than one record with the same alternate key.
The following figure illustrates an alternate index with nonunique keys over a KSDS. The
base cluster records are sequenced by employee number, which is the prime key. The
alternate index records are sequenced by department number, which is the alternate key.
Each alternate index data record points to the prime key (employee number) in the base
cluster. Note that because the alternate keys are nonunique, there can be multiple base
records with the same department number.
A path logically relates a base cluster and one of its alternate indexes. You define and
name a path to access the base cluster records through a specific alternate index with
AMS. See Using Alternate Indexes for VSAM Data Sets and IBM documentation for more
information on defining alternate indexes.
A combination of both direct and sequential access can be used in a two-step process
called skip sequential access. The process uses keyed direct access to find a starting point.
After the initial record is obtained, additional records are retrieved sequentially. Skip
sequential processing can be used with a KSDS, RRDS, and, if it has an alternate index, an
ESDS.
Skip sequential processing is useful for the following reasons:
It enables you to find records when you know the key, RBA,
or RRN of the first record you want, but do not know the key,
RBA, or RRN of the subsequent records.