Thursday, February 28, 2013

JCL to Extract first N number of records from a File

We can use the ENDREC parameter to get the first 1000 records from a file and copy it to another file. The Sample JCL is as follows :--

//JOBCARD
//STEP01   EXEC  PGM=SORT                                 
//SYSOUT   DD    SYSOUT=*                                 
//SYSPRINT DD    SYSOUT=*                                 
//SORTIN   DD    DSN=<INPUT FILE>,           
//         DISP=SHR                                       
//SORTOUT  DD    DSN=<OUTPUT FILE>,                  
//         DISP=SHR                                       
//SYSIN    DD    *                                         
  SORT FIELDS=COPY                                         
  OUTFIL FILES=OUT,ENDREC=1000                             
/*                                                         

We can give any value in the ENDREC field. Depending on the value, the extraction will happen from the input file.

No comments:

Post a Comment