View previous topic :: View next topic
|
Author |
Message |
Shanu.sukoor
New User
Joined: 31 Jan 2006 Posts: 32 Location: India
|
|
|
|
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 |
|
|
Aji
New User
Joined: 03 Feb 2006 Posts: 53 Location: Mumbai
|
|
|
|
Hi
Open i-o data-file.
if file-status not = 00
open output data-file
end-if.
Aji cherian |
|
Back to top |
|
|
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
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 |
|
|
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
muthuvel wrote: |
Please ignore my previous post and logic. |
I thought the previous made more sense than this one... |
|
Back to top |
|
|
muthuvel
Active User
Joined: 29 Nov 2005 Posts: 217 Location: Canada
|
|
|
|
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. |
|
Back to top |
|
|
|