View previous topic :: View next topic
Author
Message
bbharathiraj Warnings : 1 New User Joined: 26 Oct 2006Posts: 50 Location: Chennai
Hi Friends,
Please find my requirement below.
Content of File1: (Recfm=FB,Lrecl=53) (Key position: 1,4,BI)
1111
2222
5555
Content of File2: (Recfm=FB,Lrecl=181) (Key position: 1,4,BI)
1111
1111
1111
2222
2222
3333
4444
4444
5555
5555
Output file should have the below value.
1111
1111
1111
2222
2222
5555
5555
Note: I want to write in the output file only from the file2 (with duplicates).
Any one have a solution for this.
Thanks in Advance,
Bharathi
Back to top
Alain Benveniste New User Joined: 14 Feb 2005Posts: 88
Bharathi,
Do you have duplicates in the 1st file ?
Alain
Back to top
bbharathiraj Warnings : 1 New User Joined: 26 Oct 2006Posts: 50 Location: Chennai
Alen,
Thanks for your reply. I resolved this one by below JCL.
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=K0240AL.BHAR.TEST11,DISP=SHR
//IN2 DD DSN=K0240AL.BHAR.TEST22,DISP=SHR
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(15,15)),DISP=(MOD,PASS)
//OUT1 DD DSN=K0240TR.BQT.K0240BK2.TCBBLTD.SORT,
// DISP=(NEW,CATLG,DELETE),SPACE=(CYL,(10,10),RLSE)
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(MATCH) ON(1,4,BI) -
KEEPBASE KEEPNODUPS WITHALL WITH(1,182) USING(CTL3)
/*
//CTL1CNTL DD *
OUTREC BUILD=(1:1,181,182:C'BB')
/*
//CTL2CNTL DD *
OUTREC OVERLAY=(1:1,181,182:C'VV')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT1,INCLUDE=(182,2,CH,EQ,C'VB'),
BUILD=(1,181)
/*
And do you have any soultion if I have the duplicate in the first file.
Please let me know.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
You don't need KEEPBASE or KEEPNODUPS.
You said file1 has LRECL=53. If that were the case, you couldn't use 1,181 in CTL1CNTL. Does file1 really have an LRECL of 181?
Quote:
And do you have any soultion if I have the duplicate in the first file.
Change the first COPY to a SELECT with FIRST to remove the duplicates from the first file.
Code:
...
SELECT FROM(IN1) TO(T1) ON(1,4,BI) FIRST USING(CTL1)
...
//CTL1CNTL DD *
OUTFIL FNAMES=T1,BUILD=(1:1,181,182:C'BB')
Back to top
bbharathiraj Warnings : 1 New User Joined: 26 Oct 2006Posts: 50 Location: Chennai
Thanks Frank.
Back to top
bbharathiraj Warnings : 1 New User Joined: 26 Oct 2006Posts: 50 Location: Chennai
Hi,
Your solution is excellent. And how can we do this same process if the record key for the two files are in different position.
For example. File1 (RFmt=FB,LrecL=44) and File2 (Recfm=FB,Lrecl=298).
The matching key for first File1 is (5,4) - 4 is length
The matching key for first File2 is (1,4) - 4 is length
How can we extarct the matching records from the File2 with duplicate records.
(Please refer for the sample input and output for my first question)
I have tried with the following control card. But the job went abend since I have used duplicate INREC statement on CTL2.
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(MATCH) ON(5,4,BI) -
WITHALL WITH(1,299) USING(CTL3)
/*
//CTL1CNTL DD *
INREC OVERLAY=(299:C'BB')
/*
//CTL2CNTL DD *
INREC FIELDS=(1:5,4,5:1,4,9:9,290)
INREC OVERLAY=(299:C'VV')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=MATCH,INCLUDE=(299,2,CH,EQ,C'VB'),
BUILD=(1,298)
OUTFIL FNAMES=NOMATCH,INCLUDE=(299,2,CH,EQ,C'VV'),
BUILD=(1,298)
/*
Any one have a complete solution for this?
Thanks in Advacne,
Bharath
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Since you want the records from file2, you should move the file1 key to where the file2 key is, that is, move 5,4 from file1 to 1,4.
Code:
//TOOLIN DD *
COPY FROM(IN1) TO(T1) USING(CTL1)
COPY FROM(IN2) TO(T1) USING(CTL2)
SPLICE FROM(T1) TO(MATCH) ON(1,4,BI) -
WITHALL WITH(1,299) USING(CTL3)
/*
//CTL1CNTL DD *
INREC BUILD=(1:5,4,299:C'BB')
/*
//CTL2CNTL DD *
INREC OVERLAY=(299:C'VV')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=MATCH,INCLUDE=(299,2,CH,EQ,C'VB'),
BUILD=(1,298)
OUTFIL FNAMES=NOMATCH,INCLUDE=(299,2,CH,EQ,C'VV'),
BUILD=(1,298)
/*
Back to top
Please enable JavaScript!