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

Removing Duplicates without changing the order of records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Thu Jun 24, 2010 10:59 pm
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
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
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
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 All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Format data from multiple records usi... SYNCSORT 4
No new posts Sort SMF records? SYNCSORT 6
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts Identify and write records containing... SYNCSORT 11
No new posts Filter records where condition is in ... SYNCSORT 6
Search our Forums:


Back to Top