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
 

 

Get Duplicate records based on particular field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Aham

New User


Joined: 24 Oct 2007
Posts: 42
Location: chennai

PostPosted: Wed Dec 19, 2007 1:19 pm    Post subject: Get Duplicate records based on particular field
Reply with quote

Hi My Input file has a LRECL 80 and RECFM FB. I have to check whether records has a particular field as duplicate and if so I need to include all of them in a dataset.

Input
Code:

____5____0____5____0
ANYTHING BLUE STREET 
SMETHING RED CITY     
DIFFTHNG BLUE COUNTRY 


Here say my second field starting from position 10 is the deciding field. So Now Record 1 and record 3 should contiasn same value 'BLUE' hence the records containing them would be considered duplicate and I want both of these records in an output dataset. Is that possible with Synctool?
Back to top
View user's profile Send private message

krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Dec 19, 2007 1:26 pm    Post subject:
Reply with quote

Here is the SYNCTOOL solution
Code:
//*******************************************************
//GETMATCH EXEC PGM=SYNCTOOL                             
//TOOLMSG  DD SYSOUT=*                                   
//DFSMSG   DD SYSOUT=*                                   
//IN       DD *                                         
ANYTHING BLUE STREET                                     
SMETHING RED  CITY                                       
----+----1----+----2----+----3----+----4----+----5----+--
DIFFTHNG BLUE CUNTRY                                     
/*                                                       
//ALLDUP   DD SYSOUT=*                                   
//TOOLIN   DD *                                         
         SELECT FROM(IN) TO(ALLDUP) ON(10,4,CH) ALLDUPS 
/*                                                       
//*                                                     
Back to top
View user's profile Send private message
Aham

New User


Joined: 24 Oct 2007
Posts: 42
Location: chennai

PostPosted: Wed Dec 19, 2007 1:55 pm    Post subject:
Reply with quote

krisprems

Thanks a lot. Your code worked fine.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Dec 19, 2007 8:49 pm    Post subject:
Reply with quote

Hello,

What if there was one more record?

Code:

____5____0____5____0
ANYTHING BLUE STREET 
SMETHING RED CITY     
DIFFTHNG BLUE CUNTRY 
ANOTHER  ORANGE AVENUE 
Back to top
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Thu Dec 20, 2007 4:19 pm    Post subject:
Reply with quote

Quote:
Hello,

What if there was one more record?


dick,

What is it that you were planning to convey??

Even if there is another record like what u showed, according to Krisprem's sortcard, the output should come fine with the duplicates being shown correctly. i.e. only records with BLUE in poistion 10-14 will come in the output.

Is there something between the lines that I am missing?? icon_surprised.gif icon_surprised.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Dec 20, 2007 9:03 pm    Post subject:
Reply with quote

Hello,

Quote:
What is it that you were planning to convey??
If the data in the "color" field is not exactly a length of 3 or 4, the code will not work. . .

Notice the "overlap" of ORANGE with the prior records. Notice what would happen if the "color" field data was only 2 bytes long.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Dec 20, 2007 9:14 pm    Post subject:
Reply with quote

Quote:
If the data in the "color" field is not exactly a length of 3 or 4, the code will not work. . .
Yes, code wont work in that scenario.
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: Thu Dec 20, 2007 10:39 pm    Post subject:
Reply with quote

Aham,

If you have access to DFSORT, you can use the PARSE function in a DFSORT/ICETOOL job like the following. However, note that this won't work with Syncsort/SYNCTOOL since it doesn't support the PARSE function.

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
ANYTHING BLUE STREET
SMETHING RED CITY
ANY   PURPLE PLAZA
MY PURPLE PEOPLEEATER
DIFFTHNG   BLUE COUNTRY
ANOTHER  ORANGE AVENUE
/*
//OUT DD SYSOUT=*
//TOOLIN   DD    *
SELECT FROM(IN) TO(OUT) ON(81,12,CH) ALLDUPS USING(CTL1)
/*
//CTL1CNTL DD *
  INREC PARSE=(%=(ENDBEFR=BLANKS),
              %01=(ENDBEFR=C' ',FIXLEN=12)),
    OVERLAY=(81:%01)
  OUTFIL FNAMES=OUT,BUILD=(1,80)
/*


For the example, OUT would have:

Code:

ANYTHING BLUE STREET       
DIFFTHNG   BLUE COUNTRY     
ANY   PURPLE PLAZA         
MY PURPLE PEOPLEEATER       
Back to top
View user's profile Send private message
Aham

New User


Joined: 24 Oct 2007
Posts: 42
Location: chennai

PostPosted: Fri Dec 21, 2007 2:48 pm    Post subject:
Reply with quote

Thans a lot for the voluntary help by ll of you. My requirement is fixed and so I did nt have trouble using krisperms code .
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Dec 21, 2007 9:04 pm    Post subject: Reply to: Get Duplicate records based on particular field
Reply with quote

You're welcome icon_smile.gif

Thank you for letting us know.

d
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 -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm


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