Hi,
If program A CALLs B, is it possible a file "some-file" is opened in Program A and data is written in to B? And is it even a good design?
Thanks ,
Share a file between program and sub-program.
- Akshya Chopra
- Registered Member
- Posts: 77
- Joined: Mon May 20, 2013 11:32 pm
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Share a file between program and sub-program.
Forget the design for the moment
But what is the purpose and what is getting achieved?
But what is the purpose and what is getting achieved?
zprogrammer
- Robert Sample
- Global Moderator
- Posts: 1896
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Share a file between program and sub-program.
COBOL allows use of the EXTERNAL clause in the FD to permit files to be defined in one program and used in a subprogram.
However, in general this is a VERY BAD design to implement. It violates the principles of structured programming (particularly modular design), and ties the two programs together so much that what is then the point of having a subprogram? Maintenance becomes much tougher, since any file changes have to be reflected in BOTH programs instead of just one.
However, in general this is a VERY BAD design to implement. It violates the principles of structured programming (particularly modular design), and ties the two programs together so much that what is then the point of having a subprogram? Maintenance becomes much tougher, since any file changes have to be reflected in BOTH programs instead of just one.
- Akshya Chopra
- Registered Member
- Posts: 77
- Joined: Mon May 20, 2013 11:32 pm
Re: Share a file between program and sub-program.
Thanks Robert. I read about EXTERNAL clause and it gives hint to do what I was thiking like a "global" variable in language C. I'll work out on your advice.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Share a file between program and sub-program.
The advice was not to try to do it that way... yes? Good.
If you need to make file accesses from more than one program, put all the io for a file into one sub-program and use that, Use a parameter to indicate required function, a second one to indicate success/failure of IO (along with diagnostic information from FILE STATUS (and extended file status for VSAM( and a third one to indicate record-area.
If you need to make file accesses from more than one program, put all the io for a file into one sub-program and use that, Use a parameter to indicate required function, a second one to indicate success/failure of IO (along with diagnostic information from FILE STATUS (and extended file status for VSAM( and a third one to indicate record-area.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute