Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

VSAM file compare in COBOL program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: VSAM file compare in COBOL program
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

Site Director


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

PostPosted: Tue Feb 06, 2007 4:06 am    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Tue Feb 06, 2007 4:07 am    Post subject:
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    Post subject: Re: VSAM file compare in COBOL program
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    Post subject: Re: VSAM file compare in COBOL program
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fail to change physical VSAM filename... jacobdng CICS 0 Fri Jan 20, 2017 12:36 pm
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us