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

How to compare 2 flat files and write similar to new file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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: 1448
Location: Chicago, IL

PostPosted: Thu Jan 11, 2007 1:03 pm
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: 2358
Location: Israel

PostPosted: Thu Jan 11, 2007 2:03 pm
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
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: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Jan 11, 2007 3:52 pm
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: 2358
Location: Israel

PostPosted: Thu Jan 11, 2007 4:46 pm
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
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

Moderator Emeritus


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

PostPosted: Thu Jan 11, 2007 9:21 pm
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: 1104
Location: The Netherlands at Hole 19

PostPosted: Thu Jan 11, 2007 9:51 pm
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: 459
Location: Belgium

PostPosted: Fri Jan 12, 2007 1:27 am
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
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
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: 3156
Location: Tucson AZ

PostPosted: Sat Jan 13, 2007 5:36 am
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
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

Moderator Emeritus


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

PostPosted: Sun Jan 14, 2007 8:28 am
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
Reply with quote

Thanx Dick. It worked great.
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: Mon Jan 15, 2007 1:36 am
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: 3156
Location: Tucson AZ

PostPosted: Mon Jan 15, 2007 2:17 am
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

Moderator Emeritus


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

PostPosted: Mon Jan 15, 2007 4:23 am
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
William Thompson

Global Moderator


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

PostPosted: Mon Jan 15, 2007 5:11 am
Reply with quote

thanks for the insight,

Bill
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top