REPRO command.


REPRO Command

·        After we create the Clusters we can use them in our programs to load them. However we might need to load them initially from some PS datasets . This can be done using REPRO command.

·        We can even copy normal files using REPRO command.

·        Syntax:
REPRO {INFILE(ddname[/password]
                   [ ENVIRONMENT(DUMMY)])  |
               INDATASET(entryname[/password]
                   [ ENVIRONMENT(DUMMY)])}

    {OUTFILE(ddname[/password])  |
      OUTDATASET(entryname[/password])}

    [FROMKEY(key)  |  FROMADDRESS(address)  |
     FROMNUMBER(number)  |  SKIP(count)]

    [REPLACE  |  NOREPLACE]

    [REUSE  |  NOREUSE]

    [TOKEY(key)  |  TOADDRESS(address)  |
     TONUMBER(number)  |  COUNT(count)] 

·        Following is the meaning of each of the datasets.

·        INFILE and INDATASET:
The input may be specified by either the INFILE parameter or the INDATASET parameter.  When INFILE is used, the records are read from the DD name specified, and a DD statement must be supplied in the JCL matching the specified name.  When INDATASET is used Actual File name has to be put.

·        OUTFILE and OUTDATASET:
The VSAM cluster to receive the records read from the input dataset is specified by either OUTFILE or OUTDATASET.  OUTFILE designates that the target cluster is specified by the inclusion of a DD statement in the JCL, while OUTDATASET designates the actual file names.

·        FROMKEY: Note that they should be mentioned inside brackets. Applicable for KSDS clusters.
Indicates the key value from where the copy operation should begin.

·        FROMADDRESS:
Applicable for ESDS datasets. Used to specify the RBA value that defines the starting point of the copy operation.

·        FROMNUMBER: Applicable for RRDS datasets. Used to specify the relative record number that defines the starting point of the copy operation. 

·        SKIP:
SKIP may be included to bypass the specified number of records from the input dataset before starting the copy operation.

·        REPLACE
REPLACE may be specified to cause existing records in the output cluster to be replaced when a duplicate record is read from the input dataset.  REPLACE is applicable for KSDS and RRDS clusters.  REPLACE may also be used to merge input from subsequent REPRO operations with different input datasets to the same target dataset, where the possibility of duplicate records.  If an attempt is made to add a duplicate record and REPLACE is not specified, an error message and the input record is discarded; on the fourth occurrence of a duplicate record, the REPRO operation is terminated and the remainder of the input file is not processed.

·        REUSE
Resetting the Output Cluster to Empty
The REUSE parameter may be specified to cause the output cluster to be reset to empty status before loading commences.  In order for the REUSE parameter to be allowable, the output cluster must have been defined with the REUSE attribute

·        TOKEY: TOKEY is only applicable when the output cluster is a KSDS VSAM cluster. Used to determine the key value that defines the ending point of the copy operation. 

·        TOADDRESS: TOADDRESS is only applicable when the output dataset is a KSDS or ESDS VSAM cluster.  Defines the ending point of the copy operation.

·        TONUMBER: TONUMBER is only applicable when the output dataset is a RRDS VSAM cluster. Used to specify the relative record number that defines the ending point of the copy operation. 

Example 1: Copying data to KSDS cluster:
***************************** Top of Data ******************************
//JOB00006 JOB (XXXX),'ACCESS METHOD',NOTIFY=SYSUID                    
//STEP0001 EXEC PGM=IDCAMS                                             
//SYSPRINT DD   SYSOUT=*                                               
//INDATA1  DD *                                                        
 1SUKUL IS GREAT                                                       
 2SUKUL IS VERY GREAT                                                  
 3SUKUL IS THE GREAT                                                   
/*                                                                      
//SYSIN    DD *                                                        
 DELETE SM017R.TEST.VSAM1 CLUSTER PURGE                                
 /* ABOVE DELETES IF THE KSDS EXISTS */                                
 DEFINE CLUSTER(                    -                                  
       NAME (SM017R.TEST.VSAM1)      -                                 
       TRK  (1 1)                    -                                 
       INDEXED                       -                                  
       KEYS (1 1)                    -                                 
       RECORDSIZE (80 80))                                             
 IF LASTCC=0 THEN                    -                                 
     REPRO INFILE(INDATA1)           -                                 
     OUTDATASET(SM017R.TEST.VSAM1)                                     
/*                                                                     

IN the above example INstream data is copied to a KSDS cluster .
The numbers 1.2 and 3 are the keys of those records. They should be in sorted order for KSDS file to accept it.

The contents of the KSDS cluster can be checked using fileaid and below are the contents:
COMMAND ===>                                                  SCROLL
FA223- Records read = 3, selected = 3, error records skipped = 0    
 1 SUKUL IS GREAT                                                   
 2 SUKUL IS VERY GREAT                                              
 3 SUKUL IS THE GREAT                                               
******************************* BOTTOM OF DATA ********************-C
This indicates that all data was copied properly to the KSDS cluster.

Example 2: Copy data from KSDS to an Entry sequenced cluster:

***************************** Top of Data *********************
//JOB00007 JOB (XXXX),'ACCESS METHOD',NOTIFY=SYSUID           
//STEP0001 EXEC PGM=IDCAMS                                    
//SYSPRINT DD   SYSOUT=*                                      
//SYSIN    DD *                                               
 DELETE SM017R.TEST.VSAM2 CLUSTER PURGE                       
 /* ABOVE DELETES IF THE KSDS EXISTS */                       
 DEFINE CLUSTER(                    -                         
       NAME (SM017R.TEST.VSAM2)      -                        
       NONINDEXED                       -                     
       RECORDSIZE (80 80))                                    
 IF LASTCC=0 THEN                    -                        
     REPRO INDATASET(SM017R.TEST.VSAM1)           -           
     OUTDATASET(SM017R.TEST.VSAM2)      -                     
     FROMKEY(2) TOKEY (2)                                     
/*                                                            
**************************** Bottom of Data *******************
In the Above example we copy data from KSDS cluster that we previously created to an ESDS cluster that we created in this job.
Note that we are mentioning FROMKEY = 2 and TOKEY =2 which indicates that only 1 record should get copied.
Note that the key number should be mentioned in brackets.

We can view the data in ESDS file using fileaid:
COMMAND ===>                                                  SCROLL
FA223- Records read = 1, selected = 1, error records skipped = 0   
2SUKUL IS VERY GREAT                                               
******************************* BOTTOM OF DATA ********************-
This shows that one record is correctly copied.

REPRO can also be used to backup DASD datasets to Tape.
Example3 : Backing up a dataset to TAPE
//REPRO03  JOB 'JAY MOSELEY',CLASS=A,MSGLEVEL=(1,1),MSGCLASS=A
//*                                                           
//************************************************************
//* CREATE A SEQUENTIAL BACKUP OF AN ESDS                     
//************************************************************
//*                                                           
//IDCAMS  EXEC PGM=IDCAMS,REGION=4096K                        
//TIMECLOK DD  DSN=PAYROLL.TIMECLOK.FILE,DISP=SHR             
//BACKUP   DD  DSN=BACKUP.TIMECLOK,UNIT=TAPE,DISP=(NEW,KEEP), 
//             VOL=SER=B00001,                                
//             DCB=(RECFM=FB,LRECL=22,BLKSIZE=2200)           
//SYSPRINT DD  SYSOUT=A                                       
//SYSIN    DD  *                                              
                                                              
  REPRO INFILE(TIMECLOK)                                    - 
        OUTFILE(BACKUP)                                       
                                                              
/*             

Restoring from Backup id  identical to the process used to load VSAM clusters with REPRO.  Unless the cluster is defined with the REUSE attribute, it is necessary to first delete and then redefine the cluster in order to remove the existing records that will be replaced with those from the backup. IF REUSE attribute was specified while creating the KSDS then it will automatically delete the existing data and start reusing it.

No comments:

Post a Comment