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
 

 

Cobol internal sort to remove duplicate

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Cobol internal sort to remove duplicate
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: 8593
Location: Back in jolly old England

PostPosted: Mon Apr 18, 2011 2:50 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Mon Apr 18, 2011 8:14 pm    Post subject: Reply to: Cobol internal sort to remove duplicate
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

Senior Member


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

PostPosted: Tue Apr 19, 2011 6:08 pm    Post subject:
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: 1703
Location: Australia

PostPosted: Wed Apr 20, 2011 4:13 am    Post subject:
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

Senior Member


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

PostPosted: Wed Apr 20, 2011 2:48 pm    Post subject:
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: 1800
Location: UK

PostPosted: Wed Apr 20, 2011 3:02 pm    Post subject:
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

Senior Member


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

PostPosted: Wed Apr 20, 2011 3:25 pm    Post subject:
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: 269
Location: Mumbai

PostPosted: Tue Apr 26, 2011 11:10 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts Db2 load job abending in SORT mistah kurtz DB2 4 Mon Jun 05, 2017 3:58 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am


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