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:
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:
Usage of SPLIT1R:
Input dataset:
Output 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..
//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
****************************
|
//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
****************************
|
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
/*
//*
|
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
****************************
|
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
****************************
|
No comments:
Post a Comment