|
View previous topic :: View next topic
|
| Author |
Message |
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
Hi
How to perform the following in DFSORT?
Can this be performed using JOINKEYS
Input File-1 (will have only one record)
1,10 and 11,10 are two dates
| Code: |
----+----1----+----2
2011-01-012011-12-31 |
Input File-2 (will have n records)
4,10 is a date field
| Code: |
----+----1---
OPQ2010-01-01
ABC2011-01-01
CDE2011-02-10
EFG2011-03-20
GHI2011-04-30
IJK2011-05-01
LMN2012-01-01 |
Output File(should contain records from Input File-2. Comparison is 4,10 of file 2 which are greater than 1,10 and lesser than 2,10 of file 1)
| Code: |
----+----1---
ABC2011-01-01
CDE2011-02-10
EFG2011-03-20
GHI2011-04-30
IJK2011-05-01 |
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
HameedAli,
Use the following DFSORT JCL which will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
OPQ2010-01-01
ABC2011-01-01
CDE2011-02-10
EFG2011-03-20
GHI2011-04-30
IJK2011-05-01
LMN2012-01-01
//INB DD *
2011-01-012011-12-31
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(81,1,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(81,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,80,F2:1,20)
OUTFIL BUILD=(1,80),
INCLUDE=(4,10,CH,GE,81,10,CH,AND,4,10,CH,LE,91,10,CH)
//JNF1CNTL DD *
INREC OVERLAY=(81:C'1')
//JNF2CNTL DD *
INREC OVERLAY=(81:C'1')
//* |
|
|
| Back to top |
|
 |
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
Skolusu, it was of great help and very precise.
I don't understand the significance of the CNTL cards.
how 4,10 refers to INB not INA
and the (81,1,A)SORTED,NOSEQCK
| Quote: |
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(81,1,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(81,1,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,80,F2:1,20)
OUTFIL BUILD=(1,80),
INCLUDE=(4,10,CH,GE,81,10,CH,AND,4,10,CH,LE,91,10,CH)
//JNF1CNTL DD *
INREC OVERLAY=(81:C'1')
//JNF2CNTL DD *
INREC OVERLAY=(81:C'1')
//* |
|
|
| Back to top |
|
 |
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
| Is it possible to SORT while using JOINKEYS, I tried SORT FIELDS(1,3,CH,A). The step went fine, but the output wasn't sorted. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| HameedAli wrote: |
I don't understand the significance of the CNTL cards.
how 4,10 refers to INB not INA and the (81,1,A)SORTED,NOSEQCK |
HameedAli,
Since your files did not have a key to match from both files, we pad an arbitrary value of '1' in both files at the end of the record and use that as a matching key. Since we are padding the extra byte and we know it is sorted, so there is no need for sorting during match. SORTED,NOSEQCK tells DFSORT not to check the order of the records which can improve performance.
| HameedAli wrote: |
| Is it possible to SORT while using JOINKEYS, I tried SORT FIELDS(1,3,CH,A). The step went fine, but the output wasn't sorted. |
Yes it is possible. Replace the OPTION COPY statement with SORT FIELDS=(1,3,CH,A).
I am assuming that you did not remove the OPTION COPY statement and just added SORT statement which DFSORT ignored as OPTION COPY was used. |
|
| Back to top |
|
 |
HameedAli
Active User
Joined: 16 Apr 2009 Posts: 151 Location: India
|
|
|
|
Thanks for the detailed response Skolusu.
Performance wise which is better?
1) Sorting step separately and then perform JOIN step separately.
2) SORT and JOIN in same step? |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
| Performance wise which is better? |
Your mileage may vary. . .
Suggest you try both with the "real" data (not some subset) and determine which is better for you. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|