MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Thu Oct 28, 2010 4:34 am Post subject: Delete set of records on match
Hi,
My input data is like this (RECFM=FB, LRECL=400)
Code:
----+----1----+----2----+----3----+----4----+----5
SECHEAD123456REC 0009876BALLSTORE
DR00%$0304002010040403030300000 NAIL SORC0000
DR00%$0304002010040403030300000 CAIL SORC0001
DR00%$0304002010040403030300000 NAIS SORC0002
SECHEAD123123REC 0008765CALLMORES
DR00%$0304002010040403030300000 NAGL SORC0001
DR00%$0304002010040403030300000 NAIT SORC0002
DR00%$0304002010040403030300000 NAIY SORC0004
SECHEAD123456REC 0009876FALLWINTR
DR00%$0304002010040403030300000 NAIN SORC0007
DR00%$0304002010040403030300000 NAIS SORC0009
DR00%$0304002010040403030300000 NPIL SORC0020
DR00%$0304002010040403030300000 VPIL SORC0110
In the above set of records (Each set starts with SECHEAD) there are two duplicate sets. I want to retain only one set using SORT utility.
The comparison should be done on fields starting from 8th column (6 length) and 19th column (7 length) and if both matches then the 2nd set of records should be deleted.
Expected Output:
Code:
----+----1----+----2----+----3----+----4----+----5
SECHEAD123456REC 0009876BALLSTORE
DR00%$0304002010040403030300000 NAIL SORC0000
DR00%$0304002010040403030300000 CAIL SORC0001
DR00%$0304002010040403030300000 NAIS SORC0002
SECHEAD123123REC 0008765CALLMORES
DR00%$0304002010040403030300000 NAGL SORC0001
DR00%$0304002010040403030300000 NAIT SORC0002
DR00%$0304002010040403030300000 NAIY SORC0004
Please help.
Thanks In Advance. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Oct 28, 2010 10:20 am Post subject:
ranga_subham ,
Assuming that the output is sorted on the keys at 8 and 19 , the following DFSORT JCL will give you the desired results
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your input FB 400 byte file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,7,CH,EQ,C'SECHEAD'),
PUSH=(401:ID=8,8,6,19,7))
SORT FIELDS=(409,13,CH,A),EQUALS
OUTREC IFTHEN=(WHEN=INIT,
OVERLAY=(422:SEQNUM,8,ZD,RESTART=(409,13))),
IFTHEN=(WHEN=GROUP,BEGIN=(422,8,ZD,EQ,1),PUSH=(430:401,8))
OUTFIL BUILD=(1,400),INCLUDE=(401,8,CH,EQ,430,8,CH)
//*
The output from this job is
Code:
SECHEAD123123REC 0008765CALLMORES
DR00%$0304002010040403030300000 NAGL SORC0001
DR00%$0304002010040403030300000 NAIT SORC0002
DR00%$0304002010040403030300000 NAIY SORC0004
SECHEAD123456REC 0009876BALLSTORE
DR00%$0304002010040403030300000 NAIL SORC0000
DR00%$0304002010040403030300000 CAIL SORC0001
DR00%$0304002010040403030300000 NAIS SORC0002
_________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Fri Oct 29, 2010 5:47 am Post subject:
Hi,
Quote:
Assuming that the output is sorted on the keys at 8 and 19
You want me to sort the input before passing it to this solution. Or, this solution would take care fo sorting.
Thanks. _________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
ranga_subham Intermediate Joined: 31 Jan 2006 Posts: 255 Topics: 72
Posted: Fri Oct 29, 2010 9:31 am Post subject:
Thanks a lot Kolusu.
_________________ Ranga
*****
None of us is as smart as all of us - Ken Blanchard
Back to top
computer Beginner Joined: 12 Jun 2007 Posts: 64 Topics: 17 Location: Hyderabad
Posted: Thu Dec 09, 2010 2:57 pm Post subject:
Hi ranga_subham,
With the use of the following ICETOOL control card, your purpose will be solved,
SELECT FROM(INPUT) TO(OUTPUT) ON(8,6,CH) ON(19,7,CH) FIRST
Anyone please correct me, if I am going wrong...
Thanks,
Computer
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Dec 09, 2010 3:29 pm Post subject:
computer wrote: Anyone please correct me, if I am going wrong...
Computer,
If you followed your own advice and ran the job with your control cards you would have known how wrong you are.
Please do NOT post incorrect solutions without testing or understanding the requirements.
Thank you _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
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