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
 

 

Separate duplicate records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
arvind.m

Active User


Joined: 28 Aug 2008
Posts: 205
Location: Hyderabad

PostPosted: Tue May 12, 2009 2:50 pm    Post subject: Separate duplicate records
Reply with quote

Hi All,
I have an input file with the following layout

Key ---- 22 bytes
date ---- 8 bytes
transaction type ---- 1 byte

Now the input file can have maximum of 4 records with same key. Now if the key occurs only one time in the file i need to write into output1. If the key occurs two times in teh input file i need to write into output2. if the key occurs three times in the input file i need to write into output3 and if the kye occurs four times in the input file i need to wirte into output 4.

can anyone tell me how to get this done using sort.

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

Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2239
Location: @my desk

PostPosted: Tue May 12, 2009 5:07 pm    Post subject:
Reply with quote

Arvind,

How about trying the below ICETOOL job.
Code:
//STEP1 EXEC PGM=ICETOOL       
//IN      DD DSN=Input-file
//OUT1    DD DSN=Output-file1                         
//OUT2    DD DSN=Output-file2                           
//OUT3    DD DSN=Output-file3                         
//OUT4    DD DSN=Output-file4                       
//DFSMSG  DD SYSOUT=*                         
//TOOLMSG DD SYSOUT=*                         
//TOOLIN  DD *                                 
  SELECT FROM(IN) TO(OUT1) ON(1,22,CH) EQUAL(1)
  SELECT FROM(IN) TO(OUT2) ON(1,22,CH) EQUAL(2)
  SELECT FROM(IN) TO(OUT3) ON(1,22,CH) EQUAL(3)
  SELECT FROM(IN) TO(OUT4) ON(1,22,CH) EQUAL(4)
Back to top
View user's profile Send private message
arvind.m

Active User


Joined: 28 Aug 2008
Posts: 205
Location: Hyderabad

PostPosted: Tue May 12, 2009 6:39 pm    Post subject:
Reply with quote

Arun thank you....it worked.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2239
Location: @my desk

PostPosted: Tue May 12, 2009 7:16 pm    Post subject:
Reply with quote

You're welcome icon_smile.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue May 12, 2009 10:10 pm    Post subject: Reply to: separate duplicatie records.
Reply with quote

arvind.m,

If your input is already sorted on the key, then the following 1 pass solution will give you the desired results.

Code:

//STEP0100 EXEC PGM=SORT                 
//SYSOUT   DD SYSOUT=*                   
//SORTIN   DD *                         
AAAAAAAAAAAAAAAAAAAAAA20090501Y         
BBBBBBBBBBBBBBBBBBBBBB20090502Y         
BBBBBBBBBBBBBBBBBBBBBB20090503Y         
CCCCCCCCCCCCCCCCCCCCCC20090504Y         
CCCCCCCCCCCCCCCCCCCCCC20090505Y         
CCCCCCCCCCCCCCCCCCCCCC20090506Y         
DDDDDDDDDDDDDDDDDDDDDD20090507Y         
DDDDDDDDDDDDDDDDDDDDDD20090508Y         
DDDDDDDDDDDDDDDDDDDDDD20090509Y         
DDDDDDDDDDDDDDDDDDDDDD20090510Y         
//OUT1     DD SYSOUT=*                   
//OUT2     DD SYSOUT=*                   
//OUT3     DD SYSOUT=*                   
//OUT4     DD SYSOUT=*                   
//SYSIN    DD *                                                     
  INREC IFTHEN=(WHEN=INIT,                                         
  BUILD=(1,31,27Z,SEQNUM,1,ZD,RESTART=(1,22),C'1')),               
  IFTHEN=(WHEN=(59,1,ZD,EQ,2),OVERLAY=(32:23,9,23:09Z)),           
  IFTHEN=(WHEN=(59,1,ZD,EQ,3),OVERLAY=(41:23,9,23:18Z)),           
  IFTHEN=(WHEN=(59,1,ZD,EQ,4),OVERLAY=(50:23,9,23:27Z))             
                                                                   
  SORT FIELDS=(1,22,CH,A),EQUALS                                   
  SUM FIELDS=(23,8,BI,31,8,BI,39,8,BI,47,8,BI,55,4,BI,60,1,ZD)     
                                                                   
  OUTFIL FNAMES=OUT1,INCLUDE=(60,1,ZD,EQ,1),BUILD=(1,31)           
  OUTFIL FNAMES=OUT2,INCLUDE=(60,1,ZD,EQ,2),BUILD=(1,31,/,1,22,32,9)
  OUTFIL FNAMES=OUT3,INCLUDE=(60,1,ZD,EQ,3),                       
  BUILD=(1,31,/,1,22,32,9,/,1,22,41,9)                             
  OUTFIL FNAMES=OUT4,INCLUDE=(60,1,ZD,EQ,4),                       
  BUILD=(1,31,/,1,22,32,9,/,1,22,41,9,/,1,22,50,9)                 
/*                                                                 


If your input is not sorted on the key use this 2 pass DFSORT/ICETOOL JCL which will give you the desired results.
Code:

//STEP0100 EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                           
//DFSMSG   DD SYSOUT=*                                           
//IN       DD *                                                   
AAAAAAAAAAAAAAAAAAAAAA20090501Y                                   
BBBBBBBBBBBBBBBBBBBBBB20090502Y                                   
BBBBBBBBBBBBBBBBBBBBBB20090503Y                                   
CCCCCCCCCCCCCCCCCCCCCC20090504Y                                   
CCCCCCCCCCCCCCCCCCCCCC20090505Y                                   
CCCCCCCCCCCCCCCCCCCCCC20090506Y                                   
DDDDDDDDDDDDDDDDDDDDDD20090507Y                                   
DDDDDDDDDDDDDDDDDDDDDD20090508Y                                   
DDDDDDDDDDDDDDDDDDDDDD20090509Y                                   
DDDDDDDDDDDDDDDDDDDDDD20090510Y                                   
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)       
//OUT1     DD SYSOUT=*                                           
//OUT2     DD SYSOUT=*                                           
//OUT3     DD SYSOUT=*                                           
//OUT4     DD SYSOUT=*                                           
//OUT5     DD SYSOUT=*                                           
//TOOLIN   DD *                                                   
  SORT FROM(IN) USING(CTL1)                                       
  SORT FROM(T1) USING(CTL2)                                       
//CTL1CNTL DD *                                                   
  SORT FIELDS=(1,22,CH,A)                                         
  OUTFIL FNAMES=T1,REMOVECC,BUILD=(1,31,2X),                     
  SECTIONS=(1,22,                                                 
  TRAILER3=(1,22,32:COUNT=(M11,LENGTH=1),'T'))                   
//CTL2CNTL DD *                                                   
  SORT FIELDS=(1,22,CH,A,32,1,CH,D),EQUALS                       
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(32,1,ZD,GT,0),PUSH=(32:32,1)) 
  OUTFIL FNAMES=OUT1,BUILD=(1,31),INCLUDE=(32,2,CH,EQ,C'1 ')     
  OUTFIL FNAMES=OUT2,BUILD=(1,31),INCLUDE=(32,2,CH,EQ,C'2 ')     
  OUTFIL FNAMES=OUT3,BUILD=(1,31),INCLUDE=(32,2,CH,EQ,C'3 ')     
  OUTFIL FNAMES=OUT4,BUILD=(1,31),INCLUDE=(32,2,CH,EQ,C'4 ')     
/*                                                               
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts To Merge mutliple records into a sing... anandgbe DFSORT/ICETOOL 6 Wed Feb 22, 2017 8:49 am


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