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

Search from one file in another , and results in third file.


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

New User


Joined: 07 Dec 2007
Posts: 26
Location: Bangalore

PostPosted: Wed Dec 12, 2007 2:10 pm
Reply with quote

Hi ,

I have this question on files in mainframe . I did a search in the forum before posting this , but I couldn't find this exact question . In case you have the link , if you post that would be fine.

I have to search for a record from first file in the second file and if matching I need to put that record in the third file.

I have millions of records . So reading each record from each file will not be efficient .
Can you suggest me an alternative method.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Dec 12, 2007 2:18 pm
Reply with quote

suggest that you look at the DFSORT/Utiities forum. Though writing a pgm to do this is easy, you still need a sort to sync the file before a compare.
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Wed Dec 12, 2007 2:48 pm
Reply with quote

So reading each record from each file will not be efficient .

I'm really waiting for someone posting an alternate way.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Dec 12, 2007 2:58 pm
Reply with quote

Hi,

There is a "sticky" in COBOL froum by Dick Scherrer, it can be used as a "pseudo code" for your query. If you need a JCL then try this..
Code:
//STEP001 EXEC PGM=ICETOOL                                     
//TOOLMSG DD SYSOUT=*                                           
//DFSMSG  DD SYSOUT=*                                           
//IN1     DD DSN=HLQ.FIRST.FILE,DISP=SHR                   
//IN2     DD DSN=HLQ.SECOND.FILE,DISP=SHR                   
//T1      DD DSN=&&T1,UNIT=SYSDA,SPACE=(TRK,(5,5)),             
//           DISP=(MOD,PASS)                                   
//OUT12   DD DSN=HLQ.MATCHED.OUTPUT,DISP=(NEW,CATLG,DELETE)
//TOOLIN  DD *                                                 
  COPY FROM(IN1) TO(T1) USING(CTL1)                             
  COPY FROM(IN2) TO(T1) USING(CTL2)                             
  SPLICE FROM(T1) TO(OUT12) ON(1,3,CH) WITH(81,1) -             
  USING(CTL3) KEEPNODUPS                                       
/*                                                             
//CTL1CNTL DD *                                                 
  INREC OVERLAY=(80:C'11')                                     
/*                                                             
//CTL2CNTL DD *                                                 
  INREC OVERLAY=(80:C'22')                                     
/*                                                             
//CTL3CNTL DD *                                                 
  OUTFIL FNAMES=OUT12,INCLUDE=(80,2,CH,EQ,C'12'),BUILD=(1,80)   
/*                                   


IN1
Code:
111 $$$$$
222 AAAAA
444 FFFFF
555 GGGGG
888 CCCCC

IN2
Code:
111 BBBBB
333 DDDDD
444 FFFFF
555 HHHHH

OUT12
Code:
111 $$$$$
444 FFFFF
555 GGGGG


You need to manipulate the JCL according to the key position.
Back to top
View user's profile Send private message
tangentray

New User


Joined: 30 Dec 2006
Posts: 20
Location: Kolkata, India

PostPosted: Wed Dec 12, 2007 8:03 pm
Reply with quote

icetool should certainly be better than writing a cobol program.
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Wed Dec 12, 2007 11:56 pm
Reply with quote

If you have syncsort this should do it. In my example I have assumed the files to be file of FB,80.

Code:
000007 //STEP0010 EXEC PGM=SYNCSORT,REGION=6M               
000009 //SORTJNF1 DD DSN=In file1
000012 //SORTJNF2 DD DSN=In file2
000012 //SORTOUT DD  DSN=Out file
000032 //SYSIN    DD *                                       
000033  JOINKEYS FILES=F1,FIELDS=(1,80,A)                       
000035  JOINKEYS FILES=F2,FIELDS=(1,80,A)                   
000037  REFORMAT FIELDS=(F1:1,80)               
000038  SORT     FIELDS=COPY
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 Dec 13, 2007 1:50 am
Reply with quote

Hello,

Quote:
icetool should certainly be better than writing a cobol program.
This could be true if the program has no other logic whatsoever. Usually a process has more to it than simply matching the files - some sort of business (rather than simply technical) requirement exists.

Most often these days, a multi-step, resource wasting solution is created because many programmers do not know how and do not want to learn how to implement the code properly.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Dec 13, 2007 10:36 am
Reply with quote

dick scherrer wrote:
... because many programmers do not know how and do not want to learn how to implement the code properly.


Please exclude Me from this list..mercy Dick mercy... icon_smile.gif
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 Dec 13, 2007 10:35 pm
Reply with quote

Hi Anuj,

Quote:
Please exclude Me from this list..
No, i surely do not include you in this list.

The 2-file match/merge is one of my pet peeves icon_wink.gif For many years, all of the good COBOL training included "how-to" information and at least one of the projects required to pass the course included matching 2 files on some "key".

Given that the basic "algorithm" for the code is so straight-forward, it is discouraging how much effort is expended to avoid icon_sad.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Dec 14, 2007 11:44 am
Reply with quote

Hi Dick,

Quote:
No, i surely do not include you in this list.


Thanks for Your generosity Dick.. icon_smile.gif
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 How to split large record length file... DFSORT/ICETOOL 10
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 Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top