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
 

 

Sort input and keep only 1st occurrence of the duplicate rec

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

New User


Joined: 30 May 2007
Posts: 7
Location: India

PostPosted: Wed Sep 19, 2007 5:22 pm    Post subject: Sort input and keep only 1st occurrence of the duplicate rec
Reply with quote

Hi,
I have a requirement where the input file may have duplicate records. The file should be sorted such that if duplicates are present, then only the first occurrence/record is written to the output. For records with no duplicates, they also should be written to the same output.

Input -
AAAAA
BBBBB
CCCCC
AAAAA
CCCCC
DDDDD

OUTPUT expected-
AAAAA
BBBBB
CCCCC
DDDDD

I searched a sloution for this in the previous posts, but did not find one. Please help..

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

Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1288
Location: Chennai, India

PostPosted: Wed Sep 19, 2007 5:35 pm    Post subject: Reply to: Sort input and keep only 1st occurrence of the dup
Reply with quote

You can use ICETOOL SELECT operator

Code:

//DOIT    EXEC PGM=ICETOOL                                   
//TOOLMSG   DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//INP     DD DSN=...  input file                     
//OUT  DD DSN=...   output file
//TOOLIN      DD *                                           
SELECT  FROM(INP) TO(OUT) ON(1,5,CH) FIRST               
/*                                                           


Input:

Code:

AAAAA
BBBBB
CCCCC
AAAAA
CCCCC
DDDDD


Output:

Code:

AAAAA 
BBBBB 
CCCCC 
DDDDD 
Back to top
View user's profile Send private message
Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Wed Sep 19, 2007 8:00 pm    Post subject:
Reply with quote

Code:

//STEP10  EXEC PGM=SORT
//SYSOUT    DD SYSOUT=*               
//SORTIN    DD DSN=...,DISP=SHR
//SORTOUT   DD DSN=...                 
//SYSIN     DD *
  SORT FIELDS=(1,5,CH,A)
  SUM FIELDS=NONE                                       
/*
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: Wed Sep 19, 2007 8:34 pm    Post subject:
Reply with quote

Smita,

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html
Back to top
View user's profile Send private message
Smita Sebastian

New User


Joined: 30 May 2007
Posts: 7
Location: India

PostPosted: Thu Sep 20, 2007 11:24 am    Post subject: Reply to: Sort input and keep only 1st occurrence of the dup
Reply with quote

Hi.

Thanks Aaru. That worked!

Frank, the IBM link that you send is very useful. Thankyou.
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 SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm


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