Compare two files and write new file for add/delete/change
Posted: Mon Nov 10, 2014 6:57 am
I am writing a COBOL program to compare two files(sorted) Curr-file & Prev File.Both have layout as PersonID,DependentId,RelationType.
Single PersonId may have multiple DependentId with various relationship Types.
Whenever there is a change in RelationType I need to write a new o/p file as below.
PersonID,DependentId,RelationType, ADD/CHG/DEL, (--> need to add a indicator at end like ADD/CHG/DEL).
If there is no change in record then dont write.
Example :-
Prev-file have 10 records with one PersonId with various relationship Types for different DependentId
Curr File have 12 records with
6 unchanged records
2 new DependentId(which are not exists in prev file) and 2 new relation types
3 records have just change in relation types with old DependentId(as prev file)
Result file should contain
ADD - 2 records
CHG - 3 records
DEL - 1 record
I looked at example program ibm-cobol/file-match-merge-sample-code-t881.html, looks like it may not work as my file contains duplicate PersonId. Can anyone help me with some ideas?
Thanks.
Single PersonId may have multiple DependentId with various relationship Types.
Whenever there is a change in RelationType I need to write a new o/p file as below.
PersonID,DependentId,RelationType, ADD/CHG/DEL, (--> need to add a indicator at end like ADD/CHG/DEL).
If there is no change in record then dont write.
Example :-
Prev-file have 10 records with one PersonId with various relationship Types for different DependentId
Curr File have 12 records with
6 unchanged records
2 new DependentId(which are not exists in prev file) and 2 new relation types
3 records have just change in relation types with old DependentId(as prev file)
Result file should contain
ADD - 2 records
CHG - 3 records
DEL - 1 record
I looked at example program ibm-cobol/file-match-merge-sample-code-t881.html, looks like it may not work as my file contains duplicate PersonId. Can anyone help me with some ideas?
Thanks.