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
 

 

Duplicate Check in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
zack786

New User


Joined: 22 May 2007
Posts: 3
Location: New York

PostPosted: Thu May 24, 2007 4:32 am    Post subject: Duplicate Check in COBOL
Reply with quote

Need help. I am reading a SYSIN PDS member file and loading a fixed length (80 bytes) table with 100 entries. But I need to check the SYSIN member to make sure there are no duplicate entries, before I load it to the table in memory.

What is the best way to accomplaish DUP CHECKING in COBOL. Thanks.
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu May 24, 2007 5:04 am    Post subject:
Reply with quote

Is the input sorted? Without it being sorted, you will need a 100 byte internal table, but if you are building a table, just scan prior to inserting.....
Back to top
View user's profile Send private message
zack786

New User


Joined: 22 May 2007
Posts: 3
Location: New York

PostPosted: Thu May 24, 2007 5:19 am    Post subject: Re: Dups Check in COBOL
Reply with quote

No the input is not sorted. How do I scan prior to loading ? BINARY SEARCH ?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu May 24, 2007 5:28 am    Post subject:
Reply with quote

Hello,

Read the external file, look in the table to see if the value is already there, if it is, skip that entry (if you're ignoring dups), as each value from the external file is read, it is loaded into the "next" available position in the table as long as it is not a duplicate.

I'd suggest making sure the external file is sorted before you build and use the table.
Back to top
View user's profile Send private message
zack786

New User


Joined: 22 May 2007
Posts: 3
Location: New York

PostPosted: Thu May 24, 2007 5:48 am    Post subject: Re: Dups Check in COBOL
Reply with quote

Thanks for your reply. OK I am sorry if I did not make myself clear. The table that I load table into memory stays in memory for the duration of the time-period that the job is up and running. The allocated memory block is cleared when the job comes down. Then again, I do the load (read sysin, check for dups, load into memory) when the job is submitted.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu May 24, 2007 6:22 am    Post subject:
Reply with quote

You're welcome.

Yes, i believe i understood that the external file would be read, loaded into the internal table, and be available for the duration of the run.

What i'm not sure of is whether you have what you need to proceed or if there remain any questions.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Thu May 24, 2007 5:59 pm    Post subject:
Reply with quote

Why not sort first and let the sort eliminate key dupes using "SUM FIELDS=NONE"?
Back to top
View user's profile Send private message
p_gandhi

New User


Joined: 20 Apr 2007
Posts: 14
Location: TORONTO,ONTARIO,CANADA

PostPosted: Mon May 28, 2007 6:21 pm    Post subject: Duplicate Check in COBOL
Reply with quote

I had the same kind of projects where I hae to eliminate the duplicates from the DB2 table, what I did as follows

1) Sort the file by keys
2) read the file
in main process

when keys not = previous keys
write to output file


read next

this way you writing file when keys are not same and when the keys are same or not you reading next and move the previous key to WS for comparing
Back to top
View user's profile Send private message
Raphael Bacay

New User


Joined: 04 May 2007
Posts: 58
Location: Manila, Philippines

PostPosted: Wed May 30, 2007 9:20 am    Post subject:
Reply with quote

That idea by Phrzby Phil looks like an efficient solution to your problem.
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
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


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