Posted: Tue Jun 26, 2012 1:32 pm Post subject: SORT 2 FILES - OUTPUTING THE DIFFERENCES FROM BOTH INPUTS.
Hi everybody. I'm trying this since this morning...
I have 2 files, length 106 bytes.
1st is an old table unload.
2nd is the current table unload.
I need to compare both files and if anything is different I need to write a record using the old information and the new one, so the person will be able to check what was changed.
I would have a 212 bytes long output file.
I was trying this;
Code:
JOINKEYS FILE=F1,FIELDS=(1,106,A)
JOINKEYS FILE=F2,FIELDS=(1,106,A)
JOIN UNPAIRED,ONLY,F2
REFORMAT FIELDS=(F1:001,005, LOCN OLD 001-005
F2:001,005, LOCN NEW 006-005
F1:006,011, NDC-UPC-NBR OLD 011-011
F2:006,011, NDC-UPC-NBR NEW 022-011
F1:017,010, EFF-DTE OLD 033-010
F2:017,010, EFF-DTE NEW 043-010
F1:027,010, EXP-DTE OLD 052-010
F2:027,010, EXP-DTE NEW 063-010
F1:037,030, DESC OLD 073-030
F2:037,030, DESC NEW 103-030
F1:067,003, PERCENT OLD 133-003
F2:067,003, PERCENT NEW 136-003
F1:070,003, MIN-QTY OLD 139-003
F2:070,003, MIN-QTY NEW 142-003
F1:073,026, LST-MNT-TSMP OLD 145-026
F2:073,026, LST-MNT-TSMP NEW 171-026
F1:099,008, LST-OPR-ID OLD 197-008
F2:099,008) LST-OPR-ID NEW 205-008
SORT FIELDS=COPY
Any help please? _________________ The more I learn, the more I want to learn.
PEDRO CONTINUES THE SAME, SO, WE HAVE 5 SPACES AFTER IT.
2012-06-26 CONTINUES THE SAME, SO, WE HAVE 10 SPACES AFTER IT.
MANAGER WAS CHANGED TO PRESIDENT, SO, WE HAVE THE OLD INFORMATION AND THE NEW INFORMATION EIGHT AFTER IT. _________________ The more I learn, the more I want to learn.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Tue Jun 26, 2012 4:25 pm Post subject:
prog_mario,
Your are comparing entire record and then want to do a field by field comparison which makes it tough. There are ways to do but you would need DFSORT for that and you are running syncsort which does not support the features DFSORT has.
Kolusu
PS: use post using CODE tags . Check this link which explains the usage of code tags
If the files are guaranteed to be 1-for-1, you could append a sequence number to both files, join on the sequence number and compare whatever you'd like to compare.
This falls apart if the files have add/deleted information in additon to changed values. . . _________________ All the best,
Hi everybody I'm really glad receiving all that attention from all of you.
Talking with my business partner, he said that only 2 fields could be modified.
One thing I forgot to say (Kolusu) is that we have both dfsort and syncsort.
So I solved the problem this way:
Code:
********************************* Top of Data ***************
JOINKEYS FILE=F1,FIELDS=(1,36,A) file 1 key
JOINKEYS FILE=F2,FIELDS=(1,36,A) file 2 key
REFORMAT FIELDS=(F1:001,005, LOCN OLD 001-005
F1:006,011, NDC-UPC-NBR OLD 006-011
F1:017,010, EFF-DTE OLD 017-010
F1:027,010, EXP-DTE OLD 027-010
F1:037,030, DESC OLD 037-030
F1:067,003, PERCENT OLD 067-003
F1:070,003, MIN-QTY OLD 070-003
F2:073,026, LST-MNT-TSMP NEW 073-026
F2:099,008, LST-OPR-ID NEW 099-008
F2:067,003, PERCENT NEW 107-003
F2:070,003) MIN-QTY NEW 110-003
INCLUDE COND=(067,003,PD,NE,107,003,PD,OR,
070,003,PD,NE,110,003,PD)
SORT FIELDS=COPY
******************************** Bottom of Data *************
Thanks a lot guys, once again, for the attention. _________________ The more I learn, the more I want to learn.
If we had understood that the first part of the records is the "key" from the beginning, the answer would hav been found much sooner _________________ All the best,
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