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

Opening and Closing of files in invoked cobol programs?


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

New User


Joined: 11 May 2007
Posts: 2
Location: Mumbai

PostPosted: Fri May 11, 2007 7:37 pm
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri May 11, 2007 7:44 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri May 11, 2007 9:16 pm
Reply with quote

Hello,

Just curious - what is the reason to close it in program2?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri May 11, 2007 9:39 pm
Reply with quote

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
View user's profile Send private message
eparkar

New User


Joined: 11 May 2007
Posts: 2
Location: Mumbai

PostPosted: Sat May 12, 2007 12:19 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat May 12, 2007 2:59 pm
Reply with quote

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")icon_confused.gif

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Jun 12, 2007 3:06 pm
Reply with quote

Dear all,
Please see the link below, it is about external files. It says, file opened in one program can be closed in another!
so thought of sharing with you guys-
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/handheld/Connected/BOOKS/igy3pg20/4.2.6.1?SHELF=&DT=20040220035836&CASE=
Back to top
View user's profile Send private message
socker_dad

Active User


Joined: 05 Dec 2006
Posts: 177
Location: Seattle, WA

PostPosted: Tue Jun 12, 2007 9:24 pm
Reply with quote

As Dr. Malcom would say....

Just because you CAN do a thing, doesn't mean you SHOULD. icon_cry.gif

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! icon_biggrin.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jun 12, 2007 9:51 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Tue Jun 12, 2007 10:01 pm
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Tue Jun 12, 2007 11:21 pm
Reply with quote

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
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 206
Location: Bangalore

PostPosted: Wed Jun 13, 2007 4:09 pm
Reply with quote

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
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 Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top