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

Indexed File Rewrite


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mariraj

New User


Joined: 09 Jul 2007
Posts: 59
Location: Chennai

PostPosted: Wed Dec 15, 2010 6:53 pm
Reply with quote

Can we rewrite an indexed file without a prior read. I believe we can do it when we open the file is accessed using RANDOM/DYNAMIC mode.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 15, 2010 7:02 pm
Reply with quote

From the COBOL Programming Guide manual, with emphasis added by me:
Quote:
1.10.3.6 Replacing records in a VSAM file

To replace a record in a VSAM file, use REWRITE on a file that you opened as I-O. If the file was not opened as I-O, the record is not rewritten and the status key is set to 49. Check the file status key after each REWRITE statement.

For sequential files, the length of the replacement record must be the same as the length of the original record. For indexed files or variable-length relative files, you can change the length of the record you replace.

To replace a record randomly or dynamically, you do not have to first READ the record. Instead, locate the record you want to replace as follows:

* For indexed files, move the record key to the RECORD KEY data item, and then issue the REWRITE.

* For relative files, move the relative record number to the RELATIVE KEY data item, and then issue the REWRITE.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Dec 15, 2010 7:42 pm
Reply with quote

How come you always know where to look in the Manual/s, Robert! ;)
Back to top
View user's profile Send private message
Mariraj

New User


Joined: 09 Jul 2007
Posts: 59
Location: Chennai

PostPosted: Wed Dec 15, 2010 7:49 pm
Reply with quote

Thanks Robert. It is good that he knows where to look in the manual icon_smile.gif. I looked into the cobol language reference before posting this query. But it wasn't as explicit as the above stated line.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 15, 2010 7:51 pm
Reply with quote

Anuj, I've had to look up a LOT over the years, so I've learned the manuals well. This is one of the better skills to develop -- I always tell people, I don't know everything, but I know where to find it! icon_biggrin.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Wed Dec 15, 2010 7:53 pm
Reply with quote

Mariraj P., the Language Reference guide has the syntax, whereas the Programming Guide tends to have the implementation details. This isn't a perfect split, though, so if you look in one manual and don't find what you're needing to know, look in the other one.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Dec 16, 2010 2:11 am
Reply with quote

But try to look up the syntax for COBOL reference modification if you don't know that's what it is called. I do not remember ":" being in the index.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Thu Dec 16, 2010 2:49 am
Reply with quote

FYI,
You can also find Reference Modification listed in the COBOL Language Reference Manual Index under it's CLIST/REXX nomenclature - i.e. SUBSTRing.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Dec 16, 2010 8:52 am
Reply with quote

Ronald - I never thought of that, as I knew "substr" was not the COBOL syntax.

I don't have a hardcopy anymore, but searching the manuals at the top - all 3 COBOL language refs - none has "substr" at the top-level (table of contents), but the Enterprise one does at least have "reference modification".

Its index, however, has "reference-modification" (with hyphen).

So, not particularly user friendly for this language element.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Thu Dec 16, 2010 9:12 am
Reply with quote

Phil,
My only reason for posting a response about "reference modification" was to show that "sometimes" alternative search criteria can actually lead to the topic someone is searching for. True, even when using a web search facility.
I myself have been known to do a (PDF) text search of an entire document when I "know" the "context" but not the actual, not so obvious, "tag" that was selected by the document's author for the TOC/index.
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top