Posted: Mon Jan 16, 2006 4:26 am Post subject: To write duplicate records into another file using SORT.
Hi,
I have a problem while doing the SORT of a file. My file contains data in the following format. Suppose the file has two fields A1 and A2 and the file format is as below :
Code:
A1 A2
------ ----
XXXX Y
BBBB F
GHGH Y
XXXX Y
AAAA Y
BBBB I
I want to count the total number of duplicate records for which the fields in A1 match and the value of A2 is Y (for the above given example the record is XXXX Y). At the sametime I also want to write the duplicate records into an output file. Can anyone tell me what will be the SUM FILEDS parameter and also how to write to a new file for this if at all this is possible by JCL. Else I think I have to write a COBOL program using internal sort for this.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Mon Jan 16, 2006 5:23 am Post subject:
ayashp,
Please provide the following information: LRECL & RECFM of your input file and a sample output file. The word "Duplicate" can be interpreted in different ways. For example, you have 2 records with "XXXX Y" - the first record is considered as a unique record and the second & subsequent ones are considered duplicate entries. In such case, how you like to display the count - (2 or 1 - Including the first entry or not ?)
Quote:
I want to count the total number of duplicate records for which the fields in A1 match and the value of A2 is Y
So, do you want to have totals for each key ??? or do you need a grand total ???. Please provide a sample output, which can avoid all sorts of guess work !.
Hi Phantom,
Below is a sample file that can be considered as input file.
XXXXY
FGHJB
FGHJB
XXXXY
XXXX
AAAAY
BBBBY
XXXXY
The File is a Fixed length file and LRECL is 5. I want to write all the duplicates from this input file into another output file. The duplicate records should have the last field as Y. I need a grand total of all the duplicates.
So my output file can look like this
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum