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

Compare two files and write to O/P from File2


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Fri Nov 10, 2006 4:02 pm
Reply with quote

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

New User


Joined: 14 Feb 2005
Posts: 88

PostPosted: Fri Nov 10, 2006 6:16 pm
Reply with quote

Bharathi,

Do you have duplicates in the 1st file ?

Alain
Back to top
View user's profile Send private message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Fri Nov 10, 2006 7:40 pm
Reply with quote

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

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Nov 10, 2006 10:37 pm
Reply with quote

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
View user's profile Send private message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Tue Nov 14, 2006 10:15 am
Reply with quote

Thanks Frank.
Back to top
View user's profile Send private message
bbharathiraj
Warnings : 1

New User


Joined: 26 Oct 2006
Posts: 50
Location: Chennai

PostPosted: Wed Nov 15, 2006 3:13 pm
Reply with quote

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

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Nov 15, 2006 11:03 pm
Reply with quote

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
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
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 Merge two VSAM KSDS files into third ... JCL & VSAM 6
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
Search our Forums:

Back to Top