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
 

 

Rewrite commad on sequential file
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Rajkumar_n

New User


Joined: 07 Dec 2006
Posts: 51
Location: Bloomington

PostPosted: Fri Sep 21, 2007 2:11 am    Post subject: Rewrite commad on sequential file
Reply with quote

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
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Sep 21, 2007 2:37 am    Post subject:
Reply with quote

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
View user's profile Send private message
Rajkumar_n

New User


Joined: 07 Dec 2006
Posts: 51
Location: Bloomington

PostPosted: Fri Sep 21, 2007 3:03 am    Post subject: Reply to: Rewrite Command
Reply with quote

Thanks a lot. Let me try writing a simple sample program.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Fri Sep 21, 2007 3:06 am    Post subject:
Reply with quote

That's how "real" programmers do it.... icon_lol.gif
Back to top
View user's profile Send private message
balakrishna reddy

Active User


Joined: 13 Jul 2007
Posts: 130
Location: Guntur

PostPosted: Fri Sep 21, 2007 12:47 pm    Post subject:
Reply with quote

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
View user's profile Send private message
saptagiri kintali

New User


Joined: 21 Sep 2007
Posts: 20
Location: chennai

PostPosted: Mon Sep 24, 2007 4:45 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Rajkumar_n

New User


Joined: 07 Dec 2006
Posts: 51
Location: Bloomington

PostPosted: Fri Sep 28, 2007 11:50 pm    Post subject: Rewrite on a sequential file
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Fri Sep 28, 2007 11:59 pm    Post subject:
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 12:03 am    Post subject: Re: Rewrite on a sequential file
Reply with quote

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
View user's profile Send private message
Rajkumar_n

New User


Joined: 07 Dec 2006
Posts: 51
Location: Bloomington

PostPosted: Sat Sep 29, 2007 12:57 am    Post subject: Rewrite commad on sequential file
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sat Sep 29, 2007 1:00 am    Post subject:
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 1:02 am    Post subject:
Reply with quote

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
View user's profile Send private message
Rajkumar_n

New User


Joined: 07 Dec 2006
Posts: 51
Location: Bloomington

PostPosted: Sat Sep 29, 2007 1:48 am    Post subject: Rewrite commad on sequential file
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 2:02 am    Post subject:
Reply with quote

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
View user's profile Send private message
Rajkumar_n

New User


Joined: 07 Dec 2006
Posts: 51
Location: Bloomington

PostPosted: Sat Sep 29, 2007 9:54 am    Post subject: Rewrite commad on sequential file
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Sat Sep 29, 2007 2:53 pm    Post subject:
Reply with quote

Put a display of the file status after the open, close, read and rewrite for the file like:
DISPLAY 'OPEN ' status
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: Sat Sep 29, 2007 8:33 pm    Post subject:
Reply with quote

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
View user's profile Send private message
anv2005

New User


Joined: 14 Jul 2005
Posts: 44
Location: US

PostPosted: Thu Oct 04, 2007 12:54 am    Post subject:
Reply with quote

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
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Thu Oct 04, 2007 10:21 am    Post subject:
Reply with quote

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
View user's profile Send private message
Rajkumar_n

New User


Joined: 07 Dec 2006
Posts: 51
Location: Bloomington

PostPosted: Thu Oct 04, 2007 8:21 pm    Post subject: Reply to: Rewrite commad on sequential file
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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