View previous topic :: View next topic
|
Author |
Message |
renjithravi1 Warnings : 2 New User
Joined: 31 May 2005 Posts: 16
|
|
|
|
Hi All,
I have a requirement to remove the duplicates from a single input file.
The keys of the file are known and the file is already sorted based on the key. It is sure that there can be maximum of only 2 duplicates will be occuring in the file. I need to remove both the duplicates from the input file and create an output file. I should do this using a cobol program not by using sort. Kindly help me in this regard
Thanks and regards
Renjith |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Hang on, if the file is already sorted previously, why not just adapt the sort step to remove the duplicates. Save time, save effort, or is this another of them stupid requirements from somebody who knows naff all about the IT world. |
|
Back to top |
|
|
renjithravi1 Warnings : 2 New User
Joined: 31 May 2005 Posts: 16
|
|
|
|
Hi
Ok. Agreed. You know enough about IT world.
But think about the requirement which u r calling stupid, if sort utility was not there how you will do this? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Are you seriously telling me that your site does not have a sort product. |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Renjith,
renjithravi1 wrote: |
Ok. Agreed. You know enough about IT world. |
Expat, as we call him, is one of the most respected persons in the forum. After all, he has only given you a suggestion.
If I understood your requirement correctly, guess you would be able to do it, if you store the key in a temporary field. Each time u read the record, compare with this temporary key as process it.
Code: |
If KEY = TEMP-KEY
Discard the Record
Else
Write the record to the file
MOVE TEMP-KEY to KEY
End-if |
Fairly simple i should say... |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Let me try to understand:
renjithravi1 wrote: |
I need to remove both the duplicates from the input file and create an output file. |
As you said, if there are duplcates, at the most, there can be two. If so, you want to remove both of them? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Binop B wrote: |
Fairly simple i should say... |
Yes it is, But the question here is since the OP said "the file is already sorted based on the key", the common assumption is that, it was done using his sort product(unless his shop is still living with an internal COBOL SORT ). So why would we need to have another pass of data.
Quote: |
If so, you want to remove both of them? |
A few sample records might clarify what exactly the OP wants here. |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
I guess the answer is already given by expat...
Quote: |
is this another of them stupid requirements from somebody who knows naff all about the IT world |
|
|
Back to top |
|
|
renjithravi1 Warnings : 2 New User
Joined: 31 May 2005 Posts: 16
|
|
|
|
Hi All,
Thanks a lot for your expert opinions. I will find a way to do this. |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Renjith,
I thought i have already provided a solution...
Is not my solution acceptable.. |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Binop ,
Quote: |
Fairly simple i should say... |
do you think you code would be able to remove BOTH the records that are duplicate. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi Arun,
arcvns wrote: |
(unless his shop is still living with an internal COBOL SORT ). |
I'm not sure if you meant that "internal sort" in Cobol is somewhat different -- The internal sort and the external sort execute the same sort product, whichever is used on your system... |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
The internal sort and the external sort execute the same sort product, whichever is used on your system |
Hi Anuj,
Yes True, but AFAIK the latter is a little bit efficient. I was thinking if he is looking for an INTERNAL sort followed by some coding logic to remove the duplicates. Anyways the OP does n't seem to be interested to help us with some more info here. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
arcvns wrote: |
Anyways the OP does n't seem to be interested to help us with some more info here. |
Usual story on these Forums these days, as Kevin (superk) once said, "ow. my head hurts..." . |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
And which one is efficient is altogther a different story, we may start a different thread if you want... |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Succor wrote: |
Binop ,
Quote: |
Fairly simple i should say... |
do you think you code would be able to remove BOTH the records that are duplicate. |
As per my understanding of the requirement... i guess it should work...
I am guessing that what Renjith meant is,
Say if there is a field with key as AAAA, and there are chances that there could be two or less AAAA records immediately (duplicates) following the first AAAA record. and Renjith wanted to remove both the duplicates. I am guessing he wants to remove the other records keeping the first record.
Hope i have explained properly my understanding of the requirement... |
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Binop, Yes you have explained well .
My thought was that the OP would like to remove the whole set of records for which there are duplicates (which is again an assumption).
I reckon we should have gone by what Arun had asked for
Quote: |
A few sample records might clarify what exactly the OP wants here. |
|
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Succor wrote wrote: |
My thought was that the OP would like to remove the whole set of records for which there are duplicates (which is again an assumption). |
I too on my first read thought that was what Renjith wanted. But then, functionally, I thought such a requirement didnt make much sense... |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
... I should do this using a cobol program not by using sort ... |
Quote: |
Are you seriously telling me that your site does not have a sort product. |
just good old plain homework |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
enrico-sorichetti wrote: |
just good old plain homework |
I had thought about that... but then the guy, Renjith, has been active since almost a year. Looks odd for a guy to be doing Homework for almost a year... |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
has been active since almost a year |
I would rather say ...
has been inactive since almost a year, only 10 posts after all
and he should have known that if he wanted better replies he should have posted in a better way ...
these threads usually lower the benevolence factor of the TS/OP |
|
Back to top |
|
|
renjithravi1 Warnings : 2 New User
Joined: 31 May 2005 Posts: 16
|
|
|
|
Hi All,
Thanks for your expertise and suggestions so far. Let me explain you the requirement before i leave.
I have a file coming from some system, not from mainframe, dont know or dont care how it is coming sorted and specifications says it will be sorted.
So the file is sorted on the key and the file content example is below,
AA12345ZINSSXY
AA12345ZINSSXY
AA12345ZINSZXY
BB34444STUPSPP
My key is position 1 to 2 and 13 to 14
if two records have the same key and the value of the first record in position 8 to 12 is 'ZINSSS' and second record the same position has record 'ZINSSZ' then both the records have to be omitted from writing to output file, rest all records should be written to output file.
Of course my system has SORT and related tools, but for the records omitted a report should be printed and should be sent to business in specific format, for this the client feels using a cobol program is better.
So i have to do using program and i got the logic and did the program and first report has been successfully delivered.
To the point that i did only 10 posts during the last one year, i have explanation for that, it is not necessary for me to look at this everytime i am stuck, i know enough and i do my 'HOMEWORK' well and i have enough knowledge in IT. But sometimes too many things are need to be done from your side and you have a lots of work to do, all have to be done in one day, you think the best possibilities to reduce your time...that is the mistake i did and posted in this site..sorry for that...
Now you have the requirement clear...if you think about the logic or dont think i dont care!
Thanks a lot for all your help so far! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
that is the mistake i did and posted in this site |
Posting was not a mistake. Taking personal affront to replies might be. . . Keep in mind that replies are not directed at the poster nearly as often as they are directed at the idea
Unfortunately, your initial post was misunderstood by many and so most replies centered on a sort/utility solution. Had your most recent post been part of the topic start, this topic might have developed completely differently.
And yes, i agree with your client - i believe this is best served by code.
Quote: |
if you think about the logic or dont think i dont care |
Probably not the best way to proceed. . . Attitude is everything.
Quote: |
Thanks a lot for all your help so far! |
You're welcome - is this work complete now? |
|
Back to top |
|
|
renjithravi1 Warnings : 2 New User
Joined: 31 May 2005 Posts: 16
|
|
|
|
HI
Yes this work is complete now! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Good to hear it is working - thanks for letting us know
d |
|
Back to top |
|
|
|