Joined: 02 Dec 2002 Posts: 616 Topics: 171 Location: Stockholm, Sweden
Posted: Tue Oct 10, 2017 6:09 am Post subject: JOINKEYS with 2 variable length files
I've been experimenting, and can't get the last bit of what I want to do to work. Here is my JCL:-
Code:
//JKE5 EXEC PGM=SORT
//*
//SYSOUT DD SYSOUT=*
//* NEXT FILE IS RECFM V AND LRECL 27994
//SORTJNF1 DD DSN=&SYSUID..M62530G1.BATCH.NEW,DISP=SHR
//* NEXT FILE IS RECFM V AND LRECL 2070
//SORTJNF2 DD DSN=&SYSUID..M63010G1.BATCH.NEW,DISP=SHR
//*
//*F1ONLY DD SYSOUT=*
//*
//UNMATCH DD DSN=&SYSUID..M63505G1.BATCH.NEW.DFSORT,
// DISP=(,CATLG,),
// SPACE=(TRK,(10,5),RLSE)
//*
//MATCH DD DSN=&SYSUID..M63505S1.SYSDA.NEW.DFSORT,
// DISP=(,CATLG,),
// SPACE=(TRK,(10,5),RLSE)
//*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(23,22,A),SORTED,NOSEQCK
JOINKEYS FILE=F2,FIELDS=(23,22,A),SORTED,NOSEQCK
JOIN UNPAIRED,F1,F2
REFORMAT FIELDS=(F1:1,4,?,F1:5)
OPTION COPY
OUTFIL FNAMES=MATCH,INCLUDE=(5,1,CH,EQ,C'B'),BUILD=(1,4,6)
OUTFIL FNAMES=UNMATCH,INCLUDE=(5,1,CH,EQ,C'2'),BUILD=(1,4,6)
/*
File SORTJFN1 contains 1579 records, SORTJFN2 contains 38. SORTJFN2 is the "controlling" file. For each match between files 1 & 2, the record should be written to MATCH, any unmatched records in file2 should be written to UNMATCH (in my example, MATCH will end up with 1 record, UNMATCH with 37).
When I run the code above, I get the correct record in MATCH. I also get 37 records in UNMATCH, but all are blank (I sort of get why since I'm not referring to file2 in my REFORMAT).
How do I need to change the SORT parms to achieve what I want (maybe there's an even easier way of doing it as well and that would do fine) _________________ Michael
Joined: 02 Dec 2002 Posts: 616 Topics: 171 Location: Stockholm, Sweden
Posted: Tue Oct 10, 2017 7:05 am Post subject:
Almost perfect. I knew I had no reference to the second file, but didn't know HOW to include it in the REFORMAT.
One question though. Running your changed DFSORT, I end up with the MATCH file having LRECL 27994 and the UNMATCH having 2070. I want 2070 for BOTH of them. One obvious way would be to specify the DCB's in the JCL, but is there a better way of doing it via the DFOSRT parms ? (I tried
Joined: 26 Nov 2002 Posts: 12359 Topics: 75 Location: San Jose
Posted: Tue Oct 10, 2017 7:46 am Post subject:
misi01 wrote:
One question though. Running your changed DFSORT, I end up with the MATCH file having LRECL 27994 and the UNMATCH having 2070. I want 2070 for BOTH of them. One obvious way would be to specify the DCB's in the JCL, but is there a better way of doing it via the DFOSRT parms ?
Thanks
Huh? Your input F1 has an lrecl of 27994 and it is copied as is. If you just need 2066 bytes then specify it on Reformat statement. Why do you want to create the match file with length of 2070? _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 616 Topics: 171 Location: Stockholm, Sweden
Posted: Tue Oct 10, 2017 8:00 am Post subject:
The existing COBOL program already creates the output files with those DCB's.
If I'm going to change the code so it uses DFSORT instead of COBOL, then I want to ensure that no other programs down the line fail because the DCB's have been changed. _________________ Michael
Joined: 26 Nov 2002 Posts: 12359 Topics: 75 Location: San Jose
Posted: Tue Oct 10, 2017 9:08 am Post subject:
misi01 wrote:
The existing COBOL program already creates the output files with those DCB's.
If I'm going to change the code so it uses DFSORT instead of COBOL, then I want to ensure that no other programs down the line fail because the DCB's have been changed.
Misi01,
Just add the cobol fileds that you coded for creating the output file to the REFORMAT fileds. _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Joined: 02 Dec 2002 Posts: 616 Topics: 171 Location: Stockholm, Sweden
Posted: Wed Oct 11, 2017 2:25 am Post subject:
Thanks for the help. Am trying to understand something that is puzzling me. The reformat line
Code:
REFORMAT FIELDS=(F1:1,4,?,F2:5,2066,F1:5)
The way I understand it (and as I've said before, I'm not a DFSORT expert) is that it copies bytes 1-4 (the RDW) from file 1, then the ? will be replaced by a B or 2 which will be addded depending on whether there was a match or not. This is then followed by file 2, positions 5-2070, and finally, by file 1, position 5 onwards.
If that is correct, then with the BUILD parms you included, what happens if the record lengths differ between the matching records. For example, suppose the matching record in F1 has a 100 bytes and the equivalent record in file 2 only has 40. With the command
Joined: 26 Nov 2002 Posts: 12359 Topics: 75 Location: San Jose
Posted: Wed Oct 11, 2017 9:51 am Post subject:
misi01 wrote:
If that is correct, then with the BUILD parms you included, what happens if the record lengths differ between the matching records. For example, suppose the matching record in F1 has a 100 bytes and the equivalent record in file 2 only has 40. With the command
won't that result in the matched record being written with an RDW of 100 rather than 40?
Misi01,
If you looked at the REFORMAT statement carefully, you would notice that we ONLY specified the starting position of the records, but did NOT specify the length. When you specify in that format, DFSORT automatically treats the variable length records and updates the RDW when writing out with the actual lrecl.
But for the unmatch file you have specified BOTH the starting position as well as the length. So any short records will be padded up with spaces to the length you specified and that is the reason I had VLTRIM=C' ' to remove the excess spaces we padded at the end.
For variable-length records, the first item in the BUILD or OUTREC parameter must specify or include the unedited 4-byte record descriptor word (RDW), that is, you must start with 1,m with m equal to or greater than 4. If you want to include the bytes from a specific position to the end of each input record at the end of each reformatted output record, you can specify that starting position (p) as the last item in the BUILD or OUTREC parameter. For example:
Code:
OUTFIL OUTREC=(1,4, unedited RDW
1,2,BI,TO=ZD,LENGTH=5, display RDW length in decimal
C'|', | separator
5) display input positions 5 to end
_________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum