Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding the duplicate and original records.

Status
Not open for further replies.

imrexx

Programmer
Nov 9, 2005
12
0
0
US
Hi

I think i need to post this question in JCL forum. but i didn't find that forum. Any one Please help me in this.

I need to read the file and when a record is duplicate then i need to get both the duplicate and original record in a dataset. This need to be done in a JCL with either sort or ICETOOL not in the cobol program.
Eg: Assume we have 5 records.
aa
bb
aa
cc
ee

i need both "aa" records in a seperate dataset.
Could any one please help me in this?

Thanks
Imran
 
1. Sort the file.
2. Initialize working storage.
3. Read the file:
If key field = key field in working storage
then you have a duplicate
else no duplicate.
4. Save the record into working storage.
5. Repeat 3 thru 4.

The problem with your question is that which one of the records will signify as original and or duplicate. Do you have to assume that the first occurence is the original? Think about 3 sets of pictures. Which of the three is the original and which ones are duplicates.
 
By specifying WITH DUPLICATES IN ORDER, then the first record of any duplicate set will be the original, or at least pysically the first.
 
What do you mean by the record being a 'duplicate'? A duplicate key? The entire record being the same? If it is the entire record then what difference does it make which one is written out....they are the same :)

 
Why did you ever allow a duplicate Key?

Is this VSAM with no keys?

So like you want a sort that eliminates non-duplicates.


This site has a lot of COBOL Gurus on it also. Has a JCL Help section, but it emphasizes MVS Systems.


If you do not like my post feel free to point out your opinion or my errors.
 
Obviously, you can code a COBOL program to do this, but I think you're looking for an MVS utility. SYNCSORT will let you throw duplicates into a dataset (SUM FIELDS=NONE,XSUM), but it won't allow you to throw both records into a dataset.

If it was me, I'd sort the dataset with SYNCSORT and write a quick program (probably in REXX) to go through and toss pairs into an output dataset.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top