IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

VSAM file compare in COBOL program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Jeya Raj

New User


Joined: 14 Jan 2007
Posts: 33
Location: USA

PostPosted: Tue Feb 06, 2007 3:35 am
Reply with quote

Hi all,
I need to write a cobol program to read two VSAM files and compare those two files at 05 level. If there is a difference at 05 level for these files write it into one flat file with field name and two file values. If not continue to read input files.

I?m reading these two files into two copybooks. How can I compare two files at 05 levels?. Please let me know.

Thanks,
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Feb 06, 2007 4:06 am
Reply with quote

Hello,

Please post your copybooks (or at least the part you want to compare) and some sample data from both files as well as what you want for output when your code executes.

It need not be much, just enought to show what you are working with and what you need for the result.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Feb 06, 2007 4:07 am
Reply with quote

The level means nothing, you are comparing the two files "by key", some field in one needs to match to a field in the other.
The first thing, are both files in the same sequence of the field (or fields) that you need to compare? Determine this, and all else becomes a simple schoolbook exercise. icon_lol.gif
Back to top
View user's profile Send private message
Jeya Raj

New User


Joined: 14 Jan 2007
Posts: 33
Location: USA

PostPosted: Tue Feb 06, 2007 5:17 am
Reply with quote

I'm reading the first file and sending the key to read the second file. Both of the files are having the same record length and structure. One file is populated from VSAM data and another is populated from DB2. I need to compare both files. Write the output file with the field name and values from two files for that field if there is a mismatch.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Feb 06, 2007 5:21 am
Reply with quote

New2cobol,

I have written, and maintain several programs that do a virtually identical process, only with DB2 rows instead of VSAM records (the logic between them is pretty much the same). When you write the sequential file, you will want to include the Key of the VSAM file so you know what records is being processed. Also you will need to decide what you are going to do if a record exists on one file and not the other. What is going to happen to the file once built? You?re going to have to decide on a format for the seq file. Probable something like this:

Code:

01  CHANGE-RECORD.
    05  RECORD-KEY          PIC X(30).  >or the max key length<
    05  RECORD-FIELD_NAME   PIC X(30).
    05  OLD-VALUE           PIC X(??).  >max len of values<
    05  NEW-VALUE           PIC X(??).  >same as OLD-VALUE<


Your seq file must be generic enough to be used with all fields. That the reason for the fields in the CHANGE-RECORD being PIC X()

You will have to interrogate each field individually.

Code:

01  NEW-FILE.
    05  RECORD-KEY           PIC X(25).
    :
    05  OUTSTANDING-BALANCE  PIC S9(11)V9(2)   COMP-3.
    :


01  WS-11-2                  PIC -9(11).9(2).
    :
    :
    IF OUTSTANDING-BALANCE
       OF OLD-FILE          NOT = OUTSTANDING-BALANCE
                                  OF NEW-FILE
    THEN
        MOVE RECORD-KEY
             OF NEW-FILE     TO RECORD-KEY
                                OF CHANGE-FILE
        MOVE ?OUTSTANDING-BALANCE?
                             TO RECORD-FIELD-NAME
                                OF CHANGE-RECORD
        MOVE OUTSTANDING-BALANCE
             OF OLD-FILE
                             TO WS-11-2
        MOVE WS-11-2         TO OLD-VALUE
                                OF CHANGE-RECORD
        MOVE OUTSTANDING-BALANCE
             OF NEW-FILE
                             TO WS-11-2
        MOVE WS-11-2         TO NEW-VALUE
                                OF CHANGE-RECORD
        WRITE CHANGE-RECORD
    END-IF.
    IF INTEREST-RATE
       OF OLD-FILE          NOT = INTEREST-RATE
                                  OF NEW-FILE
    THEN
    :
    :
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top