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

Module 3: Access Method Services (AMS)


Loading KSDS

  • KSDS can be loaded in two ways:-
    1. In JCL, using REPRO command of IDCAMS
    2. Using COBOL program to read records from input file and write them to output dataset
  • Here, we will focus on loading of KSDS using REPRO
  • REPRO command is explained in ‘IDCAM REPRO command’ article
  • While loading KSDS using REPRO command, make sure all records in input file are sorted in ascending order of field which will be represented as primary key field in KSDS output dataset.
  • When we load KSDS file, make sure all records in input file has records with unique values at key field position. If REPRO finds duplicate key while loading KSDS file, it causes job failure. However, we can code REPLACE parameter which specifies REPRO to replace the duplicate record while loading into KSDS and thus it does not cause job failure

Example 1

Use of REPRO to copy sorted (based on Primary key field) PS file to KSDS file

//PSKSDS EXEC PGM=IDCAMS //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //DD01 DD DSN=PAYT.PAYROLL.PROCESS.SEL,DISP=SHR //DD02 DD DSN=PAYT.PAYROLL.PROCESS.KSDSFILE,DISP=SHR //SYSIN DD * REPRO INFILE(DD01) OUTFILE(DD02) - /*

Example 2

Use of REPRO to copy sorted (based on Primary key field) PS file to KSDS file. But the input file in this case contains records with duplicate keys

Note:- We will use REPLACE parameter here since we do not want Job failure in case if REPRO tries to copy records with duplicate key. REPLACE command will replace the existing record with new record in case of duplicate key

//PSKSDS EXEC PGM=IDCAMS //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //DD01 DD DSN=PAYT.PAYROLL.PROCESS.SEL,DISP=SHR //DD02 DD DSN=PAYT.PAYROLL.PROCESS.KSDSFILE,DISP=SHR //SYSIN DD * REPRO INFILE(DD01) OUTFILE(DD02) - REPLACE /*

Example 3

Use of REPRO to selectively copy records from one KSDS file to another KSDS file

Note:- In this example, key field is of 21 bytes and we have to selectively copy records that falls between two given keys, thus FROMKEY and TOKEY parameter will be coded

//REPKSDS EXEC PGM=IDCAMS //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //DD01 DD DSN=PAYT.PAYROLL.PROCESS.KSDSFL,DISP=SHR //DD02 DD DSN=PAYT.PAYROLL.PROCESS.KSDSFILE,DISP=SHR //SYSIN DD * REPRO INFILE(DD01) OUTFILE(DD02) - FROMKEY(ABC01050673419474C ) - TOKEY(ABC01050673419475C ) /*



Advertisements






© copyright mainframebug.com
Privacy Policy