Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Opening and Closing of files in invoked cobol programs?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Opening and Closing of files in invoked cobol programs?
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

Active Member


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

PostPosted: Fri May 11, 2007 7:44 pm    Post subject:
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

Site Director


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

PostPosted: Fri May 11, 2007 9:16 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Fri May 11, 2007 9:39 pm    Post subject: Re: Opening and Closing of files in invoked cobol programs?
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    Post subject:
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

Site Director


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

PostPosted: Sat May 12, 2007 2:59 pm    Post subject:
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: 686
Location: Earth

PostPosted: Tue Jun 12, 2007 3:06 pm    Post subject:
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: 147
Location: Columbia, MO

PostPosted: Tue Jun 12, 2007 9:24 pm    Post subject: Re: Opening and Closing of files in invoked cobol programs?
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

Site Director


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

PostPosted: Tue Jun 12, 2007 9:51 pm    Post subject:
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: 686
Location: Earth

PostPosted: Tue Jun 12, 2007 10:01 pm    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Tue Jun 12, 2007 11:21 pm    Post subject:
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: 205
Location: Bangalore

PostPosted: Wed Jun 13, 2007 4:09 pm    Post subject: Re: Opening and Closing of files in invoked cobol programs?
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    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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm
No new posts pointers on using USS and C programs. Pedro All Other Mainframe Topics 0 Wed Oct 04, 2017 4:38 am
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us