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

How to get the records from a file which have dup values


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
subhasis_50

Moderator


Joined: 09 Mar 2005
Posts: 363
Location: Earth

PostPosted: Mon May 16, 2005 2:27 pm
Reply with quote

Hi,
I have a file. Which contains some records.
Lets consider 1,2,3,4,5 total five records are there.
From them 2 & 3 are same. How i can sort the file that only record comes in the output file which has duplicate value. Here the record 2 should come.
Thanks
Subhasis
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Mon May 16, 2005 3:05 pm
Reply with quote

Use "SUM FIELDS=NONE" to remove duplicate entries from the Input File.

Regards,

Priyesh.
Back to top
View user's profile Send private message
subhasis_50

Moderator


Joined: 09 Mar 2005
Posts: 363
Location: Earth

PostPosted: Mon May 16, 2005 3:11 pm
Reply with quote

Priyesh,
if i have used sum fields=none, then the output file will contains record 1,4,5 and 2. It will not only give the records which has duplicate. It will give other records also. My requirement is to get only those records which have duplicate values.
Thanks
Subhasis
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Mon May 16, 2005 3:22 pm
Reply with quote

Use ICETOOL as you can see below:
//TOOLIN DD *
SELECT FROM(INDD) TO(OUTDD) ON(1,22,CH) FIRST -
DISCARD(SAVEDD)

You will have in output only the first record and other in SAVEDD.
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Mon May 16, 2005 3:34 pm
Reply with quote

The best answer to your request is posted in this recent topic:
http://ibmmainframes.com/viewtopic.php?t=2582
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Mon May 16, 2005 3:58 pm
Reply with quote

Hi Subhasis,

Use this one...

Code:
//S1     EXEC PGM=ICETOOL                   
//TOOLMSG   DD SYSOUT=*                       
//DFSMSG    DD SYSOUT=*                       
//IN     DD DSN=INPUT,DISP=SHR
//OUT    DD DSN=OUT,         
//          DISP=(,CATLG,DELETE),             
//          RECFM=FB,LRECL=80,                 
//          SPACE=(80,(10,10),RLSE)           
//TOOLIN DD *                                 
  SELECT FROM(IN) TO(OUT) ON(1,5,CH) FIRSTDUP
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 May 16, 2005 8:53 pm
Reply with quote

Subhasis,

If your input looks something like this:

KEY1 R01
KEY2 R02
KEY2 R03
KEY3 R04
KEY4 R05

and you want your output to be:

KEY2 R02

then this DFSORT/ICETOOL job will do what you want:

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(1,5,CH) FIRSTDUP
/*


If you want your output file to look like this:

KEY2 R03

Use LASTDUP instead of FIRSTDUP in the SELECT operator.

For complete details on all of the things you can do with the SELECT operator of DFSORT's ICETOOL, see:

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA10/6.11?DT=20050222160456

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, 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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top