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

To Eliminates Duplicates and retain the first record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ramankapoor

New User


Joined: 27 Feb 2006
Posts: 23
Location: delhi

PostPosted: Mon Mar 06, 2006 9:42 am
Reply with quote

Hye.. please give me the the control card option to eliminates Duplicates and retain the first record.

To Eliminates Duplicates we have to do Sum=None
but to retain the first record what should i have to use . pls suggest..

To Eliminates Duplicates and retain the first record
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Mon Mar 06, 2006 10:02 am
Reply with quote

Hi,

Try this out..
Code:
//STEP0100 EXEC PGM=SORT 
//SORTIN   DD *           
1111 AAAA 2222           
1111 AAAA 3333           
1111 AAAA 2222           
/*                       
//SORTOUT  DD SYSOUT=*   
//SYSIN DD *             
  SORT FIELDS=(1,14,CH,A)
  SUM FIELDS=NONE         
/*                       


The out put will be
Code:
1111 AAAA 2222
1111 AAAA 3333


Change the key as per your requirements

Regards,
Back to top
View user's profile Send private message
ramankapoor

New User


Joined: 27 Feb 2006
Posts: 23
Location: delhi

PostPosted: Mon Mar 06, 2006 10:08 am
Reply with quote

But the solution u have given ,

in the output its showing two records while i like to retain just first record.
Back to top
View user's profile Send private message
fixdoubts

New User


Joined: 21 Oct 2005
Posts: 54

PostPosted: Mon Mar 06, 2006 10:26 am
Reply with quote

Hi,

There are only two distinct records

1111 AAAA 2222
1111 AAAA 3333

and the third record

1111 AAAA 2222

is a duplicate.

I think this is what u wanted. Keep only one record and eliminate dulicate
Back to top
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Mon Mar 06, 2006 10:41 am
Reply with quote

Hi,
The other alternative solution is to use Select clause with first dup option.

SELECT FROM(INDD) TO(OUTDD) ON(P,M,F) FIRSTDUP

Thanks
Krishy
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: Mon Mar 06, 2006 9:26 pm
Reply with quote

Quote:
please give me the the control card option to eliminates Duplicates and retain the first record.


There are two ways to do this with DFSORT as shown below:

Method 1 - DFSORT/ICETOOL SELECT FIRST

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file
//OUT DD DSN=...  output file
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(p,m,f) FIRST


p,m,f is the starting position, length and format of the key. You can use multiple ON fields if you have multiple keys.

Method 2 - DFSORT SUM with EQUALS

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION EQUALS
  SORT FIELDS=(p,m,f,A)
  SUM FIELDS=NONE
/*


EQUALS ensures that the first record of duplicates is kept (note that SELECT uses EQUALS automatically). p,m,f is the starting position, length and format of the key. You can use multiple keys if appropriate.

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
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 How to split large record length file... DFSORT/ICETOOL 7
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top