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
 

 

How to compare 2 flat files and write similar to new file
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
krishnareddymsc

New User


Joined: 08 Jan 2007
Posts: 9
Location: Bangalore

PostPosted: Thu Jan 11, 2007 12:10 pm    Post subject: How to compare 2 flat files and write similar to new file
Reply with quote

can any one give me the logic of comparing 2 flat files in cobol, and write the similar records in a new file....jst explain in short...as possible...
nd thanks for the same......... icon_rolleyes.gif
Back to top
View user's profile Send private message

raviprasath_kp
Warnings : 1

New User


Joined: 20 Feb 2005
Posts: 65
Location: chennai

PostPosted: Thu Jan 11, 2007 12:56 pm    Post subject:
Reply with quote

u mean u want to write a program
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Thu Jan 11, 2007 1:03 pm    Post subject: Re: how ca we compare 2 flat files in cobol
Reply with quote

Quote:
jst explain in short...as possible...

Okie, I would try...

Put the files in sorted order on a key... and then follow Binary Search...
1> Read First File.
2> Load this file to an array/table.
3> Read second file until EoF.
4> compare key of second file with N/2 th rec of array.
5> if same "OUTPUT" else ( if less same search on 1 to N/2 part of array else N/2 to N part of array ).

Make a Search in the forum, you'll get more answers...

raviprasath_kp wrote:
u mean u want to write a program

What else "COBOL" denotes here on the title & description of the question... icon_rolleyes.gif
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Jan 11, 2007 2:03 pm    Post subject:
Reply with quote

Why writing a program if you have ready-made, proven utilities?

O.
Back to top
View user's profile Send private message
krishnareddymsc

New User


Joined: 08 Jan 2007
Posts: 9
Location: Bangalore

PostPosted: Thu Jan 11, 2007 3:39 pm    Post subject:
Reply with quote

may i know the utilities pls...and also could you pls explain how can be done this same , with 2 VSAM Ksds in JCL?
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Jan 11, 2007 3:52 pm    Post subject:
Reply with quote

Have a look over here
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Thu Jan 11, 2007 4:46 pm    Post subject:
Reply with quote

IEBCOMPR, SUPERC, COMPAREX, FILEAID etc...

O.
Back to top
View user's profile Send private message
santosh_dorge

New User


Joined: 03 Dec 2006
Posts: 8
Location: Mumbai

PostPosted: Thu Jan 11, 2007 5:48 pm    Post subject:
Reply with quote

Hi try this

1)Sort file and file2
2)Read file1
3)Read file2 until key2 >= key1
4) check if key1=key2 perform required action
5)repeat step2 to 4 until end of both files


Thanks,
Santosh
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: Thu Jan 11, 2007 9:21 pm    Post subject:
Reply with quote

Hello,

This
Quote:
2)Read file1
3)Read file2 until key2 >= key1
4) check if key1=key2 perform required action
5)repeat step2 to 4 until end of both files


will NOT work for several different situations. You will need to write code that will handle ALL cases - keep in mind that when you compare 2 files there may be duplicates in either or both files as well as "keys" that are in one file and not in the other.
Back to top
View user's profile Send private message
Bitneuker

CICS Moderator


Joined: 07 Nov 2005
Posts: 1105
Location: The Netherlands at Hole 19

PostPosted: Thu Jan 11, 2007 9:51 pm    Post subject:
Reply with quote

Here is the pseudo-code for these kind of problems I posted some time ago.
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Fri Jan 12, 2007 1:27 am    Post subject:
Reply with quote

Quote:
IEBCOMPR, SUPERC, COMPAREX, FILEAID etc...

and EComp
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Jan 13, 2007 5:19 am    Post subject: Re: How to compare 2 flat files and write similar to new fil
Reply with quote

Hi Kishor,

You say you want logic but you post in the JCL Forum, not the Computer Languages Forum, so I'm confused at what kind of solution you're looking for.

Anyway, take a look at the attachment. You should find what you need in there if you're looking for code. It may be a bit of overkill but pick out what you need and use it.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Jan 13, 2007 5:25 am    Post subject:
Reply with quote

I just looked at the attachment. What a mess!! Anybody know how to get that to print right?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Sat Jan 13, 2007 5:36 am    Post subject:
Reply with quote

Jack,

Two things:
First; 36 hours and no feedback.....maybe he/she will show up in a couple of months.... icon_cry.gif
Second; what in the heck would I need to do to that download to use it? My download produced one veeerry long single line of COBOL code. Did the CR and/or LFs get lost?

Bill
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jan 14, 2007 5:34 am    Post subject:
Reply with quote

Bill,

I don't know. I think we asked the same ques in different ways.

I downloaded a text file created in MS Word from my a: drive.
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: Sun Jan 14, 2007 8:28 am    Post subject:
Reply with quote

Hello,

If you right-click on the download link for the text file and save the file to a local drive, it opens correctly in notepad - at least on this pc.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jan 14, 2007 12:15 pm    Post subject:
Reply with quote

Thanx Dick. It worked great.
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: Mon Jan 15, 2007 1:36 am    Post subject:
Reply with quote

Most welcome icon_biggrin.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Mon Jan 15, 2007 2:17 am    Post subject:
Reply with quote

mmwife wrote:
Thanx Dick. It worked great.
Me too, Dick, just leaves me (always) wondering what the dif is?????
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: Mon Jan 15, 2007 4:23 am    Post subject:
Reply with quote

Hi Bill,

One "diff" is that the downloaded .txt file is opened by "your" local notepad. When the link is clicked, it is opened in a browser window.

Another consideration may be how the file was saved in Word. There are several ways ("save as type" - a pulldown near/at the bottom of the save window) to "save" in word and each has different control codes embedded.
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 -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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