View previous topic :: View next topic
Author
Message
useit Active User Joined: 05 Oct 2006Posts: 152
hi,
i am facinfg a tricky problem .
problem:
i have a file with record 10. (1-4 is key)
say for example:
input file1:
Code:
KEY1AAA111
KEY1AAA222
KEY1BBB333
KEY2MMM888
KEY2MMM888
KEY2MMM888
KEY3PPP333
KEY3PPP444
for the key if there are no changes in the data fields i should write it into unique file.
for the key if any changes in the any of the field i should write it into differ file.
so my unique outfile should have:
Code:
KEY2MMM888
KEY2MMM888
KEY2MMM888
and my defer file should have
Code:
KEY1AAA111
KEY1AAA222
KEY1BBB333
KEY3PPP333
KEY3PPP444
could you please suggest me how can this be achieved through jcl?? using join keys or any other utility?
regds,
useit
Back to top
useit Active User Joined: 05 Oct 2006Posts: 152
hi,
could someone please suggest me some approach?
Regds,
useit
Back to top
Ramsee New User Joined: 06 Jan 2011Posts: 53 Location: Chennai
Hi Useit,
Please use the below work around of this requirement,
If its an ADHOC request or requirement you can try in SORT, Else you can go for a COBOL PGM.
Code:
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
KEY1AAA111
KEY1AAA222
KEY1BBB333
KEY2MMM888
KEY2MMM888
KEY2MMM888
KEY3PPP333
KEY3PPP444
//SORTOUT DD SYSOUT=*
//SORTXSUM DD DSN=USER.TEST.FILE.XSUM,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE),
// DCB=(LRECL=10,BLKSIZE=0,RECFM=FB)
//SYSIN DD *
SORT FIELDS=(1,10,CH,A)
SUM FIELDS=NONE,XSUM
/*
//STEP02 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=USER.TEST.FILE.XSUM,DISP=SHR
//SORTOUT DD DSN=USER.TEST.FILE.XSUM1,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE),
// DCB=(LRECL=10,BLKSIZE=0,RECFM=FB)
//SYSIN DD *
SORT FIELDS=(1,10,CH,A)
SUM FIELDS=NONE
/*
//STEP03 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD *
KEY1AAA111
KEY1AAA222
KEY1BBB333
KEY2MMM888
KEY2MMM888
KEY2MMM888
KEY3PPP333
KEY3PPP444
//SORTJNF2 DD DSN=USER.TEST.FILE.XSUM1,DISP=SHR
//MTCH01 DD DSN=USER.JOIN.MATCH,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE),
// DCB=(LRECL=10,BLKSIZE=0,RECFM=FB)
//UNMTCH01 DD DSN=USER.JOIN.UNMATCH.F1,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE),
// DCB=(LRECL=10,BLKSIZE=0,RECFM=FB)
//UNMTCH02 DD DSN=USER.JOIN.UNMATCH.F2,
// DISP=(,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE),
// DCB=(LRECL=10,BLKSIZE=0,RECFM=FB)
//SYSIN DD *
OPTION COPY
JOINKEYS FILES=F1,FIELDS=(1,10,A)
JOINKEYS FILES=F2,FIELDS=(1,10,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:01,15,F2:01,15)
OUTFIL FNAMES=MTCH01,
INCLUDE=(1,1,CH,NE,C' ',AND,11,1,CH,NE,C' '),
BUILD=(1,10)
OUTFIL FNAMES=UNMTCH01,
INCLUDE=(1,1,CH,NE,C' ',AND,11,1,CH,EQ,C' '),
BUILD=(1,10)
OUTFIL FNAMES=UNMTCH02,
INCLUDE=(1,1,CH,EQ,C' ',AND,11,1,CH,NE,C' '),
BUILD=(11,10)
Please verify the details of USER.JOIN.MATCH and USER.JOIN.UNMATCH.F1.
I dont feel this is the right solution to this requirement, please guide me if i am wrong.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
I think you'll have to look at this one .
How many records on the file?
It can be done., but I think it is quite complex.
Once you get to the end of a key, you need to know if all your data is the same for the key. At the start of a key, you need to know where to write the data.
In a general programming language you'd store in a table and process "one behind" (processing key at "break" of key or end-of-file).
Both parts of that can be done with JOINKEYS - just not at the same time.
So I'd suggest working on the left/right from the link and using the JOINKEYS for the extract.
You need three things: record-to-recod, is the data the same (watch out for data of one key accidentally matching data of another); end of key, here's the record I want; the JOINKEYS with the records you want to extract the data you want.
If you concentrate on the matches, they go to one OUTFIL and on the other OUTFIL you just use SAVE (which gets everything which has not beem written to another OUTFIL). So you don't need to code for mismatches, just for matches.
This task is easy in a gpl.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Ramsee,
DFSORT does not have XSUM. Mind you, does useit have DFSORT?
Back to top
Ramsee New User Joined: 06 Jan 2011Posts: 53 Location: Chennai
Hi Bill,
Thanks for educating me that DFSORT will not support XSUM.
Hi Useit,
You can try to filter the DUPLICATE Records via the following steps as well. DUPKEYS
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Ramsee,
Sorry, no DUPKEYS either.
Don't have time to look closely, but the requirement is: mixture of data (5,6) per key (1,4), records for that key go to one file, else records for that key go to another.
Back to top
Please enable JavaScript!