Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 BUT RETAIN HIGHEST VALUE ON NON-... leondan22 DFSORT/ICETOOL 2 Thu Dec 14, 2017 8:13 pm
No new posts Extract record for change in combinat... Trinadh DFSORT/ICETOOL 6 Thu Nov 23, 2017 3:32 pm
No new posts JOINKEYS Paired and Unpaired Sort on ... MFwhiz DFSORT/ICETOOL 7 Tue Nov 07, 2017 2:46 am
No new posts Copy selected columns from 2 input fi... Poha Eater DFSORT/ICETOOL 3 Thu Nov 02, 2017 3:43 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us