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
 

 

In COBOL why use file name for READ and record for WRITE?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sreedharm
Warnings : 1

New User


Joined: 12 Mar 2007
Posts: 1
Location: NJ, US

PostPosted: Wed Apr 04, 2007 5:08 am    Post subject: In COBOL why use file name for READ and record for WRITE?
Reply with quote

icon_neutral.gif
Do we have concrete answer for this question?

In COBOL while reading from file we code READ <file name> where as while writing to file we code WRITE <record name>. What is the reason not to use 'file name' at the time of writing also?

Warning: Wrong Forum
Back to top
View user's profile Send private message

William Thompson

Global Moderator


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

PostPosted: Wed Apr 04, 2007 5:25 am    Post subject: Re: In COBOL why use file name for READ and record for WRITE
Reply with quote

sreedharm wrote:
Do we have concrete answer for this question?
In COBOL while reading from file we code READ <file name> where as while writing to file we code WRITE <record name>. What is the reason not to use 'file name' at the time of writing also?
Simple, a record on a file can have many layouts, especially variable files where not only the layouts might be different but the lengths too.
You READ filename and all the 01s are "available" to be the record definition.
You WRITE recordname primarily to let the output exactly what the record length is.
If this is not concrete enough, let us know and we will try again.
Back to top
View user's profile Send private message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Wed Apr 04, 2007 11:31 am    Post subject: Re: In COBOL why use file name for READ and record for WRITE
Reply with quote

sreedharm wrote:
icon_neutral.gif
Do we have concrete answer for this question?

In COBOL while reading from file we code READ <file name> where as while writing to file we code WRITE <record name>. What is the reason not to use 'file name' at the time of writing also?

Warning: Wrong Forum



WRITE statement occurs after READ statement only. So there is no need to again mention filename.
Back to top
View user's profile Send private message
murmohk1

Senior Member


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

PostPosted: Wed Apr 04, 2007 11:33 am    Post subject:
Reply with quote

Venu,

Quote:
WRITE statement occurs after READ statement only


Are you sure about this?
Back to top
View user's profile Send private message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Wed Apr 04, 2007 11:58 am    Post subject:
Reply with quote

murmohk1 wrote:
Venu,

Quote:
WRITE statement occurs after READ statement only


Are you sure about this?


Ya,

First we need to check the filename whether it contains records or not then only appropriate action should be taken.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Apr 04, 2007 12:33 pm    Post subject:
Reply with quote

Venu,
icon_surprised.gif You need to think much before you write this.
Quote:
WRITE statement occurs after READ statement only.

What if I open a file in OUTPUT mode and just WRITE number of records in to it? Think about it and let us know.
Back to top
View user's profile Send private message
murmohk1

Senior Member


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

PostPosted: Wed Apr 04, 2007 12:55 pm    Post subject:
Reply with quote

Venu,

Quote:
whether it contains records or not


What do you mean by this? Do you mean to say we cannot write records into an empty file? Please rethink twice before you post any reply.
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
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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm


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