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
 

 

Need logic to remove duplicates from same file
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
renjithravi1
Warnings : 2

New User


Joined: 31 May 2005
Posts: 16

PostPosted: Fri Aug 21, 2009 9:43 am    Post subject: Need logic to remove duplicates from same file
Reply with quote

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
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Aug 21, 2009 11:28 am    Post subject:
Reply with quote

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
View user's profile Send private message
renjithravi1
Warnings : 2

New User


Joined: 31 May 2005
Posts: 16

PostPosted: Fri Aug 21, 2009 11:59 am    Post subject:
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Aug 21, 2009 12:03 pm    Post subject:
Reply with quote

Are you seriously telling me that your site does not have a sort product.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Aug 21, 2009 12:31 pm    Post subject:
Reply with quote

Hi Renjith,

renjithravi1 wrote:
Ok. Agreed. You know enough about IT world.

icon_rolleyes.gif
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... icon_wink.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Fri Aug 21, 2009 12:51 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Aug 21, 2009 1:11 pm    Post subject:
Reply with quote

Binop B wrote:
Fairly simple i should say... icon_wink.gif
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 icon_mad.gif ). 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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Aug 21, 2009 1:14 pm    Post subject:
Reply with quote

I guess the answer is already given by expat... icon_lol.gif

Quote:
is this another of them stupid requirements from somebody who knows naff all about the IT world
Back to top
View user's profile Send private message
renjithravi1
Warnings : 2

New User


Joined: 31 May 2005
Posts: 16

PostPosted: Fri Aug 21, 2009 1:31 pm    Post subject:
Reply with quote

Hi All,

Thanks a lot for your expert opinions. I will find a way to do this.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Aug 21, 2009 1:57 pm    Post subject:
Reply with quote

Hi Renjith,

I thought i have already provided a solution... icon_rolleyes.gif

Is not my solution acceptable.. icon_sad.gif
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Fri Aug 21, 2009 2:31 pm    Post subject: Reply to: Need logic to remove duplicates from same file
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Fri Aug 21, 2009 2:52 pm    Post subject:
Reply with quote

Hi Arun,
arcvns wrote:
(unless his shop is still living with an internal COBOL SORT icon_mad.gif ).
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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Fri Aug 21, 2009 3:09 pm    Post subject:
Reply with quote

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. icon_lol.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Fri Aug 21, 2009 3:30 pm    Post subject:
Reply with quote

arcvns wrote:
Anyways the OP does n't seem to be interested to help us with some more info here. icon_lol.gif
Usual story on these Forums these days, as Kevin (superk) once said, "ow. my head hurts..." icon_smile.gif.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


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

PostPosted: Fri Aug 21, 2009 3:39 pm    Post subject:
Reply with quote

And which one is efficient is altogther a different story, we may start a different thread if you want... icon_biggrin.gif
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Aug 21, 2009 4:44 pm    Post subject: Re: Reply to: Need logic to remove duplicates from same file
Reply with quote

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... icon_razz.gif

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... icon_smile.gif
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Fri Aug 21, 2009 6:16 pm    Post subject: Reply to: Need logic to remove duplicates from same file
Reply with quote

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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Aug 21, 2009 8:17 pm    Post subject: Re: Reply to: Need logic to remove duplicates from same file
Reply with quote

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... icon_razz.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Aug 21, 2009 8:37 pm    Post subject: Reply to: Need logic to remove duplicates from same file
Reply with quote

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
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Fri Aug 21, 2009 8:50 pm    Post subject: Re: Reply to: Need logic to remove duplicates from same file
Reply with quote

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... icon_razz.gif
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Updating the counters after eliminati... PANDU1 DFSORT/ICETOOL 12 Mon Nov 21, 2016 9:47 am
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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