View previous topic :: View next topic
|
Author |
Message |
eparkar
New User
Joined: 11 May 2007 Posts: 2 Location: Mumbai
|
|
|
|
In a cobol program #1 I open a file and this program invokes another cobol program #2 and i want to close this file in program #2. So is this possible or not? |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Why not just try it, rather than trust the answer(s) of others? Seems simple enough to test in about 5 minutes. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Just curious - what is the reason to close it in program2? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
eparkar wrote: |
In a cobol program #1 I open a file and this program invokes another cobol program #2 and i want to close this file in program #2. So is this possible or not? |
How would you refer to it in program #2, by program #1's FD name? Do you think the compiler would allow you to refer to an unknown file name?
If you duplicated the select and FD in both programs, do you think you would have any luck closing a file that as far as program #2 was concerned, was never opened? |
|
Back to top |
|
|
eparkar
New User
Joined: 11 May 2007 Posts: 2 Location: Mumbai
|
|
|
|
hmmm.....in program #1 the last para invokes another program #2 and i want to close it then and there....the control wont tranfer back to the program #1. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
We understood what you want to do. . . But why?
What is the reason to not close it in program1 before invoking program2 (other than "i want to")
A couple of things to consider as you develop programs/systems:
1. there needs to be a business or technical reason for the approach.
2. "because i want to" is neither a business nor technical reason and is
.. seldom supported by software vendors or your management.
Is it possible that there are some considerations that you haven't included in your question?
If you post what you need to accomplish rather than how you want to do it, we can offer suggestions. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
Back to top |
|
|
socker_dad
Active User
Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
As Dr. Malcom would say....
Just because you CAN do a thing, doesn't mean you SHOULD.
Opening a file in one program, transferring control to a second and then closing the file in the second and terminating the process without returning to the first is simply bad design and poor programming technique.
Yes, it CAN be done; however doing so is extremely bad because it creates a maintenance nightmare for some poor on-call schmuck who is trying to figure out your "cute routine" at 3 AM morning something abends.
Good grief, Charlie Brown! Nothing is worse than debugging some hot shot's idea of "cool" coding techniques when you are brain dead to the world. Remember the acronym KISS: Keep It Simple, Silly! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Before i'd let anything like that get into production, someone would have to make a very strong case why such a convoluted approach would be acceptable.
Again, if you post what you want to accomplish, we may be able to offer a more reasonable approach. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
s_d,
I haven't really 'prescribed' anyone to practice such thing. I have said that 'it is possible'. If you see the replies above mine, you will notice that they sound saying otherwise. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Cute, I wonder if external data items (not files) is valid in CICS.....
As far as design goes, and convolutedness, I doesn't have to be....There might be very good reasons to spread file handling around to several different programs in a run unit - can't think of any yet, but there might be..... |
|
Back to top |
|
|
Ajay Baghel
Active User
Joined: 25 Apr 2007 Posts: 206 Location: Bangalore
|
|
|
|
Hi,
It can be done using GLOBAL or External keyword. But, GLOBAL is used in nested programs only.
When using External, we need to define FD statement and File status variable with External keyword in both the Main and subprogram.
Thanks,
Ajay |
|
Back to top |
|
|
|