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

JOINKEYS Paired and Unpaired Sort


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

New User


Joined: 21 May 2009
Posts: 5
Location: Philadelphia

PostPosted: Fri Sep 29, 2017 1:48 am
Reply with quote

Hello,

I'm doing a sort just like the one described in the IBM DFSORT JOINKEYS example #5:

LINK

I have two input files (both have the same file format). The sort creates three output files; with paired file1/file2 records, unpaired file1 records and unpaired file2 records.

The sort runs and populates all 3 output files. However, the numbers don't add up. I would expect (Input1 + Input2 = Output1 + Output2 + Output3). I would think each input record would only go to one output file. However, the total of the 3 output files is slightly higher than the total of the 2 input files. Am I missing something with my understanding of how this works? Why would this be happening? My JCL and results from sorting are below. Thanks in advance for the help.


//JKE5 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=TCK401.INPUT1,DISP=SHR
//SORTJNF2 DD DSN=TCK401.INPUT2,DISP=SHR
//YESONLY DD DSN=TCK401.MAS.YESONLY,
// UNIT=(SYSDA,4),SPACE=(CYL,(100,60),RLSE),
// DISP=(NEW,CATLG,CATLG),
// DCB=(RECFM=FB,LRECL=4235,BLKSIZE=0)
//TODONLY DD DSN=TCK401.MAS.TODONLY,
// UNIT=(SYSDA,4),SPACE=(CYL,(100,60),RLSE),
// DISP=(NEW,CATLG,CATLG),
// DCB=(RECFM=FB,LRECL=4235,BLKSIZE=0)
//BOTH DD DSN=TCK401.MAS.BOTH,
// UNIT=(SYSDA,4),SPACE=(CYL,(100,60),RLSE),
// DISP=(NEW,CATLG,CATLG),
// DCB=(RECFM=FB,LRECL=4235,BLKSIZE=0)
//SYSIN DD *
* CONTROL STATEMENTS FOR JOINKEYS APPLICATION
JOINKEYS FILE=F1,FIELDS=(1,80,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(1,80,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1,4235,F2:1,4235,?)
* CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)
OPTION COPY
OUTFIL FNAMES=YESONLY,INCLUDE=(8471,1,CH,EQ,C'1'),
BUILD=(1,4235)
OUTFIL FNAMES=TODONLY,INCLUDE=(8471,1,CH,EQ,C'2'),
BUILD=(4236,4235)
OUTFIL FNAMES=BOTH,INCLUDE=(8471,1,CH,EQ,C'B'),
BUILD=(1,4235,/,4236,4235)
/*

File Quantity Analysis:

TCK401.INPUT1 - 33965
TCK401.INPUT2 - 34508
Total: 68473

TCK401.MAS.BOTH - 67842
TCK401.MAS.YESONLY - 62
TCK401.MAS.TODONLY - 605
Total: 68509

Difference of 36??
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Fri Sep 29, 2017 2:09 am
Reply with quote

Most probably, your counts of records are wrong somewhere.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Fri Sep 29, 2017 2:17 am
Reply with quote

could it be that You have some duplicate records ?
Back to top
View user's profile Send private message
MFwhiz

New User


Joined: 21 May 2009
Posts: 5
Location: Philadelphia

PostPosted: Fri Sep 29, 2017 6:27 pm
Reply with quote

Thanks enrico-sorichetti - you were right. When I presort each input file with SUM=NONE it drops a few records. Then everything balances. I believed the key was unique but it is not. I'll have to take steps to ensure a unique key since the duplicates are valid...
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Fri Sep 29, 2017 7:05 pm
Reply with quote

FYI:
Without this coding like below, 90% of visitors will ignore all your questions
Code:
//JKE5     EXEC PGM=SORT
//SYSOUT   DD  SYSOUT=*
//SORTJNF1 DD  DSN=TCK401.INPUT1,DISP=SHR
//SORTJNF2 DD  DSN=TCK401.INPUT2,DISP=SHR
//YESONLY  DD  DSN=TCK401.MAS.YESONLY,
//             UNIT=(SYSDA,4),SPACE=(CYL,(100,60),RLSE),
//             DISP=(NEW,CATLG,CATLG),
//             DCB=(RECFM=FB,LRECL=4235,BLKSIZE=0)
//TODONLY  DD  DSN=TCK401.MAS.TODONLY,
//             UNIT=(SYSDA,4),SPACE=(CYL,(100,60),RLSE),
//             DISP=(NEW,CATLG,CATLG),
//             DCB=(RECFM=FB,LRECL=4235,BLKSIZE=0)
//BOTH     DD  DSN=TCK401.MAS.BOTH,
//             UNIT=(SYSDA,4),SPACE=(CYL,(100,60),RLSE),
//             DISP=(NEW,CATLG,CATLG),
//             DCB=(RECFM=FB,LRECL=4235,BLKSIZE=0)
//SYSIN   DD  *
 * CONTROL STATEMENTS FOR JOINKEYS APPLICATION
 JOINKEYS FILE=F1,
          FIELDS=(1,80,A),
          SORTED,NOSEQCK
 JOINKEYS FILE=F2,
          FIELDS=(1,80,A),
          SORTED,NOSEQCK
 JOIN UNPAIRED,F1,F2
 REFORMAT FIELDS=(F1:1,4235,
                  F2:1,4235,
                  ?)
 * CONTROL STATEMENTS FOR MAIN TASK (JOINED RECORDS)
 OPTION COPY
 OUTFIL FNAMES=YESONLY,
        INCLUDE=(8471,1,CH,EQ,C'1'),
        BUILD=(1,4235)
 OUTFIL FNAMES=TODONLY,
        INCLUDE=(8471,1,CH,EQ,C'2'),
        BUILD=(4236,4235)
 OUTFIL FNAMES=BOTH,
        INCLUDE=(8471,1,CH,EQ,C'B'),
        BUILD=(1,4235,
             /,4236,4235)
/*
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 JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts Joinkeys - 5 output files DFSORT/ICETOOL 7
Search our Forums:

Back to Top