IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Separate duplicate records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 2481
Location: @my desk

PostPosted: Tue May 12, 2009 5:07 pm
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
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: 2481
Location: @my desk

PostPosted: Tue May 12, 2009 7:16 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Duplicate transid's declared using CEDA CICS 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top