MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VSAM - Record manipulations

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Data Management
View previous topic :: View next topic  
Author Message
Sumathi
Beginner


Joined: 24 Mar 2004
Posts: 13
Topics: 3

PostPosted: Wed Mar 24, 2004 6:11 pm    Post subject: VSAM - Record manipulations Reply with quote

Hi,

I need your help to find out the solution for the below. Before posting, I have searched in this forum, but I couldn't get exactly what I want.

The challenges are as follows:
Challenge 1: (Insert)
- Seq file having few records
- VSAM file has around 100 records

-- Seq file contents have to be inserted into VSAM file. Final output must be in the sorted order.

My idea : Do repro on VSAM into new seq file ; merge with input seq
file ; sort ; delete existing VSAM and recreate a new VSAM.

Is there any better idea?

Challenge 2:(Delete)
- Seq file having record keys
- VSAM file has around 100 records

-- Records have to be deleted from VSAM as per the keys found in Seq file
: I do not have any clear idea for this.

Challenge 3:(Update)
- Seq file having record keys and its descriptions
- VSAM file has around 100 records(having keys, descriptions and others)

-- The descriptions in VSAM file have to be replaced with the descriptions given in the seq file, using the keys given in the seq file.

I have to do this assignment using JCL only. Hence please provide me JCL solutions. Thanks in advance.

- Sumathi.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed Mar 24, 2004 9:26 pm    Post subject: Reply with quote

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.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sumathi
Beginner


Joined: 24 Mar 2004
Posts: 13
Topics: 3

PostPosted: Wed Mar 24, 2004 10:45 pm    Post subject: Reply with quote

Hi Kolusu,

I am sorry. I think I didn't made my sentence clearly. Using JCL means it includes all the possible utilities(idcams, sort and so on) as well.

In the mean time I could able to complete my first challenge(using sort and idcams). I have an idea for delete also. I have to try it out.

If you have any idea for delete and update, please let me know. (Thanks and Sorry - I have to do this assignment only by JCL)

Thanks, Sumathi
Back to top
View user's profile Send private message
Sumathi
Beginner


Joined: 24 Mar 2004
Posts: 13
Topics: 3

PostPosted: Thu Mar 25, 2004 12:08 am    Post subject: Reply with quote

Hi Kolusu and others,

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.

Thanks again, Sumathi
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Mar 25, 2004 9:52 am    Post subject: Reply with quote

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.

Code:

//*******************************************************************
//* THIS STEP WILL INSERT NEW RECORDS INTO AN EXISTING VSAM CLUSETER*
//*******************************************************************
//STEP0200 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,(1,1),RLSE)       
//CON      DD DSN=YOUR VSAM UPDATE REC FILE,                     
//            DISP=SHR                                           
//         DD DSN=&T1,DISP=OLD,VOL=REF=*.T1                     
//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,EQUALS                 
  SORT FIELDS=(1,9,CH,A)                     
  SUM FIELDS=NONE                             
/*                                           


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.

Code:

//******************************************************************
//* THIS STEP WILL DELETE RECORDS IN AN EXISTING VSAM CLUSTER      *
//******************************************************************
//STEP0300 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,(1,1),RLSE)       
//CON      DD DSN=YOUR VSAM DELETE REC FILE,                     
//            DISP=SHR                                           
//         DD DSN=&T1,DISP=OLD,VOL=REF=*.T1                     
//OUT      DD DSN=YOUR INPUT VSAM FILE,         
//            DISP=OLD                                   
//TOOLIN   DD *                   
  COPY FROM(VSAMIN) TO(T1)                         
  SELECT FROM(CON) TO(OUT) ON(1,9,CH) NODUPS       
//DFSPARM  DD *                                     
  OPTION VSAMIO,RESET                               
/*                                                 


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sumathi
Beginner


Joined: 24 Mar 2004
Posts: 13
Topics: 3

PostPosted: Thu Mar 25, 2004 4:43 pm    Post subject: Reply with quote

Great ! But when I try for Insert, it failed with RC 16

The error code is : VSAMIN VSAM OPEN ERROR -- A0
COMPLETION CODE - SYSTEM=000 USER=0016 REASON=00000000

VSAMFILE has been created with the following.
Code:

DEFINE CLUSTER -                                       
      (NAME(HLQ.VSAMFILE) -           
      REUSE -                                         
      KEYS(14 0) -                                     
      RECSZ(80 80) -                                   
      FSPC(0 0) -                                     
      VOL(*) -                                         
      SHR(2 3)) -                                     
    DATA -                                             
      (NAME (HLQ.VSAMFILE.DATA)      -
      CYL(5 1) -                                       
      CISZ(4096)) -                                   
    INDEX -                                           
       (NAME (HLQ.VSAMFILE.INDEX))     

Please let me know if you find anything wrong in the definition.
Thanks, Sumathi
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Mar 25, 2004 5:20 pm    Post subject: Reply with quote

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

Code:

//DFSPARM  DD *         
       VSAMEMT=YES             



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sumathi
Beginner


Joined: 24 Mar 2004
Posts: 13
Topics: 3

PostPosted: Thu Mar 25, 2004 6:16 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Mar 25, 2004 6:27 pm    Post subject: Reply with quote

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

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Sumathi
Beginner


Joined: 24 Mar 2004
Posts: 13
Topics: 3

PostPosted: Thu Mar 25, 2004 6:36 pm    Post subject: Reply with quote

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.

Thanks a lot for all your help. - Sumathi
Back to top
View user's profile Send private message
Sumathi
Beginner


Joined: 24 Mar 2004
Posts: 13
Topics: 3

PostPosted: Tue Mar 30, 2004 6:10 pm    Post subject: Reply with quote

Hi Kolusu and others,

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.

//*
//* REPRO THE VSAM FILE INTO SEQ FILE
//*
//S01 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//INDATA DD DSN=HLQ.INPUT.VSAMFILE,DISP=SHR
//OUTDATA DD DSN=&&VSAMOUT,DISP=(,PASS),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),
// SPACE=(TRK,(5,5),RLSE),UNIT=SYSPROD
//SYSIN DD *
REPRO INFILE(INDATA) -
OUTFILE(OUTDATA)
//*
//* SORT THE INPUT FILE ALONG WIHT VSAMOUT
//*
//S02 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=A
//SORTIN DD DSN=HLQ.INPUT.FILE,DISP=SHR
// DD DSN=&&VSAMOUT,DISP=(OLD,DELETE,DELETE)
//SORTOUT DD DSN=&&SORTOUT,DISP=(,PASS),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=0),
// SPACE=(TRK,(5,5),RLSE),UNIT=SYSPROD
//SYSIN DD *
SORT FIELDS=(1,14,CH,A),EQUALS
SUM FIELDS=NONE
//*
//* REPRO BACK TO VSAM
//*
//S03 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=A
//INDATA DD DSN=&&SORTOUT,DISP=(OLD,DELETE,DELETE)
//OUTDATA DD DSN=HLQ.INPUT.VSAMFILE,DISP=SHR
//SYSIN DD *
REPRO INFILE(INDATA) -
OUTFILE(OUTDATA) -
REPLACE
//*

Please let me know how to do it for delete(using only idcams and sort).

The inputs are,
VSAM File : (lrecl = 80, keys = 1 to 14)
Input File : (lrecl = 80, keys = 1 to 14)

VSAM File content :
AAAA BVT ASDFADSFDSFSADFDAF
BBBB BVT BSDFASFDFADSFASDFA
CCCC BVT DAFSDFSDFASDFASDF

INPUT FILE content:
BBBB BVT

Final result should be :

VSAM File Content :
AAAA BVT ASDFADSFDSFSADFDAF
CCCC BVT DAFSDFSDFASDFASDF

Thanks, Sumathi
Back to top
View user's profile Send private message
yadav2005
Intermediate


Joined: 10 Jan 2005
Posts: 348
Topics: 144

PostPosted: Mon Sep 24, 2007 7:30 am    Post subject: Reply with quote

Kolusu,

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.

Code:

//******************************************************************
//* THIS STEP WILL DELETE RECORDS IN AN EXISTING VSAM CLUSTER      *
//******************************************************************
//STEP0300 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,(1,1),RLSE)       
//CON      DD DSN=YOUR VSAM DELETE REC FILE,                     
//            DISP=SHR                                           
//         DD DSN=&T1,DISP=OLD,VOL=REF=*.T1                     
//OUT      DD DSN=YOUR INPUT VSAM FILE,         
//            DISP=OLD                                   
//TOOLIN   DD *                   
  COPY FROM(VSAMIN) TO(T1)                         
  SELECT FROM(CON) TO(OUT) ON(1,9,CH) NODUPS       
//DFSPARM  DD *                                     
  OPTION VSAMIO,RESET                               
/*                       
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Data Management All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group