Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 9
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: 86
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: 9
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: 9
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: 1806
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: 7315

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: 1806
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 How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Comparing 2 Files using Current time arunsoods SYNCSORT 9 Fri Sep 22, 2017 6:00 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts Join records from 2 files with No Dup... Poha Eater DFSORT/ICETOOL 22 Sun Aug 27, 2017 10:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us