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

How to merge two files which have keys in different formats?


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

New User


Joined: 08 May 2007
Posts: 13
Location: Hyderabad

PostPosted: Wed Oct 08, 2008 12:25 pm
Reply with quote

Hi,
I have two files FILE1(key 1 to 6 bytes 9(6) field, LRECL=150) and FILE2 (key 1 to 4 bytes S9(6) Comp-3, LRECL=230).
Now I want write out all the records from FILE2 only if the key field gets a match from FILE1. Please let me know how I can achieve this.

Thanks in Advance !!!
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Wed Oct 08, 2008 1:11 pm
Reply with quote

nynali,

You can do this using any of the sort products(DFSORT or SYNCSORT) if you have any of them installed and the solution differs based on which one you have.
Can you post the sort product info?. Also do you expect duplicate keys in FILE1(or FILE2)?
Back to top
View user's profile Send private message
nynali

New User


Joined: 08 May 2007
Posts: 13
Location: Hyderabad

PostPosted: Wed Oct 08, 2008 2:27 pm
Reply with quote

Arun,
We use SYNCSORT.
FILE2 might have duplicates. FILE1 doesn't have any duplicates
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Wed Oct 08, 2008 5:25 pm
Reply with quote

Hello,

If you have Syncsort for z/OS 1.2 or later you can use Syncsort's JOIN functionality to do this. But before doing that you should make sure that the keys are in the same format. The below Syncsort job does what you asked for.
Code:
//STEP1    EXEC PGM=SORT                           
//SORTIN   DD DSN= Input file1 ------> FB, LRECL=150
//SYSOUT   DD SYSOUT=*                             
//SORTOUT  DD DSN=&&TEMP,DISP=(,PASS)               
//SYSIN    DD *                                     
  INREC BUILD=(1,6,ZD,TO=PD,LENGTH=4)               
  SORT FIELDS=COPY                                 
//*                                                 
//STEP2    EXEC PGM=SORT                           
//SORTJNF1 DD DSN=&&TEMP1,DISP=(OLD,PASS)           
//SORTJNF2 DD DSN= Input file2 ------> FB, LRECL=230
//SORTOUT  DD DSN= Output file ------> FB, LRECL=230
//SYSIN    DD *                                     
  JOINKEYS FILE=F1,FIELDS=(1,4,A)                   
  JOINKEYS FILE=F2,FIELDS=(1,4,A)                   
  REFORMAT FIELDS=(F2:1,230)                       
  SORT FIELDS=COPY                                 
//*     
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 Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
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
Search our Forums:

Back to Top