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

How to use JOINKEYS


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

New User


Joined: 13 May 2008
Posts: 4
Location: India

PostPosted: Mon Sep 29, 2008 12:17 am
Reply with quote

Hi,

I have two input files, File1 & File2.I want to join the matcing records to the Output file.(Input files with RECL=50 and Output file with RECL=80)
I want to compare File1 {Key1(11,6) + Key(1,7)}
with File2 {Key(1,13)} .If this matches i will join File1 and File2
Code:
JOIN UNPAIRED,F1                                     
  REFORMAT FIELDS=(F1:1,19,F2:19,20)


File1:
Code:
----+----1----+----2----+----3--
1234567 ABCDEF 1111111111
2222222 BBBBBB 4444444444


File2:
Code:
----+----1----+----2----+----3--
ABCDEF1234567 WWWWWWWWW
BBBBBB2222222 YYYYYYYYYY


Out:
Code:
----+----1----+----2----+----3----+----
1234567 ABCDEF 11111111111 WWWWWWWWW
2222222 BBBBBB 4444444444  YYYYYYYYYY
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Mon Sep 29, 2008 9:12 am
Reply with quote

Vinod,
Quote:
I want to compare File1 {Key1(11,6) + Key(1,7)}
with File2 {Key(1,13)} .If this matches i will join File1 and File2

The key positions you mentioned above and that given in the "Code" does n't seem to match. Also you dont need a JOIN UNPAIRED,F1 unless you want to write unmatched records also from file1

If you need only the matching records in your output you can use a Syncsort job like this.
Code:
//STEP00   EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTOUT  DD SYSOUT=*                                                 
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//SORTJNF1 DD *                                                         
1234567 ABCDEF 1111111111                                               
2222222 BBBBBB 4444444444                                               
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//SORTJNF2 DD *                                                         
ABCDEF1234567 WWWWWWWWW                                                 
BBBBBB2222222 YYYYYYYYY                                                 
//SYSIN DD *                                                           
 JOINKEYS FILE=F1,FIELDS=(9,6,A,1,7,A)                                 
 JOINKEYS FILE=F2,FIELDS=(1,6,A,7,7,A)                                 
 SORT FIELDS=COPY                                                       
 REFORMAT FIELDS=(F1:1,25,F2:14,9)         

SORTOUT
Code:
1234567 ABCDEF 1111111111 WWWWWWWW
2222222 BBBBBB 4444444444 YYYYYYYY
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Sep 29, 2008 9:19 am
Reply with quote

Hi,

Off hand code,
Code:
//SYSIN    DD    *                     
  JOINKEYS FILES=F1,FIELDS=(9,6,A,1,7,A)
  JOINKEYS FILES=F2,FIELDS=(1,6,A,7,7,A)
  REFORMAT FIELDS=(F1:1,25,F2:14,9)   
  SORT FIELDS=COPY                     
/*                                     
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Sep 29, 2008 9:23 am
Reply with quote

Agreed with Arun
Quote:
I want to compare File1 {Key1(11,6) + Key(1,7)}
with File2 {Key(1,13)} .If this matches i will join File1 and File2
It shoud be, per given example
File1 {Key1(9,6) + Key(1,7)

PS. Well, I'm a regular victim of this, didn't see your response Arun, kept open the thread for a longer time.. icon_redface.gif
Back to top
View user's profile Send private message
Vinod Y

New User


Joined: 13 May 2008
Posts: 4
Location: India

PostPosted: Tue Sep 30, 2008 2:08 am
Reply with quote

Thanks Arun and Anuj....i got the desired result. icon_cool.gif
Sorry for the typo error icon_biggrin.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Sep 30, 2008 8:08 am
Reply with quote

You are welcome, not to worry about the typos.. icon_smile.gif

-Ad
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 Joinkeys - 5 output files DFSORT/ICETOOL 7
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts Sort with JOINKEYS using two VB files DFSORT/ICETOOL 1
No new posts JOINKEYS, how to keep all occurrences? DFSORT/ICETOOL 2
Search our Forums:

Back to Top