REPRO Command (for Experienced)


REPRO command is used to copy the data from one file (input) to another file (output).

The input or output datasets can be single or multiple.

REPRO command is used on both VSAM (ESDS, KSDS, RRDS, etc.) and non-VSAM datasets (flat file, PS file, PDS member).

Two or more datasets can concatenate as an input while using the REPRO command.

Functions -


REPRO functions are -

  • Copy the data from one dataset to another.
  • Copies catalogs.
  • Load the empty VSAM cluster with records. While loading, the INDEX builds automatically (applicable to KSDS and VRRDS).
  • Create a backup of a VSAM dataset to VSAM files, PS files, or tapes. Later, those can use to restore/rebuild the VSAM dataset.

Copy notes -


  • A partial copy of a linear dataset is not allowed, and the entire data must be copied.
  • REPRO does not copy the control information of the directories or program libraries.
  • REPRO copies the VSAM recoverable dataset records also.
Notes!
  • No sorting is required/mandatory when loading ESDS.
  • All records should be sorted based on the key-value when loading KSDS.
  • All records should be in the sorted order based on the assumed key field when loading to RRDS.
  • If the logical record length of a non-VSAM dataset is greater than 32760 bytes, the REPRO command ends with an error message.
  • If the VSAM dataset is defined with a record length greater than 32760 and tries to copy the data to a sequential dataset, the REPRO command ends with an error message.

High-level syntax -


//JOBNAME  JOB job-card-parameters
//STEP1    EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  REPRO Command
/*

Detail syntax -


//JOBNAME  JOB job-card-parameters
//STEP1    EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN    DD *
  REPRO {INFILE(ddname)|INDATASET(dataset-name)}
  	{OUTFILE(ddname)| OUTDATASET(dataset-name)}
  	[FILE(ddname)]
  	[FROMKEY(key)|FROMADDRESS(address)|
  	  FROMNUMBER(starting-rrb-number)|SKIP(number)]
  	[REPLACE|NOREPLACE]
  	[REUSE|NOREUSE]
  	[TOKEY(key)|TOADDRESS(address)|
  	  TONUMBER(number)|COUNT(number)]
/*

Parameters


The REPRO command mandatory and optional parameters are specified below -

Mandatory Parameters


INFILE(ddname)


  • Specifies the input dataset to be copied.
  • The input dataset data should be in ascending order based on the key.
  • ddname used to identify the dataset to be copied or the user catalog to be merged.
  • The base cluster can be copied in an alternate-key sequence by specifying a pathname as the dataset name.

Short Description: IFILE

OUTFILE(ddname)


  • Specifies the output dataset where to copy the data.
  • The ddname can be a path for VSAM datasets with AIX.

Short Description: OFILE

INDATASET(dataset-name)


  • Specifies the input dataset to be copied or user catalog to be merged.
  • If INDATASET is specified, the dataset-name specifies the DSN name of the input file.
  • The base cluster can be copied in an alternate-key sequence by specifying a pathname as the dataset name.

Short Description: IDS

OUTDATASET(dataset-name)


  • Specifies the output dataset.
  • If OUTDATASET is specified, the dataset-name specifies the DSN name of the input file.
  • The dataset-name can be a path for VSAM datasets with AIX.

Short Description: ODS

Optional Parameters


FILE(ddname)


  • Specifies the DDnames that identify all the required volumes.
  • If the FILE parameter is not specified, VSAM tries to allocate the required volumes dynamically.

FROMKEY(key)


  • Specify the first record's key from where the copy needs to start.
  • The key can be full or generic (a portion of the key followed by *).
  • The copy begins at the first record that matches the specified key portion if generic keys are specified.
  • If a longer key than the key defined for the dataset, the data is not copied.
  • The copy begins at the following higher key if the specified key is not found.
  • FROMKEY is only used when copying an alternate index, a KSDS, or a catalog.

Short Description: FKEY

TOKEY(key)


  • Specifies the key of the last record where the copy should end.
  • The key can be full or generic (a portion of the key followed by *).
  • The copy ends at the last record that matches the specified key portion if generic keys are specified.
  • If a longer key than the key defined for the dataset, the data is not copied.
  • The copy ends at the following lower key if the specified key is not found.
  • TOKEY is only used when copying an alternate index, a KSDS, or a catalog.

FROMADDRESS(address)


  • Specifies the first record relative byte address (RBA) from where the copy needs to start.
  • The RBA value should be the beginning of a logical record.
  • If FROMADRESS is specified for KSDS, the records are copied in physical order instead of logical order.
  • FROMADDRESS can be coded -
    • Only for KSDS or ESDS.
    • Cannot specify when the dataset is being accessed using the path.
    • Cant specify when KSDS has spanned records.
  • RBA can be specified in decimal (n) or hexadecimal (X'n') format.

Short Description: FADDR

TOADDRESS(address)


  • Specifies the relative byte address (RBA) of the last record where the copy should end.
  • The entire record having the specified RBA is copied.
  • If TOADRESS is specified for KSDS, the records are copied in physical order instead of logical order.
  • TOADDRESS can be coded -
    • Only for KSDS or ESDS.
    • Cannot specify when the dataset is being accessed using the path.
    • Cant specify when KSDS has spanned records.
  • RBA can be specified in decimal (n) or hexadecimal (X'n') format.

Short Description: TADDR

FROMNUMBER(number)


  • Specifies the first record relative record number (RRN) from where the copy needs to start.
  • FROMNUMBER can be specified only when the input dataset is RRDS.
  • RRN can be specified in decimal (n), hexadecimal (X'n'), or binary (B'n') format.

Short Description: FNUM

TONUMBER(number)


  • Specifies the relative record number (RRN) of the last record where the copy should end.
  • TONUMBER can be specified only when the input dataset is RRDS.
  • RRN can be specified in decimal (n), hexadecimal (X'n'), or binary (B'n') format.

Short Description: TNUM

Note!

FROMKEY(key) | FROMADDRESS(address) | FROMNUMBER(number) | SKIP(number) | TOKEY(key) | TOADDRESS(address) | TONUMBER(number) | COUNT(number)

  • If none of the above parameters is coded, the copying begins with the first logical record in the dataset.
  • Only one among four should be coded and did not come up with the other at any point in time.
  • None of these parameters applies to the linear dataset.
  • The starting parameter should be compatible with the ending parameter. For example, if FROMKEY is specified for the starting, TOKEY should specify for the ending.

SKIP(number)


  • Specifies the number of records that need to skip before beginning to copy records. For example, if we want to copy beginning with record number 90, specify SKIP(89).
  • SKIP should not be specified when accessing the dataset through a path.

COUNT(number)


  • Specifies the number of logical records that should copy.
  • COUNT should not use when accessing the dataset through a path; results are unpredictable.

REPLACE


  • Specifies records are replaced in the output dataset if the record key is matched in the input and output datasets. If the record with a matching key is not found, the record gets inserted into the output dataset.
  • For RRDS, a relative record number (RRN) is used instead of a key.
  • REPLACE cannot be used if the output dataset is identified as a path through an alternate index.

Short Description: REP

NOREPLACE


  • Specifies records are not replaced in the output dataset if the record key is matched in the input and output datasets. If the record with a matching key is found, a "duplicate record" message is issued.
  • For RRDS, a relative record number (RRN) is used instead of a key.

Short Description: NREP

REUSE


  • Specifies that the output dataset should be empty to proceed with the copy. i.e., the dataset should be initially defined with REUSE, or the dataset should be empty before the REPRO.
  • This option is valid for VSAM datasets.

Short Description: RUS

NOREUSE


  • Specifies that records are written at the end of the file and valid for ESDS files.
  • This option is valid for VSAM datasets.

Short Description: NRUS

Example -


Requirement - Copy data from KSDS to PS file from E0003 to E0005.

Input ESDS File - MATEPK.TEST.ESDS

Key                                          
<===>----10---+----2----+----3----+----4----+--
****  Top of data  ****                        
E0001EMPLOYEE1     DIR       LOC1 0000100000   
E0002EMPLOYEE2     MGR  DEPT1LOC1 0000080000   
E0003EMPLOYEE3     MGR  DEPT2LOC2 0000075000   
E0004EMPLOYEE4     TL   DEPT1LOC1 0000050000   
E0005EMPLOYEE5     SSE  DEPT1LOC1 0000045000   
E0006EMPLOYEE6     SE   DEPT1LOC1 0000034000   
E0007EMPLOYEE7     SSE  DEPT2LOC2 0000046000   
****  End of data  ****                        

Code -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//MATEPKR JOB (123),'MTH',CLASS=A,MSGCLASS=A,MSGLEVEL=(1,1),            
//             NOTIFY=&SYSUID                                           
//************************************************************          
//* REPRO/COPY DATA FROM VSAM KSDS TO PS DATA SET                       
//************************************************************          
//STEP010  EXEC PGM=IDCAMS                                              
//SYSPRINT DD SYSOUT=*                                                  
//INPUT    DD DSN=MATEPK.EMPL.KSDS,DISP=SHR                             
//OUTPUT   DD DSN=MATEPK.EMPL.PSFILE,                                
//            DISP=(NEW,CATLG,DELETE),                                  
//            SPACE=(TRK,(1,1),RLSE),                                   
//            UNIT=SYSDA,                                               
//            DCB=(DSORG=PS,RECFM=FB,LRECL=47,BLKSIZE=470)              
//SYSIN    DD  *                                                        
  REPRO                -                                                
       INFILE(INPUT)   -                                                
       OUTFILE(OUTPUT) -                                                
       FROMKEY(E0003)  -                                                
       TOKEY(E0005)                                                     
/*                                                                      
//*                                                                     
**************************** Bottom of Data ****************************

In the above JCL, MATEPK is the userid and change it as required.

Output -

Once the above JCL is submitted, check the MAXCC of the job for any errors. If the MAXCC is 00 or 04, then REPRO is successful..

********************************* TOP OF DATA **********************************
IDCAMS  SYSTEM SERVICES                                           TIME: 10:47:50
                                                                                
  REPRO                -                                                        
       INFILE(INPUT)   -                                                        
       OUTFILE(OUTPUT) -                                                        
       FROMKEY(E0003)  -                                                        
       TOKEY(E0005)                                                             
IDC0005I NUMBER OF RECORDS PROCESSED WAS 3                                      
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0                       
                                                                                
IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0               
******************************** BOTTOM OF DATA ********************************

Verify the path in 3.4 (Dataset List utility) or any File management tools.

=COLS> ----+----1----+----2----+----3----+----4----+--                         
****** ***************************** Top of Data ******************************
000001 E0003EMPLOYEE3     MGR  DEPT2LOC2 0000075000                            
000002 E0004EMPLOYEE4     TL   DEPT1LOC1 0000050000                            
000003 E0005EMPLOYEE5     SSE  DEPT1LOC1 0000045000                            
****** **************************** Bottom of Data ****************************

Explaining Example -

In the above example,

  • INFILE(INPUT) specifies the input file.
  • OUTFILE(OUTPUT) specifies the output file.
  • FROMKEY(E0003) specifies starting record to copy.
  • TOKEY(E0003) specifies last record to copy.