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

DFSORT to match two files and write


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
John F Dutcher

New User


Joined: 02 Apr 2008
Posts: 11
Location: Harrisburg, PA

PostPosted: Thu May 12, 2016 5:17 pm
Reply with quote

I had been believing that the sort below, used to match two files and write out just matches would never have more records on the output file than exist n file F1, that is, if all F1 records found a match in F2 they would all appear in the output. Not so, as the output has many more records than the input F1. Yes, there are dups in F1 and I believe F2.... but I presumed that only the matches to F1 found in F2 would write out. CAN THIS be adjusted......so that only as many records as came in on F1 are written out ??

Code:
//SYSIN    DD *                             
  JOINKEYS FILE=F1,FIELDS=(1,9,CH,A)       
  JOINKEYS FILE=F2,FIELDS=(1,9,CH,A)       
  REFORMAT FIELDS=(F1:1,243,F2:10,3)       
  SORT FIELDS=COPY                         
/*

code' d
Back to top
View user's profile Send private message
Abid Hasan

New User


Joined: 25 Mar 2013
Posts: 88
Location: India

PostPosted: Thu May 12, 2016 6:02 pm
Reply with quote

Hello,

Now this is where things get tad bit tricky.

JOINKEYS works by building cartesian joins; and there is an example which explains the situation you're facing in the DFSORT manual.
Look at: Example 2 - Paired F1/F2 records with duplicates (cartesian) - in the DFSORT Application Programming Guide (SC26-7523-06); Chapter 4, Using a JOINKEYS Application for Joining Two Files.

That definitely should clear the air.
Back to top
View user's profile Send private message
John F Dutcher

New User


Joined: 02 Apr 2008
Posts: 11
Location: Harrisburg, PA

PostPosted: Thu May 12, 2016 6:40 pm
Reply with quote

The same manual seems to show with its Example # 3 the scenario I desire, one which keeps only the F1 records which successfully 'paired' on the key fields with a record in F2. However it sems to be coded exactly as my own example (minus the 'parsing' exercise)....and it's clear mine does not work as expected..... or as suggested in Example # 3 ?
Back to top
View user's profile Send private message
John F Dutcher

New User


Joined: 02 Apr 2008
Posts: 11
Location: Harrisburg, PA

PostPosted: Thu May 12, 2016 7:05 pm
Reply with quote

OK...... on this issue,,,,,, I find if I eliminate the dups on File F2 I get the results I expected. I will simply be guided by this experience in the future and not think that the SORT will limit output file records to what is on input file unless the 'matching' file is first purged of any dups on the key fields involved.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3049
Location: NYC,USA

PostPosted: Thu May 12, 2016 10:11 pm
Reply with quote

Quote:
CAN THIS be adjusted

You can use SUM FIELDS=NONE and the keys in your SORT FIELDS otherwise Abid has explained how that works.
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 May 12, 2016 11:38 pm
Reply with quote

Every each record on F1 that matches a record on F2 will cause a joined record to be created, and vice versa.

If you actually have the need to SORT the F1 and F2 you can remove duplicates with SUM FIELDS=NONE. If you don't need to SORT the data, you can always use WHEN=GROUP or SEQNUM to identify the "first" of a group of records. Various ways with INCDLUE/OMIT COND in the main task, or with OUTFIL INCLUDE=/OMIT=.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3049
Location: NYC,USA

PostPosted: Fri May 13, 2016 5:19 pm
Reply with quote

This is precisely what Bill said.
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top