View previous topic :: View next topic
|
Author |
Message |
sarath16581
New User
Joined: 11 Jun 2005 Posts: 8
|
|
|
|
Hi Everyone,
I have come across a requirement where in i have to call a sub program from the main program. There is an input file in the main program and the file is read in the main program. By the way the file is sequential. After i called the subprogram i realised there is a need to read the input file in the called program. Is there a way i can accomplish this? I know that i can have the read part in the main program and perform the remaining functionality in called program. But i want to know if there is way using which i can read the file in called program? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
This should be moved to applications. Is this a COBOL program?
this topic has nothing to do with DB2. Depending on the COBOL, you can look at external. or redesign.......... |
|
Back to top |
|
|
ykishor Currently Banned New User
Joined: 11 Aug 2007 Posts: 24 Location: my pc
|
|
|
|
Quote: |
But i want to know if there is way using which i can read the file in called program? |
Files can't be shared by calling and the called programs.
If the same file is to be used by both the programs then it must be closed by the calling program before it can be opened by the called program and vice-versa |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
ykishor: if this is a COBOL program, your statement is wrong. Check out the manuals link at the top of the page and use the COBOL manuals to check out the GLOBAL and EXTERNAL attributes, which allow files to be used between programs and subprograms. |
|
Back to top |
|
|
ykishor Currently Banned New User
Joined: 11 Aug 2007 Posts: 24 Location: my pc
|
|
|
|
yes robert
u r absoulutely correct....I posted this one in the context of the question..
Quote: |
There is an input file in the main program and the file is read in the main program. |
This is because the storage associated with an EXTERNAL object is not a part of any particular program in the run unit...Rather the EXTERNAL storage item is associated with run unit itself...The run ubit in that case has seperate storage for all the programs...Here that was not the case...
guess I should have been more specific.... for putting things in perspective.... Am I correct now |
|
Back to top |
|
|
ykishor Currently Banned New User
Joined: 11 Aug 2007 Posts: 24 Location: my pc
|
|
|
|
Quote: |
If the same file is to be used by both the programs then it must be closed by the calling program before it can be opened by the called program and vice-versa |
This not wrong either as claimed by u .This technique serves as a means of data linkage,but in a totally different form from the use of arguments... by the way thanks for showing me the doors of IBM Manuals...
Good Day |
|
Back to top |
|
|
|