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

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


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 3156
Location: Tucson AZ

PostPosted: Wed Apr 04, 2007 5:25 am
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
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: 1436
Location: Bangalore,India

PostPosted: Wed Apr 04, 2007 11:33 am
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
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: 691
Location: Earth

PostPosted: Wed Apr 04, 2007 12:33 pm
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: 1436
Location: Bangalore,India

PostPosted: Wed Apr 04, 2007 12:55 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 4
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top