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

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


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 1287
Location: Chennai, India

PostPosted: Wed Sep 19, 2007 5:35 pm
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
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 Developer


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

PostPosted: Wed Sep 19, 2007 8:34 pm
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:

Use [URL] BBCode for External Links
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Duplicate transid's declared using CEDA CICS 3
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top