View previous topic :: View next topic
|
Author |
Message |
psriv20 Currently Banned New User
Joined: 25 May 2009 Posts: 19 Location: Pune
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Why write a program when your SORT product will probably do this much faster and more efficiently |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Anuj,
you are assuming the file is already sorted.
Gerry |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Yes Gerry, You're correct - I did assume that, forget to mention ... . |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
So if it is already sorted the duplicates can be removed at an earlier stage. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
A riddle with many loose ends is right here... |
|
Back to top |
|
|
chandan.inst
Active User
Joined: 03 Nov 2005 Posts: 275 Location: Mumbai
|
|
|
|
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 |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
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 |
|
|
|