Page 1 of 1

Compare 2 Files

PostPosted: Thu Mar 27, 2008 4:23 pm
by sukumarit
Hey i want to compare two files say A & B . If there was a match found between the files then i need to update the file B with the details of File A.
Input :
A - sequential file
111 AAAA Mumbai
222 BBBB Chennai
333 CCCC Delhi

B VSAM File
222 BBBB
444 DDDD

Output File
B VSAM File
222 BBBB Chennai
444 DDDD

Re: Compare 2 Files

PostPosted: Thu Mar 27, 2008 7:25 pm
by arunprasad.k
ESDS or KSDS??

If I were you I would go with a simple COBOL program.

Something like:
OPEN INPUT FILE1
     I-O   FILE2
PERFORM UNTIL EOF-FILE1
      READ FILE1
               AT END SET EOF-FILE1 TO TRUE
      END-READ.
      IF NOT EOF-FILE1
          MOVE KEY-FILE1   TO  KEY-FILE2
          READ FILE2
                   NOT INVALID KEY     
                          MOVE FIELD-TO-UPDATE TO FILE2-UPDATED
                          WRITE FILE2
          END-READ
       END-IF
END-PERFORM.                   


Refer manuals and try coding this logic. Post if you face problems.

Arun.

Re: Compare 2 Files

PostPosted: Thu Mar 27, 2008 7:29 pm
by arunprasad.k
My logic will work only for KSDS. Use "ACCESS IS RANDOM" in FILE-CONTROL.

If your file is ESDS then we have to go for sequential search logic.

Arun.