Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Splitting a file based on a field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Splitting a file based on a field
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

Site Director


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

PostPosted: Thu Jun 21, 2012 7:58 pm    Post subject:
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

Moderator


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

PostPosted: Thu Jun 21, 2012 7:59 pm    Post subject:
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    Post subject:
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

Moderator


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

PostPosted: Fri Jun 22, 2012 10:03 am    Post subject:
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    Post subject:
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

Moderator


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

PostPosted: Fri Jun 22, 2012 10:23 am    Post subject:
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    Post subject:
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: 1703
Location: Australia

PostPosted: Fri Jun 22, 2012 11:28 am    Post subject:
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

Moderator


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

PostPosted: Fri Jun 22, 2012 11:34 am    Post subject:
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    Post subject:
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

Moderator


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

PostPosted: Fri Jun 22, 2012 1:29 pm    Post subject:
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

Site Director


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

PostPosted: Fri Jun 22, 2012 6:42 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Sun Jun 24, 2012 2:50 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 3 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us