Posted: Wed Mar 31, 2004 7:18 pm Post subject: Duplicates are not deleted
Hi,
I have used the piece of jcl found in this forum, for my requirement. (My requirement is 2 files have to merged, duplicates have to be eliminated and results have to written into another dataset ). My jcl is
Code:
//S02 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=A
//SORTIN DD DSN=&&VSAMOUT,DISP=(OLD,DELETE,DELETE)
// DD DSN=HLQ.INPUT.FILE,DISP=SHR
//SORTOUT DD DSN=&&OUT,DISP=(,PASS),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),
// SPACE=(TRK,(5,5),RLSE),UNIT=SYSPROD
//SYSIN DD *
INREC FIELDS=(1,80,X'001C') & total recl is 80
SORT FIELDS=(1,14,CH,A) & keys are 1 to 14
SUM FIELDS=(81,2,PD)
OUTFIL INCLUDE=(81,2,PD,EQ,1),
OUTREC=(1,80)
The job went through successfully, but the record is not deleted. Is there anything I am making wrong in the jcl?
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Wed Mar 31, 2004 7:38 pm Post subject:
This DFSORT job is equivalent to using a DFSORT/ICETOOL SELECT statement like the following:
Code:
SELECT FROM(IN) TO(OUT) ON(1,14,CH) NODUPS
This will keep only those records that have NO duplicates. So if your input had:
Code:
AAA
AAA
BBB
CCC
CCC
CCC
DDD
Your output would be:
Code:
BBB
DDD
If that's the kind of thing you're trying to do, then you have to explain what you mean by "the record is not deleted". What record?
Tell us what you're trying to do and show us an example of your input and what you expect for output. Then we can help you.
Or if you want to be really adventurous, read the following doc on the SELECT operator of DFSORT's ICETOOL and see if you can figure out how to do it yourself:
Note that there are other options besides NODUPS (FIRST, FIRSTDUP, etc) that might give you what you want. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
I tried select with NODUPS option earlier. The error msg what I got was,
SYSIN :
SELECT FROM(SORTIN) TO(SORTOUT) ON(1,14,CH) NODUPS
*
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
Objective : The keys found in the input file will be used to delete the corresponding records in the vsam file.
To do that, the vsam file records will be repro'ed first and merged with input file and duplicates has to be removed. Then, the remaining records willbe repro'ed back to vsam file. But I could see that the record is not getting deleted. I do not know is there anything needs to be changed in the sort parameter. Please let me know.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Wed Mar 31, 2004 11:58 pm Post subject:
Sumathi,
The problem with your code is that u have used the SORTIN and SORTOUT as your DD names for select statement. They are reserved for other purposes, so try using IN and OUT or any other DD name. I got the same error message and I changed the DD name and it worked for me..
Try using
SELECT FROM(IN) TO(OUT) ON(1,14,CH) NODUPS
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Thu Apr 01, 2004 5:46 am Post subject:
sumathi,
You need to post more details. Post detailed information on what you're trying to accomplish. Do not make people guess what you mean. This will give you a much better chance of getting a good answer to your questions.show us a sample input and desired output.
Your JCL looks fine and will eliminate duplicates. It is your repro which will not delete the records. when you repro it will not delete the existing contents, but will append new records or replace the contents. check this link to know more about repro
I have to use IDCAMS and SORT instead of SYNCTOOL. Hence I have been forced to do this way.
Here we go, the detailed information about my assignment.
I have to delete some records from the existing VSAM file(lrecl 80 - keys 1 to 14). The keys of the records to be deleted will be given in seq file(lrecl 80). What I am trying to do is as follows.
1. Do REPRO on a VSAM file to temp dataset(lrecl 80).
For ex the contents of VSAM file is,
AAAAAAAAAAAAAAasdfodfsdfsjfsdfsdjafdjf
BBBBBBBBBBBBBBfadfsdfdsfadsfsdfasdfff
CCCCCCCCCCCCCasdfsdfdasfasdfsdafsd
2. The record to be deleted is BBBBBBBBBBBBBB(will be in input file)
3. Concat the temp dataset with the input file.
After concat the records will be,
AAAAAAAAAAAAAAasdfodfsdfsjfsdfsdjafdjf
BBBBBBBBBBBBBBfadfsdfdsfadsfsdfasdfff
CCCCCCCCCCCCCasdfsdfdasfasdfsdafsd
BBBBBBBBBBBBBB
3. Now I want to delete the duplicates using SORT.
4. After SORT the records should be,
AAAAAAAAAAAAAAasdfodfsdfsjfsdfsdjafdjf
CCCCCCCCCCCCCasdfsdfdasfasdfsdafsd
5. REPRO back the above to VSAM file again.
After the above exercise I could see that the record is not deleted from VSAM file. I used file aid to view the contents of VSAM file.
My goal is to delete the records from VSAM file using IDCAMS and SORT. Please let me know if you have any other ideas as well.
Thanks, Sumathi
Now I found the problem. Though I am using REPRO with REPLACE at step 5, the VSAM file is not getting refreshed. That was the problem. To resolve this I have included 2 more steps. That is delete and create the vsam file before REPRO. Now I could see what I want.
Now my question is: Is that necessary to delete and recreate the VSAM file again? Will it not refreshed by itself?
Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
Posted: Thu Apr 01, 2004 1:32 pm Post subject:
Sumathi,
Please be clear in your requirements. The first time you posted you asked for a JCL solution which was provided to you. Later you started another topic that duplicates are not deleted which is related to the same question.
Before you take up an assignment make sure to ask what exactly needs to be done. Don't waste time of other members with incomplete details.
You are after quick solutions but does not pay attention to read the instructions posted for the solutions. All you do is come up with a post that it is not working. If you had to use repro then you have to delete the vsam cluster and redefine the vsam cluster for the delete to work. Look at the bottom for the deletion and recreation step of the cluster.
Here is a solution with sort.
Insert Solution:
Code:
//******************************************************************
//* THIS STEP COPIES THE VSAM FILE CONTENTS TO A TEMP FILE *
//******************************************************************
//STEP0100 EXEC PGM=SORT,PARM='VSAMEMT=YES'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=HLQ.IND.VSAMFILE,
// DISP=SHR
//SORTOUT DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
/*
//******************************************************************
//* THIS STEP WILL INSERT NEW RECS IN A VSAM CLUSTER. *
//******************************************************************
//STEP0200 EXEC PGM=SORT,PARM='VSAMEMT=YES'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&T1,DISP=OLD
// DD *
AAAA BVT ASDFASFDFADSFASDFA
BBBB BVT BSDFASFDFADSFASDFA
CCCC BVT DAFSDFSDFASDFASDF
//SORTOUT DD DSN=HLQ.IND.VSAMFILE,DISP=OLD
//SYSIN DD *
OPTION VSAMIO,RESET
SORT FIELDS=(1,14,CH,A)
/*
Delete Solution
Code:
//******************************************************************
//* THIS STEP COPIES THE VSAM FILE CONTENTS TO A TEMP FILE *
//******************************************************************
//STEP0300 EXEC PGM=SORT,PARM='VSAMEMT=YES'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=HLQ.IND.VSAMFILE,
// DISP=SHR
//SORTOUT DD DSN=&T2,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
/*
//******************************************************************
//* THIS STEP WILL DELETE RECS IN A VSAM CLUSTER. *
//******************************************************************
//STEP0400 EXEC PGM=SORT,PARM='VSAMEMT=YES'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&T2,DISP=OLD
// DD *
BBBB BVT BSDFASFDFADSFASDFA
//SORTOUT DD DSN=HLQ.IND.VSAMFILE,DISP=OLD
//SYSIN DD *
OPTION VSAMIO,RESET
INREC FIELDS=(1,80,C'01')
SORT FIELDS=(1,14,CH,A)
SUM FIELDS=(81,2,ZD)
OUTFIL INCLUDE=(81,2,ZD,EQ,1),OUTREC=(1,80)
/*
Update Solution:
Code:
//******************************************************************
//* THIS STEP COPIES THE VSAM FILE CONTENTS TO A TEMP FILE *
//******************************************************************
//STEP0500 EXEC PGM=SORT,PARM='VSAMEMT=YES'
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=HLQ.IND.VSAMFILE,
// DISP=SHR
//SORTOUT DD DSN=&T3,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
/*
//******************************************************************
//* THIS STEP WILL UPDATE RECS IN A VSAM CLUSTER. *
//******************************************************************
//STEP0600 EXEC PGM=SORT,PARM='VSAMEMT=YES'
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAA BVT ASDFA
// DD DSN=&T3,DISP=OLD
//SORTOUT DD DSN=HLQ.IND.VSAMFILE,DISP=OLD
//SYSIN DD *
OPTION VSAMIO,RESET
INREC FIELDS=(1,80,C'01')
SORT FIELDS=(1,14,CH,A)
SUM FIELDS=(81,2,ZD)
OUTFIL INCLUDE=(81,2,ZD,EQ,1),OUTREC=(1,80)
/*
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