Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Hi..DISP=OLD in VSAM file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
vab987

New User


Joined: 01 Dec 2006
Posts: 29
Location: S.A

PostPosted: Wed Nov 05, 2008 2:39 pm    Post subject: Hi..DISP=OLD in VSAM file
Reply with quote

Hi ,

I have a VSAM file and the requirement is that before the file is written with new data , all the previous data should be deteled.

So, I am writing DISP=OLD so that the old data is deleted and the new one be written , something like this :

DD02 DD DSN=CMRA.FRMTD.ACNTSORT.VS,DISP=OLD

The above is giving error stating "duplicate records" as the old data was not deleted.

Can someone guide why it is not working in VSAM file . As far as I know in Sequential files , DISP=OLD makes it sure that the old data be deleted.

Regards,
Vaibhav
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Nov 05, 2008 2:46 pm    Post subject:
Reply with quote

Hello,

What you know is flawed a couple of places. . .

Quote:
DISP=OLD makes it sure that the old data be deleted.
Not true. disp=old makes sure the file already exists and restricts usage to the job that specified disp=old. If some other job tried to read the file at the same time, the request for the file would be rejected.

You do not delete vsam files thru jcl alone. Typically an idcams delete/define is used to completely empty a vsam file and initialize it for the next use.

You can use the define that was used to create the file in the first place. You would add a delete to be rune before the define.
Back to top
View user's profile Send private message
sachin_kaushik84

New User


Joined: 03 Oct 2008
Posts: 23
Location: noida

PostPosted: Wed Nov 05, 2008 3:01 pm    Post subject: DISP=OLD makes it sure that the old data be deleted.
Reply with quote

Hello dick,
I totally agree with ur point.But one thing that i would ask you that i believe the logic that vaibhav is using in his program is might be wrong. if we want to write a file that already have a records in it than we have to open it in I/O mode with rewrite command.
Pls suggest if i am in wrong direction.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Wed Nov 05, 2008 3:14 pm    Post subject: Reply to: Hi..DISP=OLD in VSAM file
Reply with quote

Quote:
requirement is that before the file is written with new data , all the previous data should be deteled.

Your approach might work if the old data had to be kept...

or if the vsam dataset was defined with the reuse option
and the open was for output( like an initial load )
dangerous approach that must be carefully evaluated

and now back to the original post....

if the proper permissions are in place the fastest would be a vsam delete/define

but if there are constraints ( update only permission ) then the only way would be to use a program ( pay for or freeware ) to reset the vsam to the empty status,
if the dataset is big it might take some time
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Nov 05, 2008 3:47 pm    Post subject:
Reply with quote

DELETE / DEFINE is the safest and surest method.

I have seen some guy develop a program to go through a KSDS and delete every record, one by one. Took over an hour and a half. The reason - he could not find the cards to do a DELETE / DEFINE icon_rolleyes.gif

Ho hum - took me 10 minutes to build the define statements from a listcat.
Back to top
View user's profile Send private message
vab987

New User


Joined: 01 Dec 2006
Posts: 29
Location: S.A

PostPosted: Wed Nov 05, 2008 6:30 pm    Post subject:
Reply with quote

Thanks Guys, I tried delete/define and it worked as expected.

Thanks a lot to all those who replied !
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Nov 05, 2008 9:15 pm    Post subject:
Reply with quote

Hello,

Quote:
if we want to write a file that already have a records in it than we have to open it in I/O mode with rewrite command
The requirement was not to write into a file that already has records. The requirement was to empty the file and write all new records.

If the requirement had been to modify existing and write new records into the file, yes open i-o would have been what to do.
Back to top
View user's profile Send private message
sachin_kaushik84

New User


Joined: 03 Oct 2008
Posts: 23
Location: noida

PostPosted: Thu Nov 06, 2008 12:58 pm    Post subject: The requirement was not to write into a file that already...
Reply with quote

Hi Dick,
i agree that the requirement was to empty the file and write all new records that is overwrite the contents of the file.

There are two ways to write on to a file
1) we first delete the entire fille records and then write onto it.
2)Or we rewrite on to the existing file records(which will automatically delete the previous contents).
now my question is
in the first case what u have suggested is perfect
however,in the second case is it possible to open the file in I/O mode and use REWRITE command (as REWRITE OUT-REC).
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Nov 06, 2008 1:06 pm    Post subject:
Reply with quote

Quote:
however,in the second case is it possible to open the file in I/O mode and use REWRITE command (as REWRITE OUT-REC).

Why would you want to. DELETE/DEFINE takes seconds - how long would this take with a file of 5+ million records ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Thu Nov 06, 2008 6:13 pm    Post subject:
Reply with quote

Quote:
There are two ways to write on to a file
1) we first delete the entire fille records and then write onto it.
2)Or we rewrite on to the existing file records(which will automatically delete the previous contents).
now my question is
in the first case what u have suggested is perfect
however,in the second case is it possible to open the file in I/O mode and use REWRITE command (as REWRITE OUT-REC).
These methods are not equivalent and are likely to give you very different results. If you do an IDCAMS DELETE/DEFINE on the file, it starts without any records in it. If you use REWRITE, all existing records will still be in the file -- so if your new input stream does not contain a matching key for every record in the file, you will not be rewriting every record, just the ones that are in the new file.

Furthermore, rewriting the record requires you to READ the record first -- and if your program doesn't get rid of all the old data explicitly, any old data left in the record area will be rewritten as if it were new data.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Nov 07, 2008 12:45 am    Post subject:
Reply with quote

Hello,

Quote:
Or we rewrite on to the existing file records(which will automatically delete the previous contents)
Actually, no it will not. . . It will only "delete" the contents of existing records that match the input file. As Robert mentioned, old data could be left in the file causing considerable confusion as well as wrong results.

To meet the original request, the delete/define followed by loading the full set of needed data is the best way to go for both performance reasons as well as logistics (much less likely to introduce some data integrity problem with a full load).
Back to top
View user's profile Send private message
sachin_kaushik84

New User


Joined: 03 Oct 2008
Posts: 23
Location: noida

PostPosted: Mon Nov 10, 2008 2:51 pm    Post subject:
Reply with quote

Thanks Guys, for ur presious time..........
IThanks a lot to all those who replied !
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am
No new posts Occurrence of various strings within ... TS70363 JCL & VSAM 1 Thu Apr 27, 2017 8:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us