View previous topic :: View next topic
|
Author |
Message |
dilpreet
New User
Joined: 18 Mar 2008 Posts: 34 Location: INDIA
|
|
|
|
I have two KSDS files and want to copy matching records in the two files into a third file in a cobol program.
Both the files have a different number of records. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Depending on what you mean by "matching records" you could:
Read one file sequentially.
Read the other file randomly with the key from the first file.
If they "match" write to the 3rd file. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
In addition to Dick's suggession, you could sort both VSAM files in the same sequence (if they aren't already) then use simple match logic to write matched records to your 3rd file. Matching 2 files on the same key is a very fundamental process in COBOL logic. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
or,
even though this is a cobol forum,
a simple compare
and output matches to a third file
has only been done a gizzillion times by dfsort with the COPY function.
search the dfsort forum,
would not even be suprised if it is one of the dfsort tricks.
check out the sticky in the dfsort forum for references.
by the way, you could use the COPY function and not SORT,
if the ksds key is what you are matching - already sorted.
other wise, SORT the files using the CTLnnn stuff with your keys
dfsort (and syncsort) can read vsam files...
it is easy - there are tons of examples
and if you have syncsort, no problem,
the control cards are probably the same.
actually this is a waste of a cobol program,
especially since you apparently don't know enough to write a cobol pgm on your own.
and, if you go the sort route,
there are IBMers that maintain DFSORT that are always here,
as well as syncsort has representatives that provide help.
(read help as they will provide you the control cards),
whereas if you waste your time trying to write your first cobol program,
you need to debug it. |
|
Back to top |
|
|
|