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

copy Matching records from KSDS files


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

New User


Joined: 18 Mar 2008
Posts: 34
Location: INDIA

PostPosted: Sun Apr 19, 2009 11:20 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Sun Apr 19, 2009 11:35 pm
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Mon Apr 20, 2009 1:15 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Apr 20, 2009 3:24 am
Reply with quote

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
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 2
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top