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
 

 

DFSORT to match two files and write

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
John F Dutcher

New User


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

PostPosted: Thu May 12, 2016 5:17 pm    Post subject: DFSORT to match two files and write
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: 65
Location: India

PostPosted: Thu May 12, 2016 6:02 pm    Post subject:
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: 4
Location: Harrisburg, PA

PostPosted: Thu May 12, 2016 6:40 pm    Post subject: Reply to: DFSORT to match two files and write
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: 4
Location: Harrisburg, PA

PostPosted: Thu May 12, 2016 7:05 pm    Post subject: Reply to: DFSORT to match two files and write
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Thu May 12, 2016 10:11 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu May 12, 2016 11:38 pm    Post subject: Reply to: DFSORT to match two files and write
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Fri May 13, 2016 5:19 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
This topic is locked: you cannot edit posts or make replies. How to use 2 input files in control c... Gunapala CN DFSORT/ICETOOL 23 Thu Oct 13, 2016 3:42 pm
No new posts Error IEC161I 052(009,XXXRS00)-084 wh... amitc23 JCL & VSAM 10 Wed Oct 12, 2016 5:00 pm


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