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

Cobol internal sort to remove duplicate


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
psriv20
Currently Banned

New User


Joined: 25 May 2009
Posts: 19
Location: Pune

PostPosted: Mon Apr 18, 2011 2:48 pm
Reply with quote

Hi All,

I got a requirment to sort one file in cobol which could have duplicate records but we hae to write unique records into the output file.

thanks
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Apr 18, 2011 2:50 pm
Reply with quote

Why write a program when your SORT product will probably do this much faster and more efficiently
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 Apr 18, 2011 8:14 pm
Reply with quote

I don't know if you are thinking of coding your own sort, or doing a Cobol internal sort.

Without knowing more about your requirement, I'd recommend using your system sort in a step prior to the execution of your program. Then using the sorted file in the program. Keeps your program simple.

If you tell me, "well to do that, I'd have to split the program". Then I'd say, split it. Keep it simple.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Apr 19, 2011 6:08 pm
Reply with quote

As it's been already suggested - it's easy to use a SORT product right away in a Job would be easy, however, for a record - even if you write a Program to call the SORT - in back-end, your default SORT product will be invoked, you know.

Or if you insist (I assume there is some key, on which a record is called duplicate) --

Perform until end-of-file
READ the file
Move first read record in a temp varaible
READ "next reocrd"
compare "next reocrd" with the temp varaible
if on the key - records are same -- don't write to ouput
else write to ouput
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Apr 20, 2011 4:13 am
Reply with quote

Hi Anuj,

you are assuming the file is already sorted.


Gerry
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Apr 20, 2011 2:48 pm
Reply with quote

Yes Gerry, You're correct - I did assume that, forget to mention ... icon_redface.gif.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Apr 20, 2011 3:02 pm
Reply with quote

So if it is already sorted the duplicates can be removed at an earlier stage.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Apr 20, 2011 3:25 pm
Reply with quote

A riddle with many loose ends is right here...
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Tue Apr 26, 2011 11:10 am
Reply with quote

Hi,

I have executed such kind of request long back

While executing cobol program wih internal sort give following option at runtime

Code:
//SORTCNTL DD *
    SUM FIELDS=NONE


or

Code:
//IGZSRTCD DD *
  SUM FIELDS=NONE


Kindly let us know if it works

Regards,
Chandan
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Apr 28, 2011 12:22 pm
Reply with quote

Most mainframe sort utilities have a control statement keyword that will exclude duplicate occurences of the sort key values to be output. Search the manual for your sort product for 'duplicate'.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Duplicate transid's declared using CEDA CICS 3
Search our Forums:

Back to Top