Wednesday, May 27, 2009

7. Reorganizing VSAM datasets

This chapter explains the commands used to back up and restore existing datasets, protect the integrity of data.

REPRO

This command is used to:

• Loads empty VSAM cluster with records.
• Creates backup of a dataset
• Merge data from two VSAM datasets

REPRO command can operate on non-VSAM datasets. It is an all-purpose load and backup utility command and can be used in place of IEBGENER.
With REPRO you can do the following
• Convert an ISAM dataset to VSAM format
• Copy a non-VSAM dataset to a physical sequential or partitioned dataset
• Copy record from one type of VSAM datasets to another. For example KSDS to ESDS

REPRO has following disadvantages:
• Little control over the input data
• Catalog information is not copied with the data
• Prior DELETE and redefinition is required before loading the cluster unless you have specified REUSE in the DEFINE CLUSTER command

Incase of KSDS, data and index component are build automatically.

REPRO Command Syntax

Format :

REPRO
INFILE(ddname) INDATASET(dsname) -
OUTFILE(ddname) OUTDATASET(dsname) -

Optional parameters are :
FROMKEY FROMADDRESS
FROMNUMBER SKIP
TOKEY TOADDRESS
TONUMBER COUNT
INFILE and OUTFILE are required parameters that point to DD1(input file) and DD2 (output file) respectively .
Limiting Input and Output Records:-

While it is not possible to edit the input to REPRO, you can limit the input by providing the optional parameters.

FROMKEY and TOKEY parameters: FROMKEY specifies the key of the input records at which to begin reading. TOKEY specifies the key to stop reading or the last input record.

SKIP and COUNT parameters. SKIP specifies the number of input records to skip before beginning to copy. COUNT specifies the number of output records to copy. You can specify both. For example skip 10 records and copy next 10



//DD1 DD DSN=DA0001T.INPUT.KSDS,DISP=OLD
//DD2 DD DSN=DA0001T.OUTPUT.KSDS, DISP=OLD
//SYSIN DD *
REPRO -
INFILE(DD1) -
OUTFILE(DD2) -
FROMKEY(A001) -
TOKEY(A069)


Example 7.1 JCL for Loading Dataset:


Other parameter for filtering records:

FROMADDRESS (RBA)
TOADDRESS(RBA)
FROMNUMBER (RRN)
TONUMBER(RRN)
COUNT (NO.)
SKIP(NO)
Backing up VSAM Datasets

It is good to backup VSAM datasets on a regular basis.
REPRO command is used to rebuild and restore VSAM cluster from the backup copy.
Backing up a VSAM dataset involves only one step



//JOBNAME DA0001TA…
//STEP10 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT = *
//DD2 DD DSN=DA0001T.KSDS.INV.BACKUP(+1),
// DISP=(NEW,CATLG,DELETE),UNIT=TAPE,
// VOL=SER=32970,LABEL=(1,SL),
// DCB=(RECFM=FB,LRECL=80)
//SYSIN DD *
REPRO
INDATASET(DA0001T.KSDS.INV.CLUSTER) –
OUTFILE(DD2)
/*
//

Example 7.2 Using Repro for backup

In the example above INDATASET is the input file and DD2 is the output tape dataset which is a part of the GDG while is more or less like a physical sequential file. (Ref to chapter 10 for more on GDG’s )


Restoring and rebuilding the backup


DELETE-DEFINE-REPRO sequence required to restore the cluster incase of KSDS.
Delete the original cluster using IDCAMS DELETE command
Redefine the cluster using IDCAMS DEFINE CLUSTER command
Load the empty cluster with data using the IDCAMS REPRO command

When you DELETE-DEFINE-REPRO a VSAM dataset it has the following effects on the KSDS.
• The dataset is reorganized that is the Control Interval and Control Area splits are eliminated
• Free space is redistributed throughout the dataset as specified in the FREESPACE parameter.
• Primary index is rebuilt, however the DELETE command deletes the base cluster as well as its indexes. So the alternate indexes have to be redefined

ESDS or RRDS need not be reorganized because the record position is fixed permanently by sequence of entry or record number.





//DD1 DD DSN=DA0001T.LIB.KSDS.BACKUP(0),
// DISP=OLD, UNIT=TAPE,LABEL=(1,SL)
//SYSIN DD *
DELETE DA0001T.LIB.KSDS.CLUSTER
/* DEFINE CLUSTER NAME(DA0001T.LIB.KSDS.CLUSTER) -
INDEXED -
KEYS(4 0) -
RECORDSIZE(80 80) -
VOLUMES(BS3013) -
) -
DATA(NAME(DA0001T.LIB.KSDS.DATA)) -
INDEX(NAME(DA0001T.LIB.KSDS.INDEX))
REPRO -
INFILE(DD1) -
OUTDATASET(DA0001T.LIB.KSDS.CLUSTER)
/*


Example 7.3 DELETE-DEFINE-REPRO

Merging datasets with REPRO

The REPRO command can also be used to merge two datasets into one. The target dataset can be a nonempty KSDS, ESDS or RRDS. If the target dataset is an ESDS, the merged records are added to the end of the existing dataset.

EXPORT/IMPORT Commands

The EXPORT/IMPORT commands can be used for backup and recovery . You can export a dataset, alternate index or a catalog to a different system.

EMPORT/IMPORT has several advantages as compared to REPRO

Catalog information is exported along with data

Cluster deletion and redefinition not required during import as input dataset already contains catalog information

Easily ported on other systems as catalog information available with data

Like REPRO KSDS datasets are reorganized however three steps of REPRO are replaced by one


Disadvantages:

Exported data cannot be processed until Imported

Can be used only for VSAM dataset

EXPORT

FORMAT :

EXPORT entryname password
OUTFILE(ddname)
OUTDATASET(dsname)

Optional parameters

Example :

EXPORT DA0001T.LIB.KSDS.CLUSTER -
OUTFILE(DD2)


The output dataset from an EXPORT must always
be a sequential dataset (usually on a tape)

IMPORT
Format :

IMPORT -
INFILE(ddname) INDATASET(dsname) -
OUTFILE(ddname) OUTDATASET(dsname) -

Optional parameters:

IMPORT INFILE (DD2) -
OUTDATASET(DA0001T.LIB.KSDS.CLUSTER)


Imports only EXPORTED dataset




//DA0001TA JOB LA1279,PCS,MSGLEVEL=(1,1),
// MSGCLASS=A, NOTIFY=DA0001T
//* Input instream Data into ESDS VSAM Dataset
// STEP1 EXEC PGM=IDCAMS
// SYSPRINT DD SYSOUT = *
// DD1 DD *
123456789123456789
AAAAAAAABBBBBBCCCC
/*
//DD2 DD DSN=DA0001T.ESDS.CLUSTER
//SYSIN DD *
REPRO -
INFILE(DD1) -
OUTFILE(DD2)
/*
//

Example 7.4 Input instream Data into ESDS



//DA0001TA JOB LA2719,PCS,MSGLEVEL= (1,1),
// MSGCLASS=A, NOTIFY=DA0001T
//* Load Data from a file into ESDS VSAM Dataset
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT = *
//DD1 DD DSN=DA0001T.ESDS.CLUSTER1
//DD2 DD DSN=DA0001T.ESDS.CLUSTER2
//SYSIN DD *
REPRO -
INFILE(DD1 -
OUTFILE(DD2)
/*
//

Example 7.5 Load Data from a file into ESDS

Back to VSAM index

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.