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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: How to merge two files which have keys in different formats?
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: 2276
Location: @my desk

PostPosted: Wed Oct 08, 2008 1:11 pm    Post subject:
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    Post subject: Reply to: How to merge two files which have keys in differen
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: 2276
Location: @my desk

PostPosted: Wed Oct 08, 2008 5:25 pm    Post subject:
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    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 Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts PA02 - Programmtically control attent... dodithegreat IMS DB/DC 1 Thu Apr 06, 2017 8:33 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm


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