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
 

 

Compare two files and write to O/P from File2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Compare two files and write to O/P from File2
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    Post subject:
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    Post subject: Re: Compare two files and write to O/P from File2
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 Moderator


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

PostPosted: Fri Nov 10, 2006 10:37 pm    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Nov 15, 2006 11:03 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Storing huge volume of data, compare ... Pradeep K M All Other Mainframe Topics 3 Mon Jan 16, 2017 5:08 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Error IEC161I 052(009,XXXRS00)-084 wh... amitc23 JCL & VSAM 10 Wed Oct 12, 2016 5:00 pm


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