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

Limit duplicate records in the SORT


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Mon Nov 21, 2016 12:54 pm
Reply with quote

Hi All,
I have a requirement to limit number of duplicate records in a file.

For e.g:
Below is the record pattern

Code:
AAA
AAA
BBB
BBB
BBB
BBB
CCC
CCC
CCC
DDD

Requirement is to have max 2 duplicate records. So my o/p should be

Code:
AAA
AAA
BBB
BBB
CCC
CCC
DDD

Thanks.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon Nov 21, 2016 1:03 pm
Reply with quote

tell us what sort product You will be using.

look at the messages

WER... ==> SYNCSORT
ICE... ==> IBM DFSORT

and the topic will be moved to the proper section
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Mon Nov 21, 2016 1:06 pm
Reply with quote

We use SYNCSORT
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Mon Nov 21, 2016 2:09 pm
Reply with quote

Use WHEN=GROUP
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Nov 21, 2016 2:22 pm
Reply with quote

Assuming your data is in key order, extend record temporarily with a sequence number, with RESTART= for the key, and out OUTFIL with INCLLUDE=/OMIT= to do the limiting, with BUILD to drop off the extension.

The same could be achieved with WHEN=GROUP, but if the key is on each record, in the same position, then it is better to use the plain sequence number.
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Mon Nov 21, 2016 3:50 pm
Reply with quote

Hi Bill,

Yes, its in sorted order and key is always in same position.
Back to top
View user's profile Send private message
pshongal

New User


Joined: 14 Jun 2012
Posts: 96
Location: India

PostPosted: Mon Nov 21, 2016 4:01 pm
Reply with quote

Thanks Bill & Pandora for your suggestion.

I used sequence number technique. It works. Thanks a lot
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
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
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
Search our Forums:

Back to Top