Thursday, February 5, 2015

Copy members of PDS using IEBPTPCH

This JCL will copy the members of the PDS into a PS file with the help of IEBPTPCH

//STEPNAME EXEC PGM=IEBPTPCH                 
//SYSPRINT DD SYSOUT=*                       
//SYSUT1   DD DSN=TEST.PDS1,DISP=SHR  
//SYSUT2   DD DSN=TEST.PS1,          
//     DISP=(NEW,CATLG),                     
//     SPACE=(CYL,(50,50,)),                 
//     DCB=(RECFM=FB,LRECL=133,BLKSIZE=1330),
//     UNIT=WORK                             
//SYSIN    DD *                              
    PUNCH TYPORG=PO                          

Tuesday, February 3, 2015

Sort JCL to split every alternate records

 This JCL will split the even and the odd number of records from the input file.

//STEP01   EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTWK01  DD UNIT=DISK,SPACE=(CYL,(100,100))       
//SORTIN    DD *                                     
1111111111111111111111111                            
2222222222222222222222222                            
3333333333333333333333333                            
4444444444444444444444444                            
5555555555555555555555555                            
6666666666666666666666666                            
//ODD       DD DSN=TEST.ODD.OP1,
//          DISP=(,CATLG),UNIT=TEST,                 
//          SPACE=(CYL,(50,50),RLSE)                 
//EVEN       DD DSN=TEST.EVEN.OP2,
//          DISP=(,CATLG),UNIT=TEST,                 
//          SPACE=(CYL,(50,50),RLSE)                 
//SYSIN     DD *                                     
  SORT FIELDS=COPY                                   
  OUTFIL FNAMES=(ODD,EVEN),SPLIT                     
//*   

Here is the output of the ODD file:

******************************
1111111111111111111111111    
3333333333333333333333333    
5555555555555555555555555    
******************************

Here is the output of the EVEN  file:

**************************
2222222222222222222222222
4444444444444444444444444
6666666666666666666666666
**************************
SPLIT parameter to put the first record into OUTPUT1, the second record into OUTPUT2, the third record into OUTPUT1, the fourth record into OUTPUT2, and so on until you run out of records. SPLIT splits the records one at a time among the data sets specified by FNAMES.
Other options SPLITBY and SPLIT1R are also available. Do check out the usage for further info.