JCL

VSAM REPRO using IDCAMS with Examples

VSAM REPRO command is used to copy data from one file(Input file) to another file(Output file). Input & Output files can be VSAM datasets (like KSDS, ESDS, RRDS, etc.) or a non-VSAM dataset (like PS file or a member of PDS).

A few critical functionalities of REPRO are

  • It is used to copy data from one dataset (input VSAM/NON-VSAM file) to another dataset (output VSAM/NON-VSAM file).
  • It is used to load empty VSAM clusters along with building the data and index components for KSDS.
  • It is used to create a backup of a VSAM dataset in PS dataset.
  • It can be used to merge data from two VSAM datasets

VSAM REPRO Important consideration

  • While loading KSDS, make sure all records in the input file are sorted in ascending order of field which will be represented as the primary key field in the output dataset.
  • While loading ESDS, record sorting is not mandatory.
  • While loading RRDS, records can be sorted on the field that correlates to the relative record number. During RRDS load, the records are loaded in relative record sequence starting with 1.

Syntax

REPRO {INFILE(ip-ddname[/password]  OR    
      INDATASET(ip-entryname[/password]         
      {OUTFILE(op-ddname[/password])]  OR       
       OUTDATASET(op-entryname[/password])}
******[optional-paramters]  ************    
      [FROMKEY(key)]FROMADDRESS(address)]     
       FROMNUMBER(number)]SKIP(count)]      
      [REPLACE]NOREPLACE]           
      [REUSE]NOREUSE]                  
      [TOKEY(key)]TOADDRESS(address)]              
       TONUMBER(number)]COUNT(count)]

ip/op-ddname – It points to the logical name of the input and output dataset respectively as mentioned in the DD statement of the same step.
Example: //VSAMFL      DD DSN=XXXXXXX.YYYYYYYY.CUSTOMER.KSDS.CLUSTER,DISP=SHR   
In the above statement, VSAMFL indicates DDNAME (i.e. logical name of Dataset)

ip/op-entryname – It points to the physical name of the input and output dataset respectively. Ex. XXXXXXX.YYYYYYYY.CUSTOMER.KSDS.CLUSTER

There are multiple optional parameters that can be coded under the REPRO command, below are the most frequently used parameters below

ParameterDescription
FROMKEY (value-1) TOKEY (value-2)It may be included to specify either the full or generic key value that defines the starting and ending point of the copy operation.  Copies all records whose key field value is between value-1 specified in FROMKEY and value-2 specified in TOKEY.  The input file must be KSDS
FROMADDRESS (add-value-1) TOADDRESS (add-value-2)It may be included to specify the RBA value that defines the starting and ending point of the copy operation.  Copies all records whose address is between add-value-1 specified in FROMADDRESS  and add-value-2 specified in TOADDRESS. The input file must be KSDS or ESDS
FROMNUMBER (RRN-1) TONUMBER (RRN-2)It may be included to specify the relative record number that defines the starting and ending point of the copy operation. Copies all records whose relative record number(RRN) value is between RRN-1  specified in FROMNUMBER and RRN-2 specified in TONUMBER. The input file must be RRDS
SKIP(n)It may be included to bypass the specified number of records from the input dataset before starting the copy operation. When the SKIP parameter is used, REPRO skips copying the n number of records from the start of the file.
COUNT(n)COUNT parameter is used to specify that only n number of records are to be copied from the input file to the output file When the SKIP parameter is coded before the COUNT parameter, the count of the number of records to copy starts right after the number of records skipped i.e. if “ SKIP(5) COUNT(10) “ is coded, then only records at position 6 to 15 will be copied from the input file to the output file
REPLACE | NOREPLACEWhen REPLACE is coded, It specifies records with duplicate primary keys(for KSDS) and duplicate relative record numbers (for RRDS) will be replaced NOREPLACE is default and causes job failure when trying to copy records with a duplicate key

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.

Resetting the Output Cluster to Empty:

The REUSE parameter may be specified to cause the output cluster to be reset to the 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.

Example: Use of REPRO to copy PS file to GDG dataset.

//PSTOGDG JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//******************************************************           
//*SAMPLE JCL REPRO/COPY DATA FROM PS TO GDG USING REPRO
//******************************************************           
//STEPOZA  EXEC  PGM=IDCAMS                             
//SYSPRINT DD  SYSOUT=*                                 
//PSFILE   DD  DSN=XXXXXXX.YYYYYYYY.CUSTOMER.INPUT,         
//             DISP=SHR                                 
//GDGFILE  DD  DSN=XXXXXXX.YYYYYYYY.CUSTOMER.BKUP(+1),
//             DISP=(NEW,CATLG,DELETE),                        
//             UNIT=TEST,SPACE=(CYL,(10,10),RLSE),      
//             DCB=(MODEL.GDG,RECFM=FB,LRECL=80)       
//SYSIN    DD  *                                        
   REPRO INFILE(PSFILE) OUTFILE(GDGFILE)               
/* 

Example: Use of REPRO to copy KSDS VSAM to GDG dataset.

//KSTOGDG JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//*********************************************************           
//*SAMPLE JCL REPRO/COPY DATA FROM KSDS TO GDG USING REPRO
//*********************************************************    
//KSDSGDG  EXEC  PGM=IDCAMS                              
//SYSPRINT DD  SYSOUT=*                                  
//KSDSFILE DD  DSN=XXXXXXX.YYYYYYYY.CUSTOMER.KEYFILE,         
//             DISP=SHR                                  
//GDGFILE  DD  DSN=XXXXXXX.YYYYYYYY.CUSTOMER.KEYFILE.BKUP(+1),
//             DISP=(NEW,CATLG,DELETE),                         
//             UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE),      
//             DCB=(MODEL.GDG,RECFM=FB,LRECL=80)        
//SYSIN    DD  *                                         
 REPRO INFILE(KSDSFILE) OUTFILE(GDGFILE)                   
/*

Example: Use of REPRO to copy KSDS file records at row positions 6 to 15 to the output GDG dataset.

//KSDSGDG  EXEC  PGM=IDCAMS                              
//SYSPRINT DD  SYSOUT=*                                  
//KSDSFILE DD  DSN=PAYT.PAYROLL.PROCESS.KEYFILE,         
//             DISP=SHR                                  
//GDGFILE  DD  DSN=PAYT.PAYROLL.PROCESS.KEYFILE.BKUP(+1),
//             DISP=(NEW,CATLG),                         
//             UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE),      
//             DCB=(MODEL.GDG,RECFM=FB,LRECL=325)        
//SYSIN    DD  *                                         
 REPRO INFILE(KSDSFILE) OUTFILE(GDGFILE) -
 SKIP(5) COUNT(10)       
/*

Example: Use of REPRO to copy PS file to VSAM dataset.

//PSTOVSAM JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//*************************************************************
//*SAMPLE JCL REPRO/COPY DATA FROM PS TO VSAM KSDS USING REPRO
//*************************************************************
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//SYSIN    DD  *                                                  
  REPRO -                                                          
  INDATASET(XXXXXXX.YYYYYYYY.CUSTOMER.INPUT) -                        
  OUTDATASET(XXXXXXX.YYYYYYYY.CUSTOMER.KSDS.CLUSTER) -                 
  SKIP(3) -                                                         
  COUNT(3)                                                      
/* 

Example: Use of REPRO to copy VSAM to PS file.

//KSDSTOPS JOB (1234),'INDUS',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),
//             NOTIFY=&SYSUID,REGION=6M                         
//*************************************************************
//* SAMPLE JCL REPRO/COPY DATA FROM VSAM KSDS TO PS USING REPRO
//*************************************************************
//STEPOZA  EXEC PGM=IDCAMS                                      
//SYSPRINT DD SYSOUT=*                                          
//SYSOUT   DD SYSOUT=*                                          
//DD1      DD DSN=XXXXXXX.YYYYYYYY.CUSTOMER.KSDS.CLUSTER,DISP=SHR    
//DD2      DD DSN=XXXXXXX.YYYYYYYY.CUSTOMER.OUTPUT,             
//            DISP=(NEW,CATLG,DELETE),                          
//            SPACE=(TRK,(1,1),RLSE),                           
//            UNIT=SYSDA,                                       
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=0)      
//SYSIN    DD  *                                                  
  REPRO -                                                         
  INFILE(DD1) -                                                   
  OUTFILE(DD2) -                                                  
  FROMKEY(4444) -                                                    
  TOKEY(5555)                                                   
/* 

VSAM Tutorials

VSAM Define Cluster: Click Here IBM Reference : Click Here

Admin

Share
Published by
Admin

Recent Posts

Increase Transparency and Collaboration Product Backlog

A well-maintained product backlog is crucial for successful product development. It serves as a single…

4 days ago

Product Backlog – Incremental value to the customer

Incremental value to the customer refers to the gradual delivery of small, functional parts of…

6 days ago

Product Market, Customer’s Desire, Need, and Challenges

A Product Market refers to the group of potential customers who might be interested in…

1 week ago

PAL-EBM Professional Agile Leadership – EBM Certification

The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…

3 months ago

PAL I Professional Agile Leadership Certification

The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…

4 months ago

Scrum Master Certification: CSM, PSM, SSM

Choosing the right Scrum Master Certification depends on your current experience and career goals. If…

5 months ago