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

Syncsort Joinkeys - Join Unpaired


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mikel Terracina

New User


Joined: 02 Apr 2012
Posts: 11
Location: USA

PostPosted: Wed Oct 24, 2012 9:53 pm
Reply with quote

Hello, any ideas on how to get the desired output (results on one line rather than two)?

InFile_1
Code:
11111 1000
22222 1001
22222 1002


InFile_2
Code:
11111 1000
22222 1001
33333 1002


Current Output
Code:
     22222    1002
33333     1002   


Desired Output
Code:
333332222210021002


JCL
Code:
//SYSIN DD *                                   
 JOINKEYS FILE=F1,FIELDS=(1,5,A,7,4,A)         
 JOINKEYS FILE=F2,FIELDS=(1,5,A,7,4,A)         
 JOIN UNPAIRED,ONLY                           
 REFORMAT FIELDS=(F2:1,5,F1:1,5,F2:7,4,F1:7,4)
 SORT FIELDS=COPY                             
/*


Thanks in advance for any help.

Mike

File samples Code'd
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Oct 24, 2012 10:01 pm
Reply with quote

Hello,

It will help someone help you if you post a more complete set of some input data and the expected output.

Explain the rules for getting from the input to the output.

Why are values from 2 unrelated keys combined on the same output line?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Oct 24, 2012 10:05 pm
Reply with quote

On what basis should they be on the same output record?

If, for this purpose, the 7,4 is a higher-order key, you have to make it so, but then it must be "unique" across your records.

If that does not do what you want, you are going to have to use GROUP in some way.

You have to explain them appearing on the same record and how you two key fields relate to each other, the existence of duplicates for either, and anything else you feel might be useful.
Back to top
View user's profile Send private message
Mikel Terracina

New User


Joined: 02 Apr 2012
Posts: 11
Location: USA

PostPosted: Wed Oct 24, 2012 11:51 pm
Reply with quote

My apologies. I now realize the description was pretty vague.

In a nutshell, here's my situation. I have two generational dataset's - a current generation (0) and a previous generation (-1). There are 2 keys within the files:

File layout
Code:
key-1 key-2
11111 1000
22222 1001


Sometimes between the previous generation and current generation key-2 may become associated with a different key-1:
Code:
previous generation (-1) file-1
11111 1000
22222 1001
22222 1002
44444 1004
44444 1005
77777 1007
77777 1008


current generation (0) - file-2
11111 1000
22222 1001
33333 1002  (key-2 associated with new key-1)
44444 1004
55555 1005  (key-2 associated with new key-1)
77777 1007
88888 1008  (key-2 associated with new key-1)


I would like to capture records where key-2 has been associated to a different key-1, but ideally have the output written on one line as such:
(current key-1) (previous key-1) (current key-2) (optional - prev key-2)
Code:
33333 22222 1002
55555 44444 1005
88888 77777 1008


However, my current output looks like this:
Code:
     22222    1002
33333     1002     
     44444    1005
55555     1005     
     77777    1008
88888     1008   


Thanks,
Mike
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Oct 25, 2012 12:25 am
Reply with quote

So join on your 2nd key only.

Get the matches (you'll have to decided if you can get mismatches, and what you'd want to do with them if you can). OMIT the reformat records where the first key is equal and what you should be left with is perhaps what you want?
Back to top
View user's profile Send private message
Mikel Terracina

New User


Joined: 02 Apr 2012
Posts: 11
Location: USA

PostPosted: Thu Oct 25, 2012 2:14 am
Reply with quote

Thanks Bill! That did the trick. Here's my JCL:

Code:
//SYSIN DD *                           
  JOINKEYS FILE=F1,FIELDS=(7,4,A)       
  JOINKEYS FILE=F2,FIELDS=(7,4,A)       
  REFORMAT FIELDS=(F2:1,5,F1:1,5,F2:7,4)
  SORT FIELDS=COPY                     
  OMIT COND=(1,5,CH,EQ,5,5,CH)         
/*
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Oct 25, 2012 2:17 am
Reply with quote

No problem. Thanks for letting us know, and posting your solution. It may help someone else in the future.
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
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 Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top