I have a situation.
There are 2 sequential files with account number as a field in the record. Now we have to check for the matching account numbers in both the files and put it in a output file and the account numbers that are not matching in a second output file.
I want the algorithm for this.
Mind you the number of records are more than a million, normal algorithm would take lot of time.
I want the algorithm which takes the least time.
1. Make both data files indexed on account number. (Organization is indexed).
2. read first file sequentially.
(read first-file next record at end
3. move acno1 to acno2.
4. read second file write records accordingly.
(ie. Read second-file not invalid key
invalid key write output2-rec.)
thats the problem, we cannot delete the record from the file as it may be reuqired for some other purpose. after that the only solution is to make the local copy and then work on that but that will take so much time and space. Again we have to loop for the whole of the second file.
A small bit of Eazytreive will provide you the solution.The only thing is sort the files based on account number and then the sorted files are passed as input to eazytreive and you will get the two desired files.
IBD-OFFC 1 025 A
OFFC 1 008 A
IBD-OFFC1 1 025 A
OFFC1 1 008 A
OBD-OFFC 1 025 A
OFFCO1 1 008 A
OBD-OFFC1 1 025 A
OFFCO2 1 008 A
PERFORM COMPARE THRU COMPARE-EXIT
IF ACCOUNT-KEY-1 = ACCOUNT-KEY-2
IF ACCOUNT-KEY-1 < ACCOUNT-KEY-2
SET ACCOUNT-FILE-1-EOF TO TRUE
MOVE 999999 TO ACCOUNT-KEY-1
SET ACCOUNT-FILE-2-EOF TO TRUE
MOVE 999999 TO ACCOUNT-KEY-2