Compare 2 files for the new records

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
Abhin
Member
Posts: 7
Joined: Thu Nov 06, 2014 4:33 pm

Compare 2 files for the new records

Post by Abhin » Thu Nov 06, 2014 4:39 pm

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:

User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

Post by Gurugars » Thu Nov 06, 2014 7:21 pm

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.
Guru:-)

You're never fully dressed without a smile :)

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Nov 07, 2014 12:57 am

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?

Abhin
Member
Posts: 7
Joined: Thu Nov 06, 2014 4:33 pm

Post by Abhin » Mon Nov 10, 2014 11:07 am

@ 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..

Abhin
Member
Posts: 7
Joined: Thu Nov 06, 2014 4:33 pm

Post by Abhin » Tue Nov 11, 2014 9:36 am

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!!!!

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Tue Nov 11, 2014 4:02 pm

You've ignored my questions and chosen to also ask elsewhere. Can't be that urgent if you have time for that.

Abhin
Member
Posts: 7
Joined: Thu Nov 06, 2014 4:33 pm

Post by Abhin » Tue Nov 11, 2014 4:44 pm

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.. :?

Abhin
Member
Posts: 7
Joined: Thu Nov 06, 2014 4:33 pm

Post by Abhin » Tue Nov 11, 2014 4:44 pm

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.. :?

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Tue Nov 11, 2014 7:03 pm

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?

Abhin
Member
Posts: 7
Joined: Thu Nov 06, 2014 4:33 pm

Post by Abhin » Wed Nov 12, 2014 11:43 am

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

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Nov 12, 2014 5:06 pm

You've got an answer elsewhere. Satisfied?

Abhin
Member
Posts: 7
Joined: Thu Nov 06, 2014 4:33 pm

Post by Abhin » Wed Nov 12, 2014 6:59 pm

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
:|

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others