Page 1 of 1

Compare 2 files for the new records

Posted: Thu Nov 06, 2014 4:39 pm
by Abhin
Hi,

I have a requirement where I need to compare 2 files(old and new) and for any new records in the new file I need to insert "NEW" in the first 3 columns and for rest of the records first 3 columns should be blank .

All the records in the new file should be as it is except NEW for new records.

Any help will be highly appreciated
:idea:

Posted: Thu Nov 06, 2014 7:21 pm
by Gurugars
Hello Abhin,

Welcome to the forum.

It can be easily done with 'SORT JOIN'. There are loads of samples for 'SORT JOIN' in this forum itself. Please have a search on that and try by yourselve. If you are facing any issue, you can very well get back to us with YOUR TRY.

Posted: Fri Nov 07, 2014 12:57 am
by William Collins
Well, it will be a JOINKEYS.

What do you mean by a "compare"? Are you just looking for the presence of a key? Or comparing the data? Records on the old file which don't match (deletes) you're not interested in? What if the data has changed?

Posted: Mon Nov 10, 2014 11:07 am
by Abhin
@ Gurugars I am trying that..
@ Bill: I am comparing the data ,old file (F1) and new file (F2) If the data has changed and there are any new records in the new file , I should write 'NEW' in first 3 columns. I will keep rest of the file as it is .. both old and new..

Posted: Tue Nov 11, 2014 9:36 am
by Abhin
As of now I am able to copy the records which are in F2 but not in F1 using the below code:
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,79,A)
JOINKEYS FILE=F2,FIELDS=(1,79,A)
JOIN UNPAIRED,F2,ONLY
SORT FIELDS=COPY
/*

but I need all the records from F2 with 'NEW' string in front of new records, can this be done in single step? its an URGENT requirement.. F1!!!!

Posted: Tue Nov 11, 2014 4:02 pm
by William Collins
You've ignored my questions and chosen to also ask elsewhere. Can't be that urgent if you have time for that.

Posted: Tue Nov 11, 2014 4:44 pm
by Abhin
Abhin wrote:@ Gurugars I am trying that..
@ Bill: I am comparing the data ,old file (F1) and new file (F2) If the data has changed and there are any new records in the new file , I should write 'NEW' in first 3 columns. I will keep rest of the file as it is .. both old and new..
Hi Bill, I did reply for your question as quoted above.. :?

Posted: Tue Nov 11, 2014 4:44 pm
by Abhin
Abhin wrote:@ Gurugars I am trying that..
@ Bill: I am comparing the data ,old file (F1) and new file (F2) If the data has changed and there are any new records in the new file , I should write 'NEW' in first 3 columns. I will keep rest of the file as it is .. both old and new..
Hi Bill, I did reply for your question as quoted above.. :?

Posted: Tue Nov 11, 2014 7:03 pm
by William Collins
What do you mean by a "compare"? Are you just looking for the presence of a key? Or comparing the data? Records on the old file which don't match (deletes) you're not interested in? What if the data has changed?
Perhaps you can indicate what from your reply answers which question?

Posted: Wed Nov 12, 2014 11:43 am
by Abhin
Hi

I am comparing the data , not any particular keys.
If data has changed and record is there in new file but not the old , I have to write 'NEW' in front of the new record .other matched records in new file will have just spaces instead of NEW.

New file
1
2
4

Old file
1
2
3

Output should be (All the records in new file but New in front of new record)
1
2
New 4

Posted: Wed Nov 12, 2014 5:06 pm
by William Collins
You've got an answer elsewhere. Satisfied?

Posted: Wed Nov 12, 2014 6:59 pm
by Abhin
Hi Bill
As it was urgent I posted it in different forums. Sorry, I was unaware of it. Thank you for your time. have a nice Day
:|