comparing two files on some fields

Ask/Clarify the questions on EASYTRIEVE

Moderators: DikDude, Moderator Group

Post Reply
jeevan
Member
Posts: 3
Joined: Fri Sep 24, 2010 10:15 am
Location: pune

comparing two files on some fields

Post by jeevan » Fri Sep 24, 2010 10:33 am

Hi All,
I am at initial stage of easitrieve. I have three files A,B,C.I want to match file A with file B on tran-id field and have to put matched records in OUTFILE1.Similarly I want to match file C with A on tran-id and put matched records in OUTFILE2.finaly i want unmatched records from filles A,B,C into OUTFILE3

thank,
Jeevan Jadhav
jeevan

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

EAZYTRIEVE FILE MATCHING

Post by Natarajan » Mon Sep 27, 2010 7:42 pm

You can use IF MATCHED command to do this.

Code: Select all

 

JOB INPUT (FILEA KEY(TRAN-IDA) +
                  FILEB KEY(TRAN-IDB) +
                  FILEC KEY(TRAN-IDC)   )


   IF MATCHED FILEA FILEB
           WRITE to OUTFILE1
    ELSE
            WRITE to exception file.
   END-IF 

   IF MATCHED FILEA FILEC
       WRITE to OUTFILE2
    ELSE
        WRITE to exception file.
   END-IF 

   

 ....
 .... 
Make sure files are sorted on tran-id before running this code.
Logic of above code may need to change, according to details of your requirement.
Natarajan
Chennai

jeevan
Member
Posts: 3
Joined: Fri Sep 24, 2010 10:15 am
Location: pune

Post by jeevan » Tue Sep 28, 2010 9:01 am

Thanks Natarajan,
code is working.
thanks lot.


Jeevan Jadhav
jeevan

jeevan
Member
Posts: 3
Joined: Fri Sep 24, 2010 10:15 am
Location: pune

Post by jeevan » Tue Sep 28, 2010 9:49 am

Hi Natarajan,
FileA is a seq.file.FileB and FileC are vsam files and all my outfiles are sequential so how can i get records without duplicates in exception file(output file3)
jeevan

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

EAZYTRIEVE file matching

Post by Natarajan » Tue Sep 28, 2010 3:24 pm

YES, there are more chances that you will write duplicate records into outputfile. Instead of write so much logic in the program to handle this. Using sort remove duplicates from exception file.

If it is not feasible, do let us know, we can work on to implement the logic for that.

First make sure, file A does not contain any duplicates. If it contain duplicates
program logic will become complex. since it is the driver file.
Natarajan
Chennai

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