Saturday, 20 December 2014

Difference between split ,splitby and split1R used in sort

There are many different ways to split a datasets into different datasets.

Split, Splitby and Split1R are two of the ways to split a dataset a jcl.

The below jcl and the result will be able to make us understand the difference between split ,splitby and Split1R.

Usage of Split:

Split is going to get the even records in one dataset and the odd records in another i.e. first line copied to first dataset, 2nd line copied to second dataset, then 3rd line copied to third dataset and so on..

JCL for Split:

//NUMHP53A JOB ,'SPLIT',MSGCLASS=Q,MSGLEVEL=(1,1),NOTIFY=&SYSUID    
//STEP01         EXEC PGM=SORT                                            
//SORTIN        DD DSN=NUMHP53.MAITREE.DATA9,                            
//                      DISP=SHR                                               
//SORTOUT1 DD DSN=NUMHP53.MAITREE.DATA91,                           
//                      DISP=(MOD,CATLG,DELETE),                                 
//                      UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),                       
//                      DCB=(*.SORTIN)                                           
//SORTOUT2 DD DSN=NUMHP53.MAITREE.DATA92,                           
//                      DISP=(MOD,CATLG,DELETE),                                 
//                      UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),                        
//                      DCB=(*.SORTIN)                                           
//SYSOUT      DD SYSOUT=*                                              
//SYSIN          DD *                                                     
                       OPTION COPY                                                     
                       OUTFILE FNAMES=(SORTOUT1,SORTOUT2),SPLIT                       
/* 
//*

Input dataset:
VIEW       NUMHP53.MAITREE.DATA9                           Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 This is the 1st   line                                                 
000002 This is the 2nd   line                                                 
000003 This is the 3rd   line                                                 
000004 This is the 4th   line                                                 
000005 This is the 5th   line                                                 
000006 This is the 6th   line                                                 
000007 This is the 7th   line                                                 
000008 This is the 8th   line                                                 
000009 This is the 9th   line                                                 
000010 This is the 10th  line                                                 
000011 This is the 11th  line                                                 
****** **************************** Bottom of Data ****************************

Output Datasets:
VIEW       NUMHP53.MAITREE.DATA91                          Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 This is the 1st   line                                                 
000002 This is the 3rd   line                                                 
000003 This is the 5th   line                                                  
000004 This is the 7th   line                                                 
000005 This is the 9th   line                                                 
000006 This is the 11th  line                                                  
****** **************************** Bottom of Data ****************************
                                                                              
VIEW       NUMHP53.MAITREE.DATA92                          Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 This is the 2nd   line                                                 
000002 This is the 4th   line                                                 
000003 This is the 6th   line                                                 
000004 This is the 8th   line                                                 
000005 This is the 10th  line                                                  
****** **************************** Bottom of Data ****************************


Usage of Splitby:

Splitby splits the input dataset by the number we want it to. 

In the below example I have used a single dataset to be splited by 4.

The first four records are copied into 1st dataset, fifth to eighth record are copied to 2nd dataset, then again the ninth to eleventh records are copied into the 1st dataset. 

JCL for Splitby:


//NUMHP53A JOB ,'SPLIT',MSGCLASS=Q,MSGLEVEL=(1,1),NOTIFY=&SYSUID  
//STEP01   EXEC PGM=SORT                                          
//SORTIN   DD DSN=NUMHP53.MAITREE.DATA9,                          
//            DISP=SHR                                            
//SORTOUT1 DD DSN=NUMHP53.MAITREE.DATA91,                         
//         DISP=(NEW,CATLG,DELETE),                                
//         UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),                     
//         DCB=(*.SORTIN)                                         
//SORTOUT2 DD DSN=NUMHP53.MAITREE.DATA92,                         
//         DISP=(NEW,CATLG,DELETE),                                
//         UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),                     
//         DCB=(*.SORTIN)                                         
//SYSOUT   DD SYSOUT=*                                            
//SYSIN    DD *                                                   
     OPTION COPY                                                  
     OUTFILE FNAMES=(SORTOUT1,SORTOUT2),SPLITBY=4                 
/*                                                                 
//*

Input dataset:
VIEW       NUMHP53.MAITREE.DATA9                           Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 This is the 1st   line                                                 
000002 This is the 2nd   line                                                 
000003 This is the 3rd   line                                                 
000004 This is the 4th   line                                                 
000005 This is the 5th   line                                                 
000006 This is the 6th   line                                                 
000007 This is the 7th   line                                                 
000008 This is the 8th   line                                                 
000009 This is the 9th   line                                                 
000010 This is the 10th  line                                                 
000011 This is the 11th  line                                                 
****** **************************** Bottom of Data ****************************

Output dataset:
VIEW       NUMHP53.MAITREE.DATA91                          Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 This is the 1st   line                                                 
000002 This is the 2nd   line                                                 
000003 This is the 3rd   line                                                 
000004 This is the 4th   line                                                 
000005 This is the 9th   line                                                 
000006 This is the 10th  line                                                 
000007 This is the 11th  line                                                 
****** **************************** Bottom of Data ****************************

VIEW       NUMHP53.MAITREE.DATA92                          Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 This is the 5th   line                                                 
000002 This is the 6th   line                                                  
000003 This is the 7th   line                                                 
000004 This is the 8th   line                                                 
****** **************************** Bottom of Data ****************************

Usage of SPLIT1R:

SPLIT1R should be the safest way to split a dataset into number of datasets as it does not carry out the rotation. 

In the below example, I have used SPLIT1R=4 and as a result, the first 4 records are copied to 1st dataset and the remaining records are copied into the second dataset. 

JCL for SPLIT1R:


//NUMHP53A JOB ,'SPLIT',MSGCLASS=Q,MSGLEVEL=(1,1),NOTIFY=&SYSUID 
//STEP01        EXEC PGM=SORT                                         
//SORTIN       DD DSN=NUMHP53.MAITREE.DATA9,                         
//                    DISP=SHR                                            
//SORTOUT1 DD DSN=NUMHP53.MAITREE.DATA91,                        
//                   DISP=(NEW,CATLG,DELETE),                              
//                   UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),                    
//                   DCB=(*.SORTIN)                                        
//SORTOUT2 DD DSN=NUMHP53.MAITREE.DATA92,                        
//                   DISP=(NEW,CATLG,DELETE),                              
//                   UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),                     
//                   DCB=(*.SORTIN)                                        
//SYSOUT     DD SYSOUT=*                                           
//SYSIN        DD *                                                  
     OPTION COPY                                                  
     OUTFILE FNAMES=(SORTOUT1,SORTOUT2),SPLIT1R=4                
/*                                                               
//*

Input dataset:

VIEW       NUMHP53.MAITREE.DATA9                           Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 This is the 1st   line                                                 
000002 This is the 2nd   line                                                 
000003 This is the 3rd   line                                                 
000004 This is the 4th   line                                                 
000005 This is the 5th   line                                                 
000006 This is the 6th   line                                                 
000007 This is the 7th   line                                                 
000008 This is the 8th   line                                                 
000009 This is the 9th   line                                                 
000010 This is the 10th  line                                                 
000011 This is the 11th  line                                                 
****** **************************** Bottom of Data ****************************

Output Datasets:

VIEW       NUMHP53.MAITREE.DATA91                          Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 This is the 1st   line                                                 
000002 This is the 2nd   line                                                  
000003 This is the 3rd   line                                                 
000004 This is the 4th   line                                                 
****** **************************** Bottom of Data ****************************
                                                                              

VIEW       NUMHP53.MAITREE.DATA92                          Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 This is the 5th   line                                                 
000002 This is the 6th   line                                                  
000003 This is the 7th   line                                                 
000004 This is the 8th   line                                                 
000005 This is the 9th   line                                                 
000006 This is the 10th  line                                                 
000007 This is the 11th  line                                                 
****** **************************** Bottom of Data ****************************


What happens when we put a comment line before the job card

I remember once being asked a question that what happens when we put a comment line before a job card. I was unable to answer the question for the fact that I had never tried this. :D

I had an idea to document the result:

The answer is it will always ask for the job name characters.

I have used the spool job from my last post as below:

SDSF EDIT    NUMHP53A (JOB31500) JCLEDIT                   Columns 00001 00072
Command ===>   sub;;                                          Scroll ===> PAGE
****** ***************************** Top of Data ******************************
000001 //*COMMENTLINE                                                         
000002 //NUMHP53A JOB ,'SYNC',MSGCLASS=Q,MSGLEVEL=(1,1),NOTIFY=&SYSUID        
000003 //STEP01         EXEC PGM=SORT                                               
000004 //SORTIN        DD DSN=NUMHP53.MAITREE.DATA1,                               
000005 //                     DISP=SHR                                                  
000006 //                     DD DSN=NUMHP53.MAITREE.DATA2,                               
000007 //                     DISP=SHR                                                 
000008 //                     DD DSN=NUMHP53.MAITREE.DATA3,                               
000009 //                    DISP=SHR                                                 
000010 //                    DD DSN=NUMHP53.MAITREE.DATA4,                               
000011 //                    DISP=SHR                                                 
000012 //                     DD DSN=NUMHP53.MAITREE.DATA5,                               
000013 //                   DISP=SHR                                                 
  
Result:
SDSF EDIT    NUMHP53A (JOB31500) JCLEDIT                   Columns 00001 00072
  Command ===>   sub;;                                          Scroll ===> PAGE
  ****** ***************************** Top of Data ******************************
 000001 //*COMMENTLINE                                                         
 000002 //NUMHP53A JOB ,'SYNC',MSGCLASS=Q,MSGLEVEL=(1,1),NOTIFY=&SYSUID        
 000003 //STEP01         EXEC PGM=SORT                                               
 000004 //SORTIN         DD DSN=NUMHP53.MAITREE.DATA1,                               
 000005 //                      DISP=SHR                                                 
 000006 //                      DD DSN=NUMHP53.MAITREE.DATA2,                               
 000007 //                      DISP=SHR                                                 
 000008 //                      DD DSN=NUMHP53.MAITREE.DATA3,                               
 000009 //                      DISP=SHR                                                 
 000010 //                      DD DSN=NUMHP53.MAITREE.DATA4,                               
 000011 //                      DISP=SHR                                                 
 000012 //                      DD DSN=NUMHP53.MAITREE.DATA5,                               
 000013 //                      DISP=SHR                                                 
 000014 //                     DD DSN=NUMHP53.MAITREE.DATA6,                               
 000015 //                     DISP=SHR                                                 
 000016 //                    DD DSN=NUMHP53.MAITREE.DATA7,                               
  ENTER JOBNAME CHARACTER(S) -                                                   
                                                                               
 ENTER JOBNAME CHARACTER(S) -                                                  
                                                                                
                                                                               


2. Now what happens if we just give a line before jobcard.


SDSF EDIT    NUMHP53A (JOB31500) JCLEDIT                   Columns 00001 00072
Command ===>       sub;;                                      Scroll ===> PAGE
****** ***************************** Top of Data ******************************
000001 //COMMENTLINE                                                           
000002 //NUMHP53A JOB ,'SYNC',MSGCLASS=Q,MSGLEVEL=(1,1),NOTIFY=&SYSUID        
000003 //STEP01         EXEC PGM=SORT                                               
000004 //SORTIN        DD DSN=NUMHP53.MAITREE.DATA1,                               
000005 //                     DISP=SHR                                                 
000006 //                     DD DSN=NUMHP53.MAITREE.DATA2,                               
000007 //                     DISP=SHR                                                 
000008 //                     DD DSN=NUMHP53.MAITREE.DATA3,                               
000009 //                     DISP=SHR                                                 
000010 //                     DD DSN=NUMHP53.MAITREE.DATA4,                               
000011 //                    DISP=SHR                                                 
000012 //                    DD DSN=NUMHP53.MAITREE.DATA5,                               
000013 //                    DISP=SHR                                                  
000014 //                    DD DSN=NUMHP53.MAITREE.DATA6,                               
000015 //                    DISP=SHR                                                 
000016 //                   DD DSN=NUMHP53.MAITREE.DATA7,                                
ENTER JOBNAME CHARACTER(S) -                                                  
                                                                              
                                                                              

3. What happens when we give just a line (without //) before jobcard:


SDSF EDIT    NUMHP53A (JOB31500) JCLEDIT                   Columns 00001 00072
Command ===>   sub;;                                          Scroll ===> PAGE
****** ***************************** Top of Data ******************************
000001 COMMENTLINE                                                            
000002 //NUMHP53A JOB ,'SYNC',MSGCLASS=Q,MSGLEVEL=(1,1),NOTIFY=&SYSUID        
000003 //STEP01         EXEC PGM=SORT                                               
000004 //SORTIN        DD DSN=NUMHP53.MAITREE.DATA1,                               
000005 //                      DISP=SHR                                                 
000006 //                      DD DSN=NUMHP53.MAITREE.DATA2,                               

Result:


SDSF EDIT    NUMHP53A (JOB37533) JCLEDIT                   Columns 00001 00072
Command ===> sub;;                                            Scroll ===> PAGE
****** ***************************** Top of Data ******************************
000001 COMMENT                                                                 
000002 //NUMHP53A JOB ,'SYNC',MSGCLASS=Q,MSGLEVEL=(1,1),NOTIFY=&SYSUID        
000003 //STEP01        EXEC PGM=SORT                                               
000004 //SORTIN        DD DSN=NUMHP53.MAITREE.DATA1,                                
000005 //                     DISP=SHR                                                 
000006 //                    DD DSN=NUMHP53.MAITREE.DATA2,                               
000007 //                    DISP=SHR                                                 
000008 //                    DD DSN=NUMHP53.MAITREE.DATA3,                               
000009 //                    DISP=SHR                                                 
000010 //                    DD DSN=NUMHP53.MAITREE.DATA4,                               
000011 //                    DISP=SHR                                                 
000012 //                    DD DSN=NUMHP53.MAITREE.DATA5,                               
000013 //                    DISP=SHR                                                 
000014 //                    DD DSN=NUMHP53.MAITREE.DATA6,                               
000015 //                   DISP=SHR                                                 
000016 //                    DD DSN=NUMHP53.MAITREE.DATA7,                               
ENTER JOBNAME CHARACTER(S) -