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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Open an empty file in I-O mode it will throw error
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    Post subject:
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: Chennai

PostPosted: Wed Feb 07, 2007 2:28 pm    Post subject: Re: Issue with empty input file
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: Chennai

PostPosted: Wed Feb 07, 2007 3:17 pm    Post subject: Re: Issue with empty input file
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: 3158
Location: Tucson AZ

PostPosted: Wed Feb 07, 2007 3:27 pm    Post subject: Re: Issue with empty input file
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: Chennai

PostPosted: Wed Feb 07, 2007 4:48 pm    Post subject: Re: Issue with empty input file
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    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 Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm
No new posts Need help with below DB2 error ashek15 DB2 3 Sat Mar 18, 2017 5:56 am
No new posts Updating a VSAM file with DISP=OLD sheersh JCL & VSAM 8 Tue Mar 14, 2017 6:14 pm


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