View previous topic :: View next topic
|
Author |
Message |
Aniyaa
New User
Joined: 07 Dec 2007 Posts: 26 Location: Bangalore
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
So reading each record from each file will not be efficient .
I'm really waiting for someone posting an alternate way. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
tangentray
New User
Joined: 30 Dec 2006 Posts: 20 Location: Kolkata, India
|
|
|
|
icetool should certainly be better than writing a cobol program. |
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 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 |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi Dick,
Quote: |
No, i surely do not include you in this list. |
Thanks for Your generosity Dick.. |
|
Back to top |
|
|
|