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 

Splitting Files depending on Input file

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
petluri
Beginner


Joined: 05 Dec 2002
Posts: 19
Topics: 5
Location: Virginia, USA

PostPosted: Mon Dec 27, 2004 2:00 am    Post subject: Splitting Files depending on Input file Reply with quote

Hi,
I have 2 files as followed

file1
A20B20C20D20

File2
A1112345
B1123456
C1145678
D1167888

I want the second file to be split in to 4 files. But the condition is like this. We need to get the first 3 bytes from input file and check all the records from 2nd file and which ever is less than the key from file1 to be written to out 1 file. Similary the second output file should be checked against the key from file1 (starting from 4th position and 3 bytes length). And so on for the other output files.

Kindly please let me know how I can do this using Syncsort/SYNCTOOL

Regards,
Sreeni
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Dec 27, 2004 5:03 am    Post subject: Reply with quote

petluri,

Try this Synctool job.

Code:

//R010    EXEC PGM=SYNCTOOL       
//TOOLMSG   DD SYSOUT=*           
//DFSMSG    DD SYSOUT=*           
//INPUT1    DD *                 
A20B20C20D20                     
/*                               
//INPUT2    DD *                 
A1112345                         
A1727574                         
A1927574                         
B1123456                         
B1223456                         
C1145678                         
C1245678                         
C1345678                         
C1445678                         
D1167888                         
/*                               
//OUTPUT1   DD SYSOUT=*           
//OUTPUT2   DD SYSOUT=*                                 
//OUTPUT3   DD SYSOUT=*                                 
//OUTPUT4   DD SYSOUT=*                                 
//TOOLIN    DD *                                         
  COPY FROM(INPUT1)  USING(CTL1)                         
  COPY FROM(INPUT2)  USING(CTL2)                         
/*                                                       
//CTL2CNTL  DD DSN=&&TEMP1,DISP=(,PASS)                 
//CTL1CNTL  DD *                                         
  OUTFIL FNAMES=CTL2CNTL,                               
  OUTREC=(2X,C'OUTFIL FNAMES=OUTPUT1,',                 
             C'INCLUDE=(1,3,CH,LE,C''',1,3,C''')',80:X,/,
          2X,C'OUTFIL FNAMES=OUTPUT2,',                 
             C'INCLUDE=(1,3,CH,GT,C''',1,3,C''',AND,',   
                      C'1,3,CH,LE,C''',4,3,C''')',80:X,/,
          2X,C'OUTFIL FNAMES=OUTPUT3,',                 
             C'INCLUDE=(1,3,CH,GT,C''',4,3,C''',AND,',   
                      C'1,3,CH,LE,C''',7,3,C''')',80:X,/,
          2X,C'OUTFIL FNAMES=OUTPUT4,',                 
             C'INCLUDE=(1,3,CH,GT,C''',7,3,C''',AND,',   
                      C'1,3,CH,LE,C''',10,3,C''')',80:X)
/*                                                       


Here is a brief description of what the job does.

1. First, I assumed that you actually wanted the conditions like this:
Code:

a.  Write to Output1 if Key in file 2 is LE (Less than or Equal to) Key in position 1 thru 3 of Input file 1.

b.  Write to Output2 if Key is file 2 is GT first Key (file 1) and LE Second Key (file 1) and so on.


Is this assumption right ? B'cas you never pointed out the GT condition in your post. You just asked me to compare the Keys in file 2 against the Second Key in file 1 (Pos: 4 thru 6). Anyway you can easily change my job if this assumption is wrong.

Description:
1. Take as input File 1 and create a DYNAMIC Sort Control Card CTL2CNTL as shown below.
Code:

  OUTFIL FNAMES=OUTPUT1,INCLUDE=(1,3,CH,LE,C'A20')                     
  OUTFIL FNAMES=OUTPUT2,INCLUDE=(1,3,CH,GT,C'A20',AND,1,3,CH,LE,C'B20')
  OUTFIL FNAMES=OUTPUT3,INCLUDE=(1,3,CH,GT,C'B20',AND,1,3,CH,LE,C'C20')
  OUTFIL FNAMES=OUTPUT4,INCLUDE=(1,3,CH,GT,C'C20',AND,1,3,CH,LE,C'D20')


2. Now read the Input file 2 and split the records into 4 different output file using the conditions listed in the Control card - CTL2CNTL.

Hope I'm clear.

Now, if you want your output files 2, 3, 4 to be cumulative as shown below.
Output File 2 = Output File 1 + records for file 2
Output file 3 = Output File 1 + Output File 2 + records for file 3
Output file 4 = Output File 1 + Output File 2 + Output File 3 + records for file 4 then use this job.

Code:

//R010    EXEC PGM=SYNCTOOL                             
//TOOLMSG   DD SYSOUT=*                                 
//DFSMSG    DD SYSOUT=*                                 
//INPUT1    DD *                                       
A20B20C20D20                                           
/*                                                     
//INPUT2    DD *                                       
A1112345                                               
A1727574                                               
A1927574                                               
B1123456                                               
B1223456                                               
C1145678                                               
C1245678                                               
C1345678                                               
C1445678                                               
D1167888                                               
/*                                                     
//OUTPUT1   DD SYSOUT=*                                 
//OUTPUT2   DD SYSOUT=*                                 
//OUTPUT3   DD SYSOUT=*                                 
//OUTPUT4   DD SYSOUT=*                                       
//TOOLIN    DD *                                               
  COPY FROM(INPUT1)  USING(CTL1)                               
  COPY FROM(INPUT2)  USING(CTL2)                               
/*                                                             
//CTL2CNTL  DD DSN=&&TEMP1,DISP=(,PASS)                       
//CTL1CNTL  DD *                                               
  OUTFIL FNAMES=CTL2CNTL,                                     
  OUTREC=(2X,C'OUTFIL FNAMES=OUTPUT1,',                       
             C'INCLUDE=(1,3,CH,LE,C''',1,3,C''')',80:X,/,     
          2X,C'OUTFIL FNAMES=OUTPUT2,',                       
             C'INCLUDE=(1,3,CH,LE,C''',4,3,C''')',80:X,/,     
          2X,C'OUTFIL FNAMES=OUTPUT3,',                       
             C'INCLUDE=(1,3,CH,LE,C''',7,3,C''')',80:X,/,     
          2X,C'OUTFIL FNAMES=OUTPUT4,',                       
             C'INCLUDE=(1,3,CH,LE,C''',10,3,C''')',80:X)       
/*                                                             


The CTL2CNTL will be generated as shown below.
Code:

  OUTFIL FNAMES=OUTPUT1,INCLUDE=(1,3,CH,LE,C'A20')
  OUTFIL FNAMES=OUTPUT2,INCLUDE=(1,3,CH,LE,C'B20')
  OUTFIL FNAMES=OUTPUT3,INCLUDE=(1,3,CH,LE,C'C20')
  OUTFIL FNAMES=OUTPUT4,INCLUDE=(1,3,CH,LE,C'D20')


Hope this helps,

Thanks,
Phantom
Back to top
View user's profile Send private message
petluri
Beginner


Joined: 05 Dec 2002
Posts: 19
Topics: 5
Location: Virginia, USA

PostPosted: Mon Dec 27, 2004 6:22 am    Post subject: Reply with quote

Thank you very much Phantom! Actually, I need both the solutions.

Regards,
Sreeni
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
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