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

Get Duplicate records based on particular field


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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
Reply with quote

krisprems

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

Moderator Emeritus


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

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

Moderator Emeritus


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

PostPosted: Thu Dec 20, 2007 9:03 pm
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
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 Developer


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

PostPosted: Thu Dec 20, 2007 10:39 pm
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
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

Moderator Emeritus


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

PostPosted: Fri Dec 21, 2007 9:04 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Duplicate transid's declared using CEDA CICS 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top