IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

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

Senior Member


Joined: 14 Mar 2007
Posts: 10697
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

Moderator


Joined: 07 Sep 2006
Posts: 1566
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: 7312
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

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts Inserting records into the empty segm... IMS DB/DC 0
No new posts COBOL VS SORT Utility for file format... COBOL Programming 6
No new posts Copying data from prev record using SORT SYNCSORT 19
No new posts Combining more 4 files with sorted or... DFSORT/ICETOOL 3
No new posts Need to read duplicate rows from tabl... DB2 3

Back to Top