IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Splitting a file based on a field


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chandu ravichandra

New User


Joined: 10 Apr 2012
Posts: 6
Location: INDIA

PostPosted: Thu Jun 21, 2012 7:05 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 21, 2012 7:58 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Jun 21, 2012 7:59 pm
Reply with quote

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
View user's profile Send private message
chandu ravichandra

New User


Joined: 10 Apr 2012
Posts: 6
Location: INDIA

PostPosted: Fri Jun 22, 2012 9:55 am
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jun 22, 2012 10:03 am
Reply with quote

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
View user's profile Send private message
chandu ravichandra

New User


Joined: 10 Apr 2012
Posts: 6
Location: INDIA

PostPosted: Fri Jun 22, 2012 10:20 am
Reply with quote

Thanks a lot Pandora for your valuable time icon_smile.gif .
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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jun 22, 2012 10:23 am
Reply with quote

I just understood what you ment

When keys are not found I believe your output files woild be created empty
Back to top
View user's profile Send private message
chandu ravichandra

New User


Joined: 10 Apr 2012
Posts: 6
Location: INDIA

PostPosted: Fri Jun 22, 2012 10:30 am
Reply with quote

yes, you are correct. we will have empty datasets.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Jun 22, 2012 11:28 am
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jun 22, 2012 11:34 am
Reply with quote

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
View user's profile Send private message
chandu ravichandra

New User


Joined: 10 Apr 2012
Posts: 6
Location: INDIA

PostPosted: Fri Jun 22, 2012 12:40 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jun 22, 2012 1:29 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Jun 22, 2012 6:42 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sun Jun 24, 2012 2:50 am
Reply with quote

chandu ravichandra wrote:
Thanks a lot Pandora for your valuable time icon_smile.gif .
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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top