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 RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts Changing of LRECL of a file abdulrafi DFSORT/ICETOOL 2 Fri Mar 24, 2017 3:25 pm
No new posts splitting a file abdulrafi DFSORT/ICETOOL 4 Fri Mar 24, 2017 11:51 am
No new posts Record Not found in AlX but record re... mukun264 COBOL Programming 7 Fri Mar 24, 2017 9:28 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm


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