Posted: Wed Jan 08, 2003 11:25 am Post subject: comparing two files and adding record to new file..
Hi,
I have two files(old,new),, which are same FB sequential files and having key at the same column postion(let's assume at 5 chars length starts from 1st column).
My requirement :
I need to compare/find each and every record key(5 chars field) of old file with all new file records key and do the following
1) If find it in new file then nothing needs to be done(I mean no modifications to the new file)
2) If not found, then that old file record should append to the new file..
Will it possible by any utilities... other than Eztrieve/Cobol..
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Jan 08, 2003 11:37 am Post subject:
Anand_R,
Can there be duplicates in any of the files?? If the records are unique then it is an easy task to do. Please let me know the LRECL,RECFM of the 2 files.
Joined: 29 Nov 2002 Posts: 8 Topics: 1 Location: Calcutta India
Posted: Thu Jan 09, 2003 5:19 am Post subject:
If the files contain unique records, you can perform this task by using series of SORTs.
(1) append old file with the number '1' - OUTREC func in sort
(2) append new file with the number '2' - OUTREC func in sort
(3) do a sumfields on this new field keeping the 5 byte field in the "SORT FIELDS" clause and this new field in the "SUM FIELDS" clause
(4) any records still remaining with '1' can be included into a file - INCLUDE func in sort
(5) append this file with remaining '1's to the new file by concatenation - copy using sort
If you have duplicates, could you just let me know if both have duplicates or only the old can have duplicates or only new can have them.
Thanks a lot for your reply,, I am not much familiar with sort and I am learning this sort with mvsformus helpboard, If any of you can provide me code I can better understand ur explanation..
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Jan 09, 2003 7:07 am Post subject:
Anand_r,
The following DFSORT/ICETOOL JCL will give you the desired results.If you syncsort at your shop then change the pgm name to synctool.This job is similar to ajeykumar's explanation but slightly different as he forgot to take into consideration the matched records.
A Brief explanation of the Job.
The first copy operator takes in the NEWFILE and creates file T1 while appending a constant '1' at the end.
The second copy operator takes in the OLDFILE and creates file T2 while appending a constant '2' at the end.
Now we concatenate these 2 files together as CON( make sure that new file T1 is the first dsn name as we want the records for the match condition from newfile). we sum sort this con file on the constants added at the end. Any matched record will have a total of 3 in the 81 st byte.so we need that record. And you also want to append the records from the old file which will have '2' in the 81st byte as it does not have a match in the new file.
So we use the substring(SS) option to select the above 2 records.While writting out the records we will strip off the constants we added at the end.
Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Jan 09, 2003 12:08 pm Post subject:
Anand_r,
On second thoughts, you can do it in much easier way and in just one pass of data.The following DFSORT/ICETOOL JCL will give you the results.concatenate both files and use the SELECT operator with FIRST option.Make sure that newfile is the first file in concatenation.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Fri Feb 28, 2003 6:49 pm Post subject:
Kolusu,
I just noticed that you have:
Code:
//DFSPARM DD *
OPTION EQUALS
/*
for your DFSORT/ICETOOL SELECT job. You actually don't need to specify OPTION EQUALS since DFSORT automatically uses EQUALS for SELECT. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 70 Topics: 19 Location: California
Posted: Fri Feb 28, 2003 7:01 pm Post subject:
Anand_R,
Do you have Easytrieve in your shop. _________________ Venkataramana
-- Good judgement comes from experience, and often experience comes from bad judgement.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Sun Mar 02, 2003 5:06 pm Post subject:
Kolusu,
DFSORT's ICETOOL sets many options automatically for different operators to ensure the correct or optimum results. For example: EQUALS for SELECT ensures the correct results for the FIRST, LAST, FIRSTDUP and LASTDUP operands; DYNALLOC for SORT allows dynamic allocation of work data sets; etc. The options and statements that ICETOOL sets up for various operators is no secret given that they appear in the DFSMSG message data set.
Anyway, thanks for correcting your job. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
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