|
View previous topic :: View next topic
|
| Author |
Message |
chandu ravichandra
New User
.jpg)
Joined: 10 Apr 2012 Posts: 6 Location: INDIA
|
|
|
|
Hi,
I have the requirement, where i need to split the file into multiple files based on a filed of input file. Each output files should contains the records with same key.
Notes:
1. each files is Lrecl of 20.
2. key filed starts at position 8 and length of 3.(i.e., 100,101,103)
3. the values of key field can vary and there can be up to 12 different keys.
For example the input file
| Code: |
1 100 123456789
2 100 123456790
3 100 123456791
4 101 123456792
5 101 123456793
6 101 123456794
7 101 123456795
8 101 123456796
9 103 123456797
10 103 123456798
11 103 123456799
12 103 123456800
13 103 123456801 |
output file1:
| Code: |
1 100 123456789
2 100 123456790
3 100 123456791 |
output file2:
| Code: |
4 101 123456792
5 101 123456793
6 101 123456794
7 101 123456795
8 101 123456796 |
output file3:
| Code: |
9 103 123456797
10 103 123456798
11 103 123456799
12 103 123456800
13 103 123456801 |
Could you please help me to achieve this using SYNCSORT
Thanks in advance |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
For a quicker answer, suggest you search the JCL and DFSORT parts of the forum. This has been asked and code provided before (IIRC). |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
IIR Syncsort syntax C
Something like this
Ensure you have those many output dd OUT1 to OUT12
| Code: |
SORT FIELDS=COPY
OUTFIL FNAMES=OUT1,INCLUDE=(8,3,CH,EQ,C'100')
OUTFIL FNAMES=OUT2,INCLUDE=(8,3,CH,EQ,C'101')
OUTFIL FNAMES=OUT3,INCLUDE=(8,3,CH,EQ,C'102')
OUTFIL FNAMES=OUT4,INCLUDE=(8,3,CH,EQ,C'103')
OUTFIL FNAMES=OUT5,INCLUDE=(8,3,CH,EQ,C'104')
OUTFIL FNAMES=OUT6,INCLUDE=(8,3,CH,EQ,C'105')
OUTFIL FNAMES=OUT7,INCLUDE=(8,3,CH,EQ,C'106')
OUTFIL FNAMES=OUT8,INCLUDE=(8,3,CH,EQ,C'107')
OUTFIL FNAMES=OUT9,INCLUDE=(8,3,CH,EQ,C'108')
OUTFIL FNAMES=OUT10,INCLUDE=(8,3,CH,EQ,C'109')
OUTFIL FNAMES=OUT11,INCLUDE=(8,3,CH,EQ,C'110')
OUTFIL FNAMES=OUT12,INCLUDE=(8,3,CH,EQ,C'111') |
should work |
|
| Back to top |
|
 |
chandu ravichandra
New User
.jpg)
Joined: 10 Apr 2012 Posts: 6 Location: INDIA
|
|
|
|
Thanks Dick, I have searched in the forum and couldn't find appropriate thread for SYNCSORT jcl.
Thanks Pandora, since i don't have values of key, couldn't work out as you mentioned
| Quote: |
| INCLUDE=(8,3,CH,EQ,C'value') |
Can anybody please help me for this |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| As a one time activity you can find the unique key values hoping it doeant change in future you can build the above sort card using the unique keys found |
|
| Back to top |
|
 |
chandu ravichandra
New User
.jpg)
Joined: 10 Apr 2012 Posts: 6 Location: INDIA
|
|
|
|
Thanks a lot Pandora for your valuable time .
We have requirement where the values of key field can vary and there can be up to 12 different keys.
I found the appropriate thread for DFSORT jcl in our forum
| Code: |
//SPLIT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1 100 123456789
2 100 123456790
3 100 123456791
4 101 123456792
5 101 123456793
6 101 123456794
7 101 123456795
8 101 123456796
9 103 123456797
10 103 123456798
11 103 123456799
12 103 123456800
13 103 123456801
/*
//OUT01 DD SYSOUT=*
//OUT02 DD SYSOUT=*
//OUT03 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(9,3),PUSH=(21:ID=2))
OUTFIL FNAMES=OUT01,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,01)
OUTFIL FNAMES=OUT02,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,02)
OUTFIL FNAMES=OUT03,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,03)
/*
// |
Can we do the same using SYNCSORT. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
I just understood what you ment
When keys are not found I believe your output files woild be created empty |
|
| Back to top |
|
 |
chandu ravichandra
New User
.jpg)
Joined: 10 Apr 2012 Posts: 6 Location: INDIA
|
|
|
|
| yes, you are correct. we will have empty datasets. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Pandora-Box,
| Quote: |
| When keys are not found I believe your output files woild be created empty |
How does this differ from your example ? Your output files would also be empty.
Gerry |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Hi Gerry ,
I feel TS assumed my example would not create the file when key not found he could have very much executed using the card
so why quoted those lines
And yet am not sure if he nneded to create files only when key is found |
|
| Back to top |
|
 |
chandu ravichandra
New User
.jpg)
Joined: 10 Apr 2012 Posts: 6 Location: INDIA
|
|
|
|
Hi Pandora,
| Quote: |
I feel TS assumed my example would not create the file when key not found he could have very much executed using the card
|
I understood ur example and it wont suits my requirement...and I dont know where i am missing to explain u what i needed.
| Quote: |
| And yet am not sure if he nneded to create files only when key is found |
do u mean to say we can create datasets with help of sort based on the number of keys
please let me know u need more details about requirement.. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Ok
I understand you wanted to copy key data seperately
What do you want to do when key is present = Do you need to create output and copy data ?
What do you want to do when key is not present ?
or is that do you need to create the output dynamically based on the keys only present that run?
Thanks |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
How many records (on average) will be in the input file?
One way would be to "pre-process" the input file and generate the JCL and sort control statements based on the keys found. . . |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| chandu ravichandra wrote: |
Thanks a lot Pandora for your valuable time .
We have requirement where the values of key field can vary and there can be up to 12 different keys.
I found the appropriate thread for DFSORT jcl in our forum
| Code: |
//SPLIT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
1 100 123456789
2 100 123456790
3 100 123456791
4 101 123456792
5 101 123456793
6 101 123456794
7 101 123456795
8 101 123456796
9 103 123456797
10 103 123456798
11 103 123456799
12 103 123456800
13 103 123456801
/*
//OUT01 DD SYSOUT=*
//OUT02 DD SYSOUT=*
//OUT03 DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(9,3),PUSH=(21:ID=2))
OUTFIL FNAMES=OUT01,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,01)
OUTFIL FNAMES=OUT02,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,02)
OUTFIL FNAMES=OUT03,BUILD=(1,20),INCLUDE=(21,2,ZD,EQ,03)
/*
// |
Can we do the same using SYNCSORT. |
Please try it and let us know.
Otherwise consider Dick's solution, to generate the sort cards in each run along the lines of Pandora-box's original solution. At the time you have the data you (as in Sort) can "know" what the keys are. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|