View previous topic :: View next topic
Author
Message
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi,
My sort job uses JOINKEYS:
Code:
//STEP0002 EXEC PGM=SORT
//SORTJNF1 DD *
1
//SORTJNF2 DD *
1
1
3
1
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,1,A)
JOINKEYS FILE=F2,FIELDS=(1,1,A)
REFORMAT FIELDS=(F1:1,1)
SORT FIELDS=COPY
END
/*
Output:
Expected Output:
I am getting three records into output file because the SORTJNF2 has three matches against SORTJNF1. But, I want to get only one record into output file. How to alter my job to achieve it
Please help.
Thanks.
Back to top
Anuj Dhawan Superior Member Joined: 22 Apr 2006Posts: 6250 Location: Mumbai, India
not-tested:
Code:
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,1,A)
JOINKEYS FILE=F2,FIELDS=(1,1,A)
REFORMAT FIELDS=(F1:1,1)
INREC OVERLAY=(80:SEQNUM,2,ZD,RESTART=(1,1))
SORT FIELDS=COPY
OUTFIL INCLUDE=(80,2,ZD,EQ,1),BUILD=(1,1)
/*
Back to top
Anuj Dhawan Superior Member Joined: 22 Apr 2006Posts: 6250 Location: Mumbai, India
And what release of SyncSort you are at, if you've DUPKEYS feacture availbale, try this:
Code:
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,1,A)
JOINKEYS FILE=F2,FIELDS=(1,1,A)
REFORMAT FIELDS=(F1:1,1)
SORT FIELDS=(1,1,CH,A)
DUPKEYS FIELDS=NONE
/*
Back to top
Hariharan Ramachandran New User Joined: 30 Nov 2010Posts: 28 Location: Chennai, Tamilnadu,INDIA
Please find the exact solution for your query. It has been TESTED.
Code:
//SORTJNF1 DD *
1
//SORTJNF2 DD *
1
1
3
1
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(01,01,A)
JOINKEYS FILE=F2,FIELDS=(01,01,A)
REFORMAT FIELDS=(F1:01,02,
F2:01,02)
INREC FIELDS=(01,01,SEQNUM,01,ZD,RESTART=(01,01),START=0)
INCLUDE COND=(01,01,CH,EQ,03,01,CH,AND,
02,01,CH,EQ,04,01,CH)
OUTREC FIELDS=(1:1,1)
SORT FIELDS=(01,01,CH,A)
SUM FIELDS=NONE
/*
Regards,
Hari
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Ramsri,
Code:
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,1,A)
JOINKEYS FILE=F2,FIELDS=(1,1,A)
REFORMAT FIELDS=(F1:1,1)
SORT FIELDS=(1,1,CH,A)
SUM FIELDS=NONE
/*
This should do what you're trying to achieve.
Hariharan Ramachandran wrote:
Please find the exact solution for your query
Hariharan Ramachandran,
Your solution has too many control statements which are not really required to achieve what the OP is trying to do.
Back to top
Hariharan Ramachandran New User Joined: 30 Nov 2010Posts: 28 Location: Chennai, Tamilnadu,INDIA
You are right...
Regards,
Hari
Back to top
Anuj Dhawan Superior Member Joined: 22 Apr 2006Posts: 6250 Location: Mumbai, India
Quote:
too many control statements
and so the passes of the data!
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi Arun,
Thank you very much.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi Anuj,
DUPKEYS FIELDS=NONE works for me. It does similar to SUM FIELDS=NONE.
Thanks.
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
Ramsri,
You're welcome.
DUPKEYS FIELDS is an advanced version of SUM FIELDS where you can perform AVG,MIN,MAX and SUM of equally keyed control fields. For FIELDS=NONE or SUM operation, you may use either of these.
Back to top
Please enable JavaScript!