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

Program needed to compare the records of flat file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
stly
Warnings : 1

New User


Joined: 25 Jul 2005
Posts: 93

PostPosted: Wed Mar 01, 2006 1:27 pm
Reply with quote

hi frds i need a program from u.i hav a flat file n a master file.i need to compare the records of flat file with that of master file.if it does not exist i hav to write it in the mater file.can any one suggest optimum code.
i tried comparing the record of flat file with all the records of master file and so on.but it luks lenghty.can any one provide the code.
Back to top
View user's profile Send private message
DavidatK

Active Member


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

PostPosted: Wed Mar 01, 2006 7:49 pm
Reply with quote

stly

Step 1. If not already, sort master file and flat file by record key

Step 2. Pseudo code

Code:

    perform read-old-master-file
    perform read-flat-file

    perform
      until old-master-file-eof
      and   flat-file-eof
        if master-file-key = flat-file-key
        then
            perform write-from-old-master-file
            perform read-old-master-file
            perform read-flat-file
        else
            if master-file-key > flat-file-key
            then
                perform write-from-flat-file
                perform read-flat-file
            else
                perform write-from-old-master-file
                perform read-old-master-file
            end-if
        end-if
     end-perform.

Read-old-master-file.
    Read old-master-file
        At end
            Move ?y? to old-master-file-eof
            Move high-key-value to master-file-key.
Read-flat-file.
    Read flat-file
        At end
            Move ?y? to flat-file-eof
            Move high-key-value to flat-file-key.
Write-from-old-master-file.
    Write new-master-file from old-master-file.
Write-from-flat-file.
    Write new-master-file from flat-file.




Dave
Back to top
View user's profile Send private message
stly
Warnings : 1

New User


Joined: 25 Jul 2005
Posts: 93

PostPosted: Tue Mar 07, 2006 1:44 pm
Reply with quote

thank u very much
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 290
Location: Basel, Switzerland

PostPosted: Fri Mar 10, 2006 5:57 pm
Reply with quote

hy stly,

why write a program?
use utilities instead...

i.e. dfsort

merge both files, sort them and omit all duplicates...

martin9
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