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
 

 

remove dublicates and keep last record

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

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Wed Apr 06, 2011 6:04 pm    Post subject: remove dublicates and keep last record
Reply with quote

Hello

Can you please tell me how can I remove duplicate records from a FB data set of length and keep the last record in output file instead of keeping the first record

Ex

AAAAAAAAAA04012007
AAAAAAAAAA04012008
AAAAAAAAAA04012009
AAAAAAAAAA04012010
BBBBBBBBBB04012007
BBBBBBBBBB04012008
BBBBBBBBBB04012009
BBBBBBBBBB04012010

First 10 bytes is key and next 8 bytes is date value, I need to sort this file for unique key values and keep last record of that particular key in output file, which mean my output should be

AAAAAAAAAA04012010
BBBBBBBBBB04012010

Can this achieved with sort?
Back to top
View user's profile Send private message

Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Apr 06, 2011 6:30 pm    Post subject:
Reply with quote

OK...
Tell us what output you are expected if your input file is like
Code:

AAAAAAAAAA04012007
AAAAAAAAAA04012008
AAAAAAAAAA04012010
AAAAAAAAAA04012009
BBBBBBBBBB04012007
BBBBBBBBBB04012008
BBBBBBBBBB04012009
BBBBBBBBBB04012010

should it be
Code:
AAAAAAAAAA04012010
BBBBBBBBBB04012010

or

Code:
AAAAAAAAAA04012009
BBBBBBBBBB04012010
Back to top
View user's profile Send private message
Hima1985

New User


Joined: 17 Apr 2009
Posts: 70
Location: India

PostPosted: Wed Apr 06, 2011 6:54 pm    Post subject:
Reply with quote

Sambhaji

Thanks for the response, Records won't be like that, highest year record will the last record for particular key. So that scenario will not come.

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

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed Apr 06, 2011 7:43 pm    Post subject:
Reply with quote

Try,
Code:
//S1    EXEC  PGM=ICETOOL                   
//SYSOUT    DD  SYSOUT=*                     
//DFSMSG    DD  SYSOUT=*                     
//TOOLMSG   DD  SYSOUT=*                     
//IN        DD *                             
AAAAAAAAAA04012007                           
AAAAAAAAAA04012008                           
AAAAAAAAAA04012009                           
AAAAAAAAAA04012010                           
BBBBBBBBBB04012007                           
BBBBBBBBBB04012008                           
BBBBBBBBBB04012009                           
BBBBBBBBBB04012010                           
/*                                           
//OUT       DD SYSOUT=*                     
//TOOLIN    DD *                             
  SELECT FROM(IN) TO(OUT) ON(1,10,CH) LAST   
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed Apr 06, 2011 9:10 pm    Post subject:
Reply with quote

Hima1985,

If the input data is already sorted on the key and date then you can use a COPY operation instead of sort like shown below.

Code:

//STEP0100 EXEC PGM=SORT         
//SYSOUT   DD SYSOUT=*           
//SORTIN   DD *                   
AAAAAAAAAA04012007               
AAAAAAAAAA04012008               
AAAAAAAAAA04012009               
AAAAAAAAAA04012010               
BBBBBBBBBB04012007               
BBBBBBBBBB04012008               
BBBBBBBBBB04012009               
BBBBBBBBBB04012010               
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD *                   
  SORT FIELDS=COPY               
  OUTFIL REMOVECC,NODETAIL,       
  SECTIONS=(1,10,TRAILER3=(1,80))
//*
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 Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts To Merge mutliple records into a sing... anandgbe DFSORT/ICETOOL 6 Wed Feb 22, 2017 8:49 am
No new posts Remove junk values in a file and rite... KP1125 DFSORT/ICETOOL 2 Wed Jan 25, 2017 9:58 pm


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