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
 

 

Removing Duplicates without changing the order of records

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

New User


Joined: 05 Apr 2010
Posts: 41
Location: Kolkata,India

PostPosted: Thu Jun 24, 2010 10:39 pm    Post subject: Removing Duplicates without changing the order of records
Reply with quote

Hi,

I've a flat file(FB,LRECL=80) with duplicate record on key(position 1-5).
I need a output file with unique record on the key(1-5) keeping the input order of records intact.

I/P file

Code:
AAAAA
AAAAA
AAAAA
ZZZZZ
ZZZZZ
BBBBB
BBBBB
QQQQQ
QQQQQ
CCCCC
XXXXX
XXXXX


o/P file

Code:
AAAAA
ZZZZZ
BBBBB
QQQQQ
CCCCC
XXXXX


keys come in a block i.e 'AAAAA' never appears after the first 3 occurence.Same for other records.

I tried to sort it but the o/p file appears in sorted order.I need to preserve the initial order.
Any help
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Jun 24, 2010 10:59 pm    Post subject:
Reply with quote

Here's a DFSORT job that will do what you asked for:

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN DD *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(1,5)))
  OUTFIL INCLUDE=(81,8,ZD,EQ,1),BUILD=(1,80)
/*
Back to top
View user's profile Send private message
razesh84

New User


Joined: 05 Apr 2010
Posts: 41
Location: Kolkata,India

PostPosted: Thu Jun 24, 2010 11:21 pm    Post subject:
Reply with quote

That was quick sir 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: Fri Jun 25, 2010 4:05 am    Post subject: Reply to: Removing Duplicates without changing the order of
Reply with quote

razesh84,

Alternatively you can use SELECT operator with FIRST and COPY to get the desired results

Code:

//STEP0100 EXEC PGM=ICETOOL                                 
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN       DD *                                             
AAAAA                                                       
AAAAA                                                       
AAAAA                                                       
ZZZZZ                                                       
ZZZZZ                                                       
BBBBB                                                       
BBBBB                                                       
QQQQQ                                                       
QQQQQ                                                       
CCCCC                                                       
XXXXX                                                       
XXXXX                                                       
//OUT      DD SYSOUT=*
//TOOLIN   DD *                           
  SELECT FROM(IN) TO(OUT) ON(1,5,CH) FIRST USING(CTL1)
//CTL1CNTL DD *                           
  OPTION COPY                             
//*                                       
Back to top
View user's profile Send private message
razesh84

New User


Joined: 05 Apr 2010
Posts: 41
Location: Kolkata,India

PostPosted: Fri Jun 25, 2010 9:46 pm    Post subject:
Reply with quote

Thanks Skolusu
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 Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts Updating the counters after eliminati... PANDU1 DFSORT/ICETOOL 12 Mon Nov 21, 2016 9:47 am
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


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