Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Mar 24, 2004 9:26 pm Post subject:
sumathi,
Quote:
I have to do this assignment using JCL only. Hence please provide me JCL solutions.
I am sorry to say that there aren't any pure JCL solutions which can get your tasks done.
As of date JCL by itself can do nothing. It is programs/utitlites that perform the tasks.
You need an utility(Idcams, DFSORT..) or a pgm written in cobol, PLI, easytrieve... to perform the insert/update/delete. You need a JCl to run any utility or pgm.
I can compile and run a cobol pgm by coding the pgm as an instream. will that work for you? so Please be clear on how you want to do and then may be we can suggest a solution.
In the mean time, I have gone through other postings and decided to do it in the following way.
For Delete:
Repro VSAM to Seq file2 ; Use SORT to merge Seq file and Seq file2 ; Use SELECT with NODUPS : Repro back the output with REPLACE option
For Update:
Same as above, but without NODUPS.
I assume that the above options will work. Please let me know if you have any other options.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Thu Mar 25, 2004 9:52 am Post subject:
Sumathi,
Here are the solutions for your questions using utilies. The following DFSORT/ICETOOL job will give you the desired results. If you have syncsort at your shop then change the pgm name to synctool. Make sure VSAM is defined with REUSE. I asssumed that your vsam key is 9 bytes in length and starts in pos1.
Insert solution:
We first copy contents of the vsam file to a temp dataset. Now we concatenate this temp dataset along with the records to be inserted and load back to the original file.Note that the out vsam dataset is same as the input dataset. You can use the same input vsam file as output vsam file when it is defined with REUSE option.
Code:
//*******************************************************************
//* THIS STEP WILL INSERT NEW RECORDS INTO AN EXISTING VSAM CLUSETER*
//*******************************************************************
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//VSAMIN DD DSN=YOUR INPUT VSAM FILE,
// DISP=SHR
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//CON DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
// DD DSN=YOUR NEW VSAM INSERT REC FILE,
// DISP=SHR
//OUT DD DSN=YOUR INPUT VSAM FILE,
// DISP=OLD
//TOOLIN DD *
COPY FROM(VSAMIN) TO(T1)
SORT FROM(CON) TO(OUT) USING(CTL1)
//CTL1CNTL DD *
OPTION VSAMIO,RESET
SORT FIELDS=(1,9,CH,A) $ SORT ON VSAM KEY FIELD
/*
UPDATE solution:
We first copy contents of the vsam file to a temp dataset. Now we concatenate this temp dataset along with the records to be updated and load back to the original file. But the only difference is that we make update records file to be in the first concatenation list. so using EQUALS option and eliminating the duplicates using sum fields=none, we can update the desired keys.Note that the out vsam dataset is same as the input dataset. You can use the same input vsam file as output vsam file when it is defined with REUSE option.
We first copy contents of the vsam file to a temp dataset. Now we concatenate this temp dataset along with the records to be deleted and load back to the original file.when we concate the records to be deleted file with the temp dataset, all the keys which we want to delete will be duplicates. So we use the SELECT operator with NODUPS option to eliminate all the records to be deleted. Note that the out vsam dataset is same as the input dataset. You can use the same input vsam file as output vsam file when it is defined with REUSE option.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Thu Mar 25, 2004 5:20 pm Post subject:
Sumathi,
You are getting that error because the file is not 'initialized'. That is becuase the cluster is created and it is empty .You need to initialize a newly defined vsam file before manipulating it.
But sort can handle empty vsam files also.The parm VSAMEMT will allow you to process even if it is empty. So add dd statement to your first insert step
Hi Kolusu,
Yes. It helped lot, both Insert and Delete working now. But Update is not. It looks like that SUM FIELDS=NONE is working on the other way. Is that necessary to mention LAST(DUPS) or FIRST(DUPS).
Thanks, Sumathi
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Thu Mar 25, 2004 6:27 pm Post subject:
Sumathi,
Did you follow this rule mentioned in the update solution?
Quote:
But the only difference is that we make update records file to be in the first concatenation list. so using EQUALS option and eliminating the duplicates using sum fields=none, we can update the desired keys.
Your key is 14 bytes in length , so your sort fields should be 1,14,ch,a ? Did you make that change?
When you say that solution does not work, you need to post more details such as error messages and sample input and desired output
Hi Kolusu,
Earlier it was not given any errors. The job went through fine. But the result was not what expected. I am using the correct sort fields 1,14,ch,a.
As you mentioned in your quote, I have interchanged the files and found its working now correctly.
I tried to implement the above exercise using idcams and sort. Find below the jcl, which can be used for both insert and updation. Please have a look and comment for any changes.
I have a question as i want to delete the records in an existing KSDS cluster , the solution provided by you for deletion i am not quite clear as want u mean for //CON DD DSN=YOUR VSAM DELETE REC FILE, can you help me i want to delete the records from an existing dataset and lod the records from one more new dataset as initially went i loaded the records i missed out to keep one field blanks.
Code:
DELETE solution:
We first copy contents of the vsam file to a temp dataset. Now we concatenate this temp dataset along with the records to be deleted and load back to the original file.when we concate the records to be deleted file with the temp dataset, all the keys which we want to delete will be duplicates. So we use the SELECT operator with NODUPS option to eliminate all the records to be deleted. Note that the out vsam dataset is same as the input dataset. You can use the same input vsam file as output vsam file when it is defined with REUSE option.
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