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

Open an empty file in I-O mode it will throw error


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Shanu.sukoor

New User


Joined: 31 Jan 2006
Posts: 32
Location: India

PostPosted: Wed Feb 07, 2007 1:37 pm
Reply with quote

Hi

I have a requirement as follows.

OPEN and READ an input file
IF the file is empty
write 5 lines and close the file.
IF file is not empty
read the file and update a particular line.


I think that if I open an empty file in I-O mode it will throw error. IDCAMS checking is not possible in this case due to a particular condition that is exixting in production.

How can I accomplish this req? Please help me. Sorry I do not have time to experiment.

Thanks in advance.
Back to top
View user's profile Send private message
Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Wed Feb 07, 2007 2:19 pm
Reply with quote

Hi

Open i-o data-file.
if file-status not = 00
open output data-file
end-if.

Aji cherian
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed Feb 07, 2007 2:28 pm
Reply with quote

Quote:
OPEN and READ an input file
IF the file is empty
write 5 lines and close the file.
IF file is not empty
read the file and update a particular line.


I think that if I open an empty file in I-O mode it will throw error


Yes,i think it will throw an error of file status '35'.So now you can process as per the below logic.

If file status=35
write 5 lines and close the file
If files status=00
process as per ur requirement.

correct me if i am wrong.
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed Feb 07, 2007 3:17 pm
Reply with quote

Please ignore my previous post and logic.I think this willl be useful

OPEN I-O file

Read File
increment a read counter
At end
if read counter = 0 (meaning the file is empty)
write 5 lines and close the file. (which is your requirement)
End-Read

(If the file is not empty ,the control will come here)
update a particular line which you reqire.

Correct me if i am wrong..
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 Feb 07, 2007 3:27 pm
Reply with quote

muthuvel wrote:
Please ignore my previous post and logic.
I thought the previous made more sense than this one... icon_confused.gif
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Canada

PostPosted: Wed Feb 07, 2007 4:48 pm
Reply with quote

Quote:
I thought the previous made more sense than this one...


I tried the first logic with the empty I-O file logic. I didnot get any error,the job ran fine .The thing is for the empty I-O file i didn't get the file status as '35' instead i got as '10' which means end-of-file.So i changed the way and also it is better to use a variable for the read-count since it is easy to track back if there is any issue. icon_razz.gif
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 0
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
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 HILITE on Browse mode? TSO/ISPF 2
Search our Forums:

Back to Top