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

Compare two file and matched records will store into another


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sreenivasulu. Vemula

New User


Joined: 21 Aug 2008
Posts: 6
Location: Chennai

PostPosted: Thu Aug 28, 2008 9:15 am
Reply with quote

Hi,

How can compare two files and all matched records will be stored in another output file. These two files are different length and key values is also different position in two files.

Fetch the number from first file and that number compare in second file. If any match is occur that record will be stored into output file. But we need all occurences in second file.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Aug 28, 2008 11:02 am
Reply with quote

Can you please post sample input and required output with
positions specified? it will help to answer.

At this point of time i can only answer that it can be done using ICETOOL.
icon_smile.gif icon_smile.gif icon_smile.gif
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Aug 28, 2008 11:22 am
Reply with quote

Sreeni,

Welcome to the forum.

Quote:
Fetch the number from first file and that number compare in second file. If any match is occur that record will be stored into output file. But we need all occurences in second file.


Give us few more details on the field positions, record length and all. Are you using DFSORT or SYNCSORT?

Do search the forums as this has been discussed many times.
Back to top
View user's profile Send private message
Sreenivasulu. Vemula

New User


Joined: 21 Aug 2008
Posts: 6
Location: Chennai

PostPosted: Thu Aug 28, 2008 12:43 pm
Reply with quote

Input File1:
100
200
300
500

InputFIle2
100
100
100
200
200
500
500
600

Output File:

100
100
100
200
200
500
500

Two input files are different length and values positions are also different
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Aug 28, 2008 1:08 pm
Reply with quote

Quote:
Two input files are different length and values positions are also different


Sorry, but Wednesday is psycic day, so you might want to help us help you by providing some useful information such as the locations of key fields in both files, the RECFM & LRECL of both files.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Aug 28, 2008 2:05 pm
Reply with quote

Also the SORT poduct which is installed at your shop...

Thanks,
Arun
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Aug 28, 2008 2:12 pm
Reply with quote

Sreeni,

Check this and change as per your reqts.

Code:
//STEPS200 EXEC PGM=ICETOOL                                       
//TOOLMSG  DD SYSOUT=*                                             
//DFSMSG   DD SYSOUT=*                                             
//IN1      DD *                                                   
100                                                               
200                                                               
300                                                               
500                                                               
/*                                                                 
//IN2      DD *                                                   
100                                                               
100                                                               
100                                                               
200                                                               
200                                                               
500                                                               
500                                                               
600                                                               
/*                                                                 
//T1 DD DSN=&&T1234,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),             
// UNIT=SYSDA                                                     
//TOOLIN   DD *                                                   
COPY FROM(IN1) TO(T1) USING(CTL1)                                 
  COPY FROM(IN2) TO(T1) USING(CTL2)                               
  SPLICE FROM(T1) TO(OUT) ON(1,3,CH) WITH(1,51) WITHALL USING(CTL3)
/*                                                                 
//CTL1CNTL DD *                                                   
  INREC OVERLAY=(50:C'BB')                                         
/*                                                                 
//CTL2CNTL DD *                                                   
  INREC OVERLAY=(50:C'TT')                                         
/*                                                                 
//CTL3CNTL DD *                                                   
  OUTFIL FNAMES=OUT,INCLUDE=(50,2,CH,EQ,C'TT'),BUILD=(1,49)       
/*                                                                 
//OUT      DD SYSOUT=*   


Output:

Code:
********************************* TOP OF DATA **********************************
100                                                                             
100                                                                             
100                                                                             
200                                                                             
200                                                                             
500                                                                             
500                                                                             
******************************** BOTTOM OF DATA ********************************

I have assumed a recl of 49
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Aug 28, 2008 3:37 pm
Reply with quote

Hi Aaru, see line from vemula
Quote:

Two input files are different length and values positions are also different


i think above code will work when keys are at same position in file
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Thu Aug 28, 2008 4:09 pm
Reply with quote

Sambhaji,

Quote:
Hi Aaru, see line from vemula
Quote:

Two input files are different length and values positions are also different



i think above code will work when keys are at same position in file


Read my post again. The very first line says "Check this and change as per your reqts. ".

I have asked him to change the SORT card as per his requirements. We had asked all sorts of questions to the OP which he didn't answer. So just posted assuming that the field positions are same (that is how it looked from teh sample input) .

Anyways shall wait for the OP to answer.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Aug 28, 2008 4:11 pm
Reply with quote

Sambhaji,

Quote:
Check this and change as per your reqts.


Did you happen to notice this?

We can provide only a generic solution unless the OP comes up with the actual file positions.

Thanks,
Arun
Back to top
View user's profile Send private message
Sreenivasulu. Vemula

New User


Joined: 21 Aug 2008
Posts: 6
Location: Chennai

PostPosted: Tue Sep 02, 2008 8:44 am
Reply with quote

My requirement is, I have two files, files contains data as follows

File1: File length is 50, but key value starts from 10th position, remaining places are empty(Spaces)

100
200
300
500
400
700
600

FIle2: File length 50, here also key value start at 10th position, remaining places are not empty.

123441 100 ABC
123441 100 ABC
123441 100 ABC
123442 200 AAA
123442 200 AAA
123443 500 BBB
123443 500 BBB
123444 600 CCC
123445 800 XYZ
123445 800 XYZ
123446 900 AAA
123446 900 AAA

Output is:

123441 100 ABC
123441 100 ABC
123441 100 ABC
123442 200 AAA
123442 200 AAA
123443 500 BBB
123443 500 BBB
123444 600 CCC


Please let me know how to solve this problem.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Sep 02, 2008 9:40 am
Reply with quote

Sreenivasulu,

I have assumed 3 character key starting from 10th position in both the files. If match is found, file-2 record gets copied to output.

The below SYNCSORT job would give you the expected results if your shop has SYNCSORT FOR Z/OS 1.2 or above.

Code:
//STEP1    EXEC PGM=SORT                         
//SORTJNF1 DD DSN=File-1 ------------- FB,LRECL=50
//SORTJNF2 DD DSN=File-2 ------------- FB,LRECL=50
//SORTOUT  DD DSN=Output File -------- FB,LRECL=50                         
//SYSOUT   DD SYSOUT=*   
//SYSIN    DD *                                   
  JOINKEYS FILE=F1,FIELDS=(10,3,A)               
  JOINKEYS FILE=F2,FIELDS=(10,3,A)               
  REFORMAT FIELDS=(F2:1,50)                       
  SORT FIELDS=COPY       


Thanks,
Arun
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top