View previous topic :: View next topic
Author
Message
rakesh1155 New User Joined: 21 Jan 2009Posts: 84 Location: India
I have a dataset:
TEST.GROUPS (FB,LRECL=8)
AAAAAAAA
BBBBBBBB
CCCCCCC
HHHHHHHH
IN.DATASET (FB.LRECL=80) contains :
AAAAAAAA DATA1A........
AAAAAAAA DATA1B........
AAAAAAAA DATA1C........
BBBBBBBB DATA2A........
BBBBBBBB DATA2A........
CCCCCCC DATA3A........
DDDDDDD DATA4A........
EEEEEEEEE DATA5A........
EEEEEEEEE DATA5B........
EEEEEEEEE DATA5C........
FFFFFFFFFF DATA6A........
GGGGGGG DATA7A........
HHHHHHHH DATA8A........
HHHHHHHH DATA8B........
HHHHHHHH DATA8C........
The output should compare the two datasets for the 1st 8 bytes and give a third datset with all the matching records from the IN.DATASET
In this case, the OUT.DATSET(FB,LRECL=80) should contain
AAAAAAAA DATA1A........
AAAAAAAA DATA1B........
AAAAAAAA DATA1C........
BBBBBBBB DATA2A........
BBBBBBBB DATA2A........
CCCCCCC DATA3A........
HHHHHHHH DATA8A........
HHHHHHHH DATA8B........
HHHHHHHH DATA8C........
Because 8 As , 8Bs, 8 Cs and 8 Hs are existing in TEST.GROUPS.
Can we achieve it through SORT INCLUDE COND?
Can the INCLUDE COND be extended to other datasets ?
Thanking in advance,
Rakesh.
Back to top
Bala1 New User Joined: 18 Mar 2010Posts: 6 Location: london
Back to top
rakesh1155 New User Joined: 21 Jan 2009Posts: 84 Location: India
Thanks Bala!
The Cartesian Join will merge records from both the files.
But in my requirement, the output file should contain records from IN.DATSET (File2) with a match in TEST.GROUPS(File1).
The output should not contain records from TEST.GROUPS (File1).
Will the Cartesian Join Help ?
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
Quote:
Will the Cartesian Join Help ?
No. I don't know why this was suggested. . .
Unless i completely misunderstand what you are looking for, you want a 2-file match on a key (not a Cartesian product). . .
There are many examples of matching 2 files in the forum. . . Suggest you use one of these as a guide.
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
rakesh1155,
The following DFSORT JCL will give you the desired results.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your 8 byte input file,DISP=SHR
//SORTOUT DD DSN=&&TM80,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//HDR DD DSN=&&HDR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//OUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC OVERLAY=(80:X)
OUTFIL FNAMES=HDR,ENDREC=1,BUILD=(C'$$$',80:X)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.HDR
// DD DSN=&&TM80,DISP=SHR
// DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.HDR
// DD DSN=your input 80 byte file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(81:ID=1))
SORT FIELDS=(1,8,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,OVERLAY=(83:SEQNUM,8,ZD,RESTART=(1,8))),
IFTHEN=(WHEN=GROUP,BEGIN=(83,8,ZD,EQ,1),PUSH=(82:81,1))
OUTFIL INCLUDE=(81,2,ZD,EQ,21,AND,1,3,CH,NE,C'$$$'),BUILD=(1,80)
//*
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
I probably made a bad assumption that both files were already in key sequence.
If the files are in sequence, would this not be a candidate for JOINing. . .?
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
dick scherrer wrote:
Hello,
I probably made a bad assumption that both files were already in key sequence.
If the files are in sequence, would this not be a candidate for JOINing . . .?
Dick scherrer,
Sorted or unsorted it is an ideal candidate for joinkeys function. However I wasn't sure if OP had the latest PTF. If has the Latest PTF then he can use this job
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD DSN=your input FB 80 byte file,DISP=SHR
//SORTJNF2 DD DSN=your input FB 8 byte file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILES=F1,FIELDS=(1,8,A),SORTED,NOSEQCK
JOINKEYS FILES=F2,FIELDS=(1,8,A),SORTED,NOSEQCK
REFORMAT FIELDS=(F1:1,80)
SORT FIELDS=COPY
//*
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Note: Make sure you only use NOSEQCK if you KNOW that your records are already in sorted order. With SORTED and without NOSEQCK, DFSORT will check for out of order records and issue a message if it finds one. With SORTED and NOSEQCK, DFSORT does NOT check for out of order records (which can improve performance), so you must be sure that the records are already in order.
Back to top
rakesh1155 New User Joined: 21 Jan 2009Posts: 84 Location: India
Thanks all you guys for your help.
I was able to achieve the desired results using the JOINKEYS. Yes, the files will be in sorted order.
I was a bit uncomfortable to understand the IFTHEN solution mentioned above. Skolusu, If you dont mind, please elaborate that solution.
-Thanks again,
Rakesh.
Back to top
Please enable JavaScript!