Posted: Thu Nov 08, 2007 4:40 pm Post subject: File Split using DFSORT or SYNCSORT
Hello!
I visited all the messages, but could not find the exact solution I was searching for. I hope you GURUs will shed some light towrds the solution.
I want to split this file in two files. First file should contain all the P1 related data for Date D1. the second file should contain P1 related data for date D2. Similarly all P2-D3 combination to go to file 1 and P2-D4 should go to file 2.
In other words all data for P1 should go to file 1 until I find a break in D1. when I find a break in D1, until I get a break in P1,rest of those records should be written to file2.
Request you to take some of your valuable time to point to me a good solution.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Nov 08, 2007 5:30 pm Post subject:
The pattern isn't clear. In your discussion, you skip from P2D3 to P2D4 ... what about P3D3 and P4D3 in between P2D3 and P2D4? What about P3D4 and P4D4?
Please show the output you would expect for your input and explain the rules for getting from input to output more clearly. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Nov 08, 2007 7:07 pm Post subject:
Well, you didn't explain the rules, so I'm not sure I understand what you want. But I'll take a guess that you want to alternate writing the groups in output file1 or output file2 each time the Dx value changes. So the D1 records go in output file1, the D2 records go in output file2, the D3 records go in output file1, the D4 records go in output file2, and so on. If that's what you want, then the following DFSORT job will do it. If that's not what you want, then you need to explain what you want.
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Last edited by Frank Yaeger on Fri Nov 09, 2007 4:18 pm; edited 1 time in total
In other words -
Until D1 changes, all the records should go to File1 for P1 key. When D1 changes to D2 and still its having the same key P1, then all the records should go to file2.
Then when P1 changes to P2, until D1(for P2 key) changes to D2(for P2 key), all the records should go to File1 and when D1 changes to D2, unitl (either the EOF or P2 changes to Px), all the records should go to File2.
The input file is sorted first on P1 key then on D1 key.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Nov 09, 2007 1:53 pm Post subject:
For your latest example (and earlier example), the DFSORT job I posted gives the output you show for the input you show.
You would need to show me an example where my job does not produce the correct output for me to understand what would need to be changed. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Nov 09, 2007 6:32 pm Post subject:
You're welcome.
Quote:
You guys are really helpful.
I guess you're referring to me and the pet rats in my pocket. Well, actually they're girls, not guys, and they're at home, not in my pocket (although they do love to explore my pockets).
(It must be Friday afternoon - I'm getting punchy.) _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Mon Nov 19, 2007 1:36 pm Post subject:
You want to group the records by positions 1-2 and 7-8 and then write alternate groups to different output files. A group starts when 1-2 and 7-8 changes.
The INREC statement first does a RESTART on positions 1-2 and 7-8 to get a 0 for the first record in each group so we know which record starts a group. Then it uses the "group trick" to get a sequence number for each group of records. After the INREC statement, the records would look like this:
The OUTREC statement does MOD 2 arithmetic on the groupnum to get a 0 in 3005 for groups with an even groupnum and a 1 for groups with an odd groupnum. We can then use the 1 indicator to select records to go to output file1 and the 0 indicator to select records to go to output file2. After the OUTREC statement, the records would look like this:
The first OUTFIL statement selects the records with the 1 indicator to go to OUT1.
The second OUTFIL statement selects the other records to go to OUT2. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Thanks for the quick reply Frank.
I'm trying to modify the control card to suit my change and I should have told this earlier. I sincerly apologize for it. The P1 key is 12 byte wide and abd D1 key is 5 byte wide.
When i Modified the control card to suit the need, I'm getting all the records in file1 and nothing on File 2.
Thanks for the quick reply Frank.
I'm trying to modify the control card to suit my change and I should have told this earlier. I sincerly apologize for it. The P1 key is 12 byte wide and abd D1 key is 5 byte wide.
When i Modified the control card to suit the need, I'm getting all the records in file1 and nothing on File 2.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum