MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

File Split using DFSORT or SYNCSORT
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
eskaysem
Beginner


Joined: 31 Mar 2003
Posts: 29
Topics: 13

PostPosted: Thu Nov 08, 2007 4:40 pm    Post subject: File Split using DFSORT or SYNCSORT Reply with quote

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 have one file as follows(FB - LRECL 3000)

P1V1C1D1
P1V1C2D1
P1V1C3D1
P1V1C4D1
P1V2C1D1
P1V2C2D1
P1V2C3D1
P1V1C1D2
P1V1C2D2
P1V1C3D2
P1V1C4D2
P1V2C1D2
P1V2C2D2
P1V2C3D2
P2V1C1D3
P2V1C2D3
P3V2C1D3
P4V2C2D3
P2V1C1D4
P2V1C2D4
P3V2C1D4
P4V2C2D4


and so on...
All the D's are julian dates.

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.

Thank you,
Santosh
_________________
Thanks!,
Santosh Kulkarni
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 08, 2007 5:30 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eskaysem
Beginner


Joined: 31 Mar 2003
Posts: 29
Topics: 13

PostPosted: Thu Nov 08, 2007 5:53 pm    Post subject: Reply with quote

Sorry for the typo.

Input file:
P1V1C1D1
P1V1C2D1
P1V1C3D1
P1V1C4D1
P1V2C1D1
P1V2C2D1
P1V2C3D1
P1V1C1D2
P1V1C2D2
P1V1C3D2
P1V1C4D2
P1V2C1D2
P1V2C2D2
P1V2C3D2
P2V1C1D3
P2V1C2D3
P2V2C1D3
P2V2C2D3
P2V1C1D4
P2V1C2D4
P2V2C1D4
P2V2C2D4

Output file1:
P1V1C1D1
P1V1C2D1
P1V1C3D1
P1V1C4D1
P1V2C1D1
P1V2C2D1
P1V2C3D1
P2V1C1D3
P2V1C2D3
P2V2C1D3
P2V2C2D3

output File2:
P1V1C1D2
P1V1C2D2
P1V1C3D2
P1V1C4D2
P1V2C1D2
P1V2C2D2
P1V2C3D2
P2V1C1D4
P2V1C2D4
P2V2C1D4
P2V2C2D4

Sorry again.
Thanks for your help.
_________________
Thanks!,
Santosh Kulkarni
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Nov 08, 2007 7:07 pm    Post subject: Reply with quote

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.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/3000)
//OUT1 DD DSN=...   output file1 (FB/3000)
//OUT2 DD DSN=...   output file2 (FB/3000)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
    OVERLAY=(3001:SEQNUM,8,PD,
             3017:SEQNUM,8,PD,START=0,RESTART=(7,2))),
     IFTHEN=(WHEN=(3017,8,PD,EQ,+0),
       OVERLAY=(3001:SEQNUM,8,PD)),
     IFTHEN=(WHEN=NONE,
       OVERLAY=(3009:SEQNUM,8,PD,
        3001:3001,8,PD,SUB,3009,8,PD,TO=PD,LENGTH=8))
  OUTREC OVERLAY=(3001:3001,8,PD,MOD,+2,TO=ZD,LENGTH=1)
  OUTFIL FNAMES=OUT1,INCLUDE=(3001,1,ZD,EQ,1),BUILD=(1,3000)
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,3000)
/*

_________________
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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eskaysem
Beginner


Joined: 31 Mar 2003
Posts: 29
Topics: 13

PostPosted: Fri Nov 09, 2007 11:58 am    Post subject: Reply with quote

Sorry for the confusion again!!
I'll try to be specific as to what exactly do I need.

Suppose input file -
P1V1C1D1
P1V1C2D1
P1V1C1D2
P1V1C2D2
P2V1C1D1
P2V1C2D1
P2V1C1D2
P2V1C2D2

my Output files should look like -

File1
P1V1C1D1
P1V1C2D1
P2V1C1D1
P2V1C2D1

File2
P1V1C1D2
P1V1C2D2
P2V1C1D2
P2V1C2D2

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.

These Dx are dates in julian format.

Thanks again! I'm highly obliged.

Santosh
_________________
Thanks!,
Santosh Kulkarni
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Nov 09, 2007 1:53 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eskaysem
Beginner


Joined: 31 Mar 2003
Posts: 29
Topics: 13

PostPosted: Fri Nov 09, 2007 2:29 pm    Post subject: Reply with quote

Thanks for the great help Frank. The only place it did not work was
eg:
Input File:
P1V1C1D1
P1V1C1D2
P1V1C2D2
P2V1C1D2
P2V1C1D3

The output that I got was
File1:
P1V1C1D1
P2V1C1D3

File2:
P1V1C1D2
P1V1C2D2
P2V1C1D2

Thanks
_________________
Thanks!,
Santosh Kulkarni
Back to top
View user's profile Send private message
eskaysem
Beginner


Joined: 31 Mar 2003
Posts: 29
Topics: 13

PostPosted: Fri Nov 09, 2007 3:02 pm    Post subject: Reply with quote

Input file:
P1V1C1D1
P1V1C1D2
P1V1C2D2
P2V1C1D2
P2V1C1D3


The output should have been as follows

File1:
P1V1C1D1
P2V1C1D2

File2:
Input File:
P1V1C1D2
P1V1C2D2
P2V1C1D3
_________________
Thanks!,
Santosh Kulkarni
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Nov 09, 2007 4:26 pm    Post subject: Reply with quote

Ok, this DFSORT job should do it:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/3000)
//OUT1 DD DSN=...   output file1 (FB/3000)
//OUT2 DD DSN=...   output file2 (FB/3000)
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
    OVERLAY=(3001:1,2,3003:7,2,3005:SEQNUM,8,PD,
             3021:SEQNUM,8,PD,START=0,RESTART=(3001,4))),
     IFTHEN=(WHEN=(3021,8,PD,EQ,+0),
       OVERLAY=(3005:SEQNUM,8,PD)),
     IFTHEN=(WHEN=NONE,
       OVERLAY=(3013:SEQNUM,8,PD,
        3005:3005,8,PD,SUB,3013,8,PD,TO=PD,LENGTH=8))
  OUTREC OVERLAY=(3005:3005,8,PD,MOD,+2,TO=ZD,LENGTH=1)
  OUTFIL FNAMES=OUT1,INCLUDE=(3005,1,ZD,EQ,1),BUILD=(1,3000)
  OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,3000)
/*

_________________
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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eskaysem
Beginner


Joined: 31 Mar 2003
Posts: 29
Topics: 13

PostPosted: Fri Nov 09, 2007 6:10 pm    Post subject: Reply with quote

Thank you so much Frank. You guys are really helpful.

Appreciate it !!
_________________
Thanks!,
Santosh Kulkarni
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Nov 09, 2007 6:32 pm    Post subject: Reply with quote

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). Mr. Green

(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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eskaysem
Beginner


Joined: 31 Mar 2003
Posts: 29
Topics: 13

PostPosted: Mon Nov 19, 2007 9:53 am    Post subject: Reply with quote

Smile I certainly was refering to you and only to you...
Frank, could you please explain the control card a bit?

Thanks
_________________
Thanks!,
Santosh Kulkarni
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Mon Nov 19, 2007 1:36 pm    Post subject: Reply with quote

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:

Code:

         key1   key2    groupnum
1-8      3001-2 3003-4  3005-3012
P1V1C1D1 P1     D1      1
P1V1C1D2 P1     D2      2
P1V1C2D2 P1     D2      2
P2V1C1D2 P2     D2      3
P2V1C1D3 P2     D3      4


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:

Code:

         key1   key2    output file indicator
1-8      3001-2 3003-4  3005
P1V1C1D1 P1     D1      1
P1V1C1D2 P1     D2      0
P1V1C2D2 P1     D2      0
P2V1C1D2 P2     D2      1
P2V1C1D3 P2     D3      0


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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
eskaysem
Beginner


Joined: 31 Mar 2003
Posts: 29
Topics: 13

PostPosted: Mon Nov 19, 2007 3:11 pm    Post subject: Reply with quote

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.

My control card looks like this -

Code:
 OPTION COPY                                                 
   INREC IFTHEN=(WHEN=INIT,                                 
     OVERLAY=(3001:1,12,3013:24,5,3018:SEQNUM,8,PD,         
              3034:SEQNUM,8,PD,START=0,RESTART=(3001,4))),   
      IFTHEN=(WHEN=(3034,8,PD,EQ,+0),                       
        OVERLAY=(3018:SEQNUM,8,PD)),                         
      IFTHEN=(WHEN=NONE,                                     
        OVERLAY=(3026:SEQNUM,8,PD,                           
         3018:3018,8,PD,SUB,3026,8,PD,TO=PD,LENGTH=8))       
 OUTREC OVERLAY=(3018:3018,8,PD,MOD,+2,TO=ZD,LENGTH=1)       
 OUTFIL FNAMES=OUT1,INCLUDE=(3018,1,ZD,EQ,1),BUILD=(1,3000) 
 OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,3000)                     


I'm sorry for not being clear at first.

Thanks
_________________
Thanks!,
Santosh Kulkarni
Back to top
View user's profile Send private message
eskaysem
Beginner


Joined: 31 Mar 2003
Posts: 29
Topics: 13

PostPosted: Mon Nov 19, 2007 3:13 pm    Post subject: Reply with quote

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.

My control card looks like this -

Code:
 OPTION COPY                                                 
   INREC IFTHEN=(WHEN=INIT,                                 
     OVERLAY=(3001:1,12,3013:24,5,3018:SEQNUM,8,PD,         
              3034:SEQNUM,8,PD,START=0,RESTART=(3001,4))),   
      IFTHEN=(WHEN=(3034,8,PD,EQ,+0),                       
        OVERLAY=(3018:SEQNUM,8,PD)),                         
      IFTHEN=(WHEN=NONE,                                     
        OVERLAY=(3026:SEQNUM,8,PD,                           
         3018:3018,8,PD,SUB,3026,8,PD,TO=PD,LENGTH=8))       
 OUTREC OVERLAY=(3018:3018,8,PD,MOD,+2,TO=ZD,LENGTH=1)       
 OUTFIL FNAMES=OUT1,INCLUDE=(3018,1,ZD,EQ,1),BUILD=(1,3000) 
 OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,3000)                     


I'm sorry for not being clear at first.

Thanks
_________________
Thanks!,
Santosh Kulkarni
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group