Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 3: Access Method Services (AMS)


IDCAMS- REPRO Command

  • REPRO command is used to copy data from one file(Input file) to another file(Output file)
  • Input & Output file can be VSAM dataset (like KSDS, ESDS, RRDS etc.) or non-VSAM dataset (like PS file or a member of PDS).
  • Using REPRO command, we can also merge data from two VSAM datasets
  • Important consideration:-
    • While loading KSDS, make sure all records in input file are sorted in ascending order of field which will be represented as primary key field in output dataset.
    • While loading ESDS, records 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:-

    Syntax format 1:
    REPRO - INFILE(ip-ddName) - OUTFILE(op-ddName) - [optional-paramters]

    Syntax format 2:

    REPRO - INFILE(ip-ddName) - OUTFILE(op-ddName) - [optional-paramters]

  • Where,
    • ip-ddName and op-ddName points to the logical name of the input and output dataset respectively as mentioned in the DD statement of same step.
      Example: //VSAMFL  DD DEPT.VSAM.KSDSFILE,DISP=SHR
      In above statement VSAMFL indicates DDNAME (i.e. logical name of Dataset)
    • ip-datasetName and op-datasetName points to the physical name of the input and output dataset respectively. Ex. DEPT.VSAM.KSDSFILE
    • There are multiple optional parameter can be coded under REPRO command, but we have explained the most frequently used parameters in below.
  • Optional parameters:-
    Parameter Description
    FROMKEY (value-1)
    TOKEY (value-2)
    • Copies all records whose key field value is between value-1 and value-2
    • Input file must be KSDS
    FROMADDRESS (add-value-1)
    TOADDRESS (add-value-2)
    • Copies all records whose address is between add-value-1 and add-value-2
    • Input file must be KSDS or ESDS
    FROMNUMBER (RRN-1)
    TONUMBER (RRN-2)
    • Copies all records whose relative record number(RRN) value is between RRN-1 and RRN-2
    • Input file must be RRDS
    SKIP(n)
    • When SKIP parameter is used, REPRO skips copying of 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 SKIP parameter is coded before COUNT parameter, the count of 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 input file to the output file
    REPLACE | NOREPLACE
    • When REPLACE is coded, It specifies records with duplicate primary keys(for KSDS) and duplicate relative record number (for RRDS) will be replaced
    • NOREPLACE is default and causes job failure when try to copy records with duplicate key

Example 1:-

Use of REPRO to copy PS file to GDG dataset

//KSGDGCP EXEC PGM=IDCAMS //SYSPRINT DD SYSOUT=* //PSFILE DD DSN=PAYT.PAYROLL.PROCESS.MSTR, // DISP=SHR //GDGFILE DD DSN=PAYT.PAYROLL.PROCESS.MSTR.BKUP(+1), // DISP=(NEW,CATLG), // UNIT=TEST,SPACE=(CYL,(10,10),RLSE), // DCB=(MODEL.GDG,RECFM=FB,LRECL=318) //SYSIN DD * REPRO INFILE(PSFILE) OUTFILE(GDGFILE) /*

Example 2:-

Use of REPRO to copy KSDS file to 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) /*

Example 3:-

Use of REPRO to copy KSDS file records at row position 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) /*

For more examples refer articles ‘Loading a KSDS’, ‘Loading a ESDS’ and ‘‘Loading a RRDS’






© copyright mainframebug.com
Privacy Policy