|
View previous topic :: View next topic
|
| Author |
Message |
ksouren007
New User
Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
|
|
|
|
Hi,
I am trying to work on Joinkeys requirement and need some help.
SORTJNF1 - FB/LRECL - 102
SORTJNF1 file will be having unique occurence of the key.
SORTJNF2 - FB-LRECL - 834
SORTJNF2 file will be having multiple occurence of the key.
SORTOUT - FB/LRECL - 834
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,16,A)
JOINKEYS FILE=F2,FIELDS=(1,16,A)
OPTION COPY
REFORMAT FIELDS=(F2:1,834,F1:1,102,?)
INREC IFTHEN=(WHEN=((806,1,CH,EQ,C'S',OR,
806,1,CH,EQ,C'E'),AND,
880,1,CH,EQ,C'S'),
OVERLAY=(17:C'S'))
INCLUDE COND=(937,1,CH,EQ,C'B')
OUTREC FIELDS=(1,834)
|
I am using the above code successfully to get the common matched OVERLAYED records at the output file.
However, my requirement is to OVERLAY the common matched records in the output file while write the unmatched records from SORTJNF2 file at the output as is.
Can I achieve this at one pass? Pls advise. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Use JOIN UNPAIRED F1,F2 and then OUTFIL INCLUDE + BUILD
So your code would become
Try this untested
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,16,A)
JOINKEYS FILE=F2,FIELDS=(1,16,A)
JOIN UNPAIRED F1,F2
REFORMAT FIELDS=(F2:1,834,F1:1,102,?)
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=((806,1,CH,EQ,C'S',OR,
806,1,CH,EQ,C'E'),AND,
880,1,CH,EQ,C'S'),
OVERLAY=(17:C'S'))
OUTFIL FNAMES=BOTHFS,INCLUDE=(937,1,CH,EQ,C'B'),BUILD=(1,834)
OUTFIL FNAMES=F2ONLY,INCLUDE=(937,1,CH,EQ,C'2'),BUILD=(1,102) |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Add JOIN UNPAIRED,F2
Your IFTHEN will be false (the F1 data will all be blanks).
Your INCLUDE COND= is redundant in your code (you only get Bs) and is unnecessary also for getting Bs and 2s, as you'll only get given those from the above JOIN.
You can "cut down" the REFORMAT record with IFOUTLEN=834, so when the IFTHEN processing is finished, the records will be treated as 834 bytes.
Something like this should be close:
| Code: |
JOINKEYS FILE=F1,FIELDS=(1,16,A)
JOINKEYS FILE=F2,FIELDS=(1,16,A)
JOIN UNPAIRED,F2
OPTION COPY
REFORMAT FIELDS=(F2:1,834,F1:1,102)
INREC IFOUTLEN=834,
IFTHEN=(WHEN=((806,1,CH,EQ,C'S',OR,
806,1,CH,EQ,C'E'),AND,
880,1,CH,EQ,C'S'),
OVERLAY=(17:C'S')) |
|
|
| Back to top |
|
 |
ksouren007
New User
Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
|
|
|
|
Thanks all for replying.
I went for Bill's option as I wanted one output file at a single pass..and It worked great.
Thanks a lot! |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| Thanks for letting us know. You can drop the ? in the REFORMAT, as the content is no longer used. I missed that before. Updating the original. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Ksouren007,
You don't really need to sort the whole File 1 as you are only interested in just the key and 46th byte (validating byte 880 after reformat), so just build those 2 fields.
Also as rule of thumb always code your duplicate file as SORTJNF1 and unique file as SORTJNF2.
Use the following JCL
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DISP=SHR,DSN=Your 834 Byte Duplicate file
//SORTJNF2 DD DISP=SHR,DSN=Your 102 Byte Unique file
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS FILE=F1,FIELDS=(1,16,A)
JOINKEYS FILE=F2,FIELDS=(1,16,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,834,F2:17,1)
INREC IFOUTLEN=834,
IFTHEN=(WHEN=((806,1,CH,EQ,C'S',OR,806,1,CH,EQ,C'E'),AND,
835,1,CH,EQ,C'S'),OVERLAY=(17:C'S'))
//*
//JNF2CNTL DD *
INREC BUILD=(1,16,46,1)
//* |
|
|
| Back to top |
|
 |
ksouren007
New User
Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
|
|
|
|
| Thanks for letting me know the trick Skolusu...the tweak went fine! |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|