View previous topic :: View next topic
|
Author |
Message |
Rajkumar_n
New User
Joined: 07 Dec 2006 Posts: 51 Location: Bloomington
|
|
|
|
Hi,
Could any one please let me know if we can use rewrite commad on sequential file. I am in to a situation where I need to use a sequential file in several programs and keep it in sync with changes.
Is it possible if I open the file in I-O mode and by declaring the copy book lay out in working-storage section, later rewrite the record from working storage record lay out.
This is may be a silly question but I never used rewrite command on a sequential file.
Please provide me if any one have example programs.
Thanks and Regards,
Rajkumar Nerella |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
You have looked at REWRITE in the manual, right?
It looks to me that it can do what you want....
Every time I've faced a situation that I have not yet faced, I try, small test code to "prove" if it is possible or not.....
Go for it...... |
|
Back to top |
|
|
Rajkumar_n
New User
Joined: 07 Dec 2006 Posts: 51 Location: Bloomington
|
|
|
|
Thanks a lot. Let me try writing a simple sample program. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
That's how "real" programmers do it.... |
|
Back to top |
|
|
balakrishna reddy
Active User
Joined: 13 Jul 2007 Posts: 128 Location: Guntur
|
|
|
|
Hi Rajkumar,
I have worked on the same type of requirement, You can open that sequential file in i-o mode and if you want to update the file then use rewrite command to do it.
Quote: |
Is it possible if I open the file in I-O mode and by declaring the copy book lay out in working-storage section, later rewrite the record from working storage record lay out.
|
You cannot use the same layout for both working-storage section and the file section. You have to change the variable names.
Please correct me if i am wrong. |
|
Back to top |
|
|
saptagiri kintali
New User
Joined: 21 Sep 2007 Posts: 20 Location: chennai
|
|
|
|
we can update a sequential file but it should contain same length. no changes in length of corresponding rec will not allow. |
|
Back to top |
|
|
Rajkumar_n
New User
Joined: 07 Dec 2006 Posts: 51 Location: Bloomington
|
|
|
|
Hi,
I tried to use rewrite command on a sequential file. I am in to a situations where I need to keep updating a sequential file in two programs.
The program is issuing a file-status of 48 even after opening file in I-O mode.
Could any one please let me know the solution for this incident.
This post is in reference with my previous post about Rewrite comman.
Thanks and Regards,
Rajkumar Nerella |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I am in to a situations where I need to keep updating a sequential file in two programs. |
Are these 2 programs running at the same time? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Rajkumar_n wrote: |
The program is issuing a file-status of 48 even after opening file in I-O mode. |
Two things....
What is in the additional six bytes of file status (always a very good way to get to the bottom of VSAM problems)?
File status 48 says you don't have it opened in I-O mode.....
Maybe the addtitonal three fields will point out the problem....
Maybe you had better prove to your self that the file is opened in I-O mode, a display of all four status fields right after the open could do that..... |
|
Back to top |
|
|
Rajkumar_n
New User
Joined: 07 Dec 2006 Posts: 51 Location: Bloomington
|
|
|
|
Hi,
Thanks for all your quick repsonse. I opened the sequential file in I-O mode. My requirement is as shown below.
I have three files
File-A is Input file, File-B is I/O file(VSAM File, File-C is I/O file which is a flat file.
Logic is : Read input file match the record with VSAM AND Flat file
If it is found in VSAM or extract file then rewrite the VSAM record and rewrite the same record in Extract file
If it is not found in VSAM file but not found in extract file then populate date from VSAM file and write the extract record.
Thanks and Regards,
Rajkumar Nerella |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Ok, we understand the task at hand. . .
Please review the last few replies and answer the questions asked or follow the suggestions made and post the results.
It will also help if you mention which file(s) get(s) the file status 48. . . |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
File status 48 says you don't have it opened in I-O mode.....
What is in the additional six bytes of file status (always a very good way to get to the bottom of VSAM problems)? |
|
Back to top |
|
|
Rajkumar_n
New User
Joined: 07 Dec 2006 Posts: 51 Location: Bloomington
|
|
|
|
Hi,
I am not getting this error for VSAM. I am getting this error for Sequential file.
I am not sure if I need to declare file status with 8 bytes of length. I declared it as PIC X(02).
Please assist me.
Thanks and Regards,
Rajkumar Nerella |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Well, then if it isn't VSAM, don't worry....
File status 48 says you don't have it opened in I-O mode.....
Maybe you had better prove to your self that the file is opened in I-O mode, a display of the status field right after the open could do that..... |
|
Back to top |
|
|
Rajkumar_n
New User
Joined: 07 Dec 2006 Posts: 51 Location: Bloomington
|
|
|
|
Hi,
How can I prove that I opened the file in I-O mode. I can prpvide copy of my program. Please let me know if it is possible to assist me where I am going wrong.
Please let me know your mail-id so that I can send the attachment.
I am getting file status 48 on sequential file. But the job is not abending but it is not wrting files to output
Thanks and Regards,
Rajkumar Nerella |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Put a display of the file status after the open, close, read and rewrite for the file like:
DISPLAY 'OPEN ' status |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I am getting file status 48 on sequential file. But the job is not abending but it is not wrting files to output |
You do not get an abend because you handled the error in your program. If you did not specify where to put FILE STATUS, the code would have abended.
You can copy/paste from youjr source into youjr reply here. Several of the people who reply to questions are not permitted to download attachments so placing the info "inline" usually works better.
When you put code or jcl in a post, it is best to use the "Code" tab near the top ofthe reply panel. This makes your post more readable and preserves alighment. When yoj have entgered a bit of code, click "Preview" to see how yojr post will appear to the forum. When you are satisfied with yojr post, click "Submit". |
|
Back to top |
|
|
anv2005
New User
Joined: 14 Jul 2005 Posts: 44 Location: US
|
|
|
|
Make sure to use the COBOL statement REWRITE instead of WRITE when the sequential file is opened for I-O.
The COBOL statement WRITE results in file status 48 even when the file is opened for I-O.
Regards,
Alex. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
Alex,
Quote: |
Make sure to use the COBOL statement REWRITE instead of WRITE when the sequential file is opened for I-O. |
How do you write a new record into the file when opened in I-O mode.
Quote: |
The COBOL statement WRITE results in file status 48 even when the file is opened for I-O. |
Are you sure about this? |
|
Back to top |
|
|
Rajkumar_n
New User
Joined: 07 Dec 2006 Posts: 51 Location: Bloomington
|
|
|
|
Hi,
Finally I came to know that "WRITE" command and 'REWRITE" command can not be used in the same program. So I switched from sequential file to VSAM file.
But still some where in mind, it is saying we can achived this by using multiple open statements and close statement.
Like
If you want to rewrite the record then open the file in I-O mode and after rewriting close the file.
When you want write a new record open the file in extend mode and close the file after writing the record.
Can any one throw me some light whether this will work.
Thanks and Regards,
Rajkumar Nerella |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Good design will not have the code opening and closing the file repeatedly.
Is there some reason that the original sequential file cannot be read and a new output file created. If i understand what you want to do (and i may not), you could "change the record read and write the modified record in the new file. If new records need to be written, just write them.
If you show some sample inpujt and what you need for output, we can better offer suggestions. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Rajkumar,
Two things haven't been mentioned yet:
You can't REWRITE a tape record.
You can REWRITE a disk rec, but you can't WRITE (insert) a rec into the middle of a file (e.g. between recs 5 ans 6). You can add them to the end of a disk file.
Does either of these apply to what you're trying? |
|
Back to top |
|
|
Rajkumar_n
New User
Joined: 07 Dec 2006 Posts: 51 Location: Bloomington
|
|
|
|
dick scherrer,
I accept with your comment. But in my requirement I need to process the same sequential file through 4 programs.
If I have to create new file in each and every step the process is going to be big.
Thanks and Regards,
Rajkumar Nerella |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Depends on how you define "big". The jcl to create the output file (rather than re-write) would be one dd statement "bigger". . .
Without doing any testing, i'd say that reading the file and creating a "new" output will perform as well (probably better) than opening and closing the file repeatedly. Opens and closes require much more system sork than a read or a write.
If you want to do a little test, you might create some test code that in one case opens a file reads a record and closes the file 10000 times. Then do the same thing, but only open the file one time, read 10000 records, and close the file. The difference should demonstrate what i've mentioned. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Hi!
I would like to make a further comment
REWRITE IS DANGEROUS - a la James Bond .. VERY DANGEROUS
in case of program failures/abends/reruns(for_any_reason)
You cannot simply rerun the failing program
but You have to restore the sequential dataset to the initial state,
so...
You need to have an additional step to take a backup before each REWRITING program
and a restore step before the rerun
I would say that having two files is cheaper ( overall cost )
also an additional comment
the REWRITE technique must ( given the aforesaid consideration )
repeat must be approved usually at a high level
regards
e.s |
|
Back to top |
|
|
|