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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
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 Rotate partition-logical & physic... DB2 0
No new posts changing defaults in db2 admin - Unlo... DB2 0
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top