IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Hi..DISP=OLD in VSAM file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Wed Nov 05, 2008 2:46 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Wed Nov 05, 2008 3:14 pm
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: 8796
Location: Welsh Wales

PostPosted: Wed Nov 05, 2008 3:47 pm
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
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

Moderator Emeritus


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

PostPosted: Wed Nov 05, 2008 9:15 pm
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
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: 8796
Location: Welsh Wales

PostPosted: Thu Nov 06, 2008 1:06 pm
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: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Nov 06, 2008 6:13 pm
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

Moderator Emeritus


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

PostPosted: Fri Nov 07, 2008 12:45 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts how to eliminate null indicator value... DB2 7
No new posts VSAM LISTCAT INFORMATION JCL & VSAM 2
No new posts Format Binary file to EBCDIC JCL & VSAM 4
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
Search our Forums:

Back to Top