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 file and matched records will store into another

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Compare two file and matched records will store into another
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Aug 28, 2008 11:22 am    Post subject: Reply to: Compare two file and matched records will store in
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    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Thu Aug 28, 2008 1:08 pm    Post subject:
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: 2180
Location: @my desk

PostPosted: Thu Aug 28, 2008 2:05 pm    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Aug 28, 2008 2:12 pm    Post subject: Reply to: Compare two file and matched records will store in
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Thu Aug 28, 2008 4:09 pm    Post subject: Reply to: Compare two file and matched records will store in
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: 2180
Location: @my desk

PostPosted: Thu Aug 28, 2008 4:11 pm    Post subject:
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    Post subject: Find Matching Records - Using SORT
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: 2180
Location: @my desk

PostPosted: Tue Sep 02, 2008 9:40 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
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 Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm


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