Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Search from one file in another , and results in third file.
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    Post subject:
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    Post subject:
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

Senior Member


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

PostPosted: Wed Dec 12, 2007 2:58 pm    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Dec 13, 2007 1:50 am    Post subject:
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

Senior Member


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

PostPosted: Thu Dec 13, 2007 10:36 am    Post subject:
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

Site Director


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

PostPosted: Thu Dec 13, 2007 10:35 pm    Post subject: Reply to: Search from one file in another , and results in t
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

Senior Member


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

PostPosted: Fri Dec 14, 2007 11:44 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us