View previous topic :: View next topic
|
Author |
Message |
krishnareddymsc
New User
Joined: 08 Jan 2007 Posts: 9 Location: Bangalore
|
|
|
|
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......... |
|
Back to top |
|
|
raviprasath_kp Warnings : 1 New User
Joined: 20 Feb 2005 Posts: 65 Location: chennai
|
|
|
|
u mean u want to write a program |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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... |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
Why writing a program if you have ready-made, proven utilities?
O. |
|
Back to top |
|
|
krishnareddymsc
New User
Joined: 08 Jan 2007 Posts: 9 Location: Bangalore
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
Have a look over here |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
IEBCOMPR, SUPERC, COMPAREX, FILEAID etc...
O. |
|
Back to top |
|
|
santosh_dorge
New User
Joined: 03 Dec 2006 Posts: 8 Location: Mumbai
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bitneuker
CICS Moderator
Joined: 07 Nov 2005 Posts: 1104 Location: The Netherlands at Hole 19
|
|
|
|
Here is the pseudo-code for these kind of problems I posted some time ago. |
|
Back to top |
|
|
PeD
Active User
Joined: 26 Nov 2005 Posts: 459 Location: Belgium
|
|
|
|
Quote: |
IEBCOMPR, SUPERC, COMPAREX, FILEAID etc...
|
and EComp |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
I just looked at the attachment. What a mess!! Anybody know how to get that to print right? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Jack,
Two things:
First; 36 hours and no feedback.....maybe he/she will show up in a couple of months....
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Thanx Dick. It worked great. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Most welcome |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
mmwife wrote: |
Thanx Dick. It worked great. |
Me too, Dick, just leaves me (always) wondering what the dif is????? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
thanks for the insight,
Bill |
|
Back to top |
|
|
|