Use the same input file in Sub program and main program.
Use the same input file in Sub program and main program.
Dear All,
I have one question. I want to use one input file in sub-program, this file is used in main program as well. How can I do that? Please help.
I have one question. I want to use one input file in sub-program, this file is used in main program as well. How can I do that? Please help.
Thanks,
Anil
Anil
- Robert Sample
- Global Moderator
- Posts: 1899
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Use the same input file in Sub program and main program.
Research the EXTERNAL clause in the Enterprise COBOL Language Reference manual (page 178 of the 6.2 version). This is not necessarily a wise thing to do.
Re: Use the same input file in Sub program and main program.
Read about EXTERNAL clause. Is not it for variables and not files?
Thanks,
Anil
Anil
- Robert Sample
- Global Moderator
- Posts: 1899
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Use the same input file in Sub program and main program.
Did you not read page 178+ of the 6.2 version of the manual? It says
So the manual EXPLICITLY tells you EXTERNAL is for files as well as variables. Depending upon the specifics of what you want to do, you may need GLOBAL as well, but you need to spend some time reading the Programming Guide manual to know which (or both) are better for your needs.EXTERNAL clause
The EXTERNAL clause specifies that a file connector is external, and permits communication between two programs by the sharing of files.
A file connector is external if the storage associated with that file is associated with the run unit rather than with any particular program within the run unit. An external file can be referenced by any program in the run unit that describes the file. References to an external file from different programs that use separate descriptions of the file are always to the same file. In a run unit, there is only one representative of an external file.
In the FILE SECTION, the EXTERNAL clause can be specified only in file description entries.
The records appearing in the file description entry need not have the same name in corresponding external file description entries. In addition, the number of such records need not be the same in corresponding file description entries.
Use of the EXTERNAL clause does not imply that the associated file-name is a global name. See Sharing data by using the EXTERNAL clause in the Enterprise COBOL Programming Guide for specific information about the use of the EXTERNAL clause.
Re: Use the same input file in Sub program and main program.
Thanks Robert.
So in CICS will all the files be defined as EXTERNAL as they are used by so many programs?
So in CICS will all the files be defined as EXTERNAL as they are used by so many programs?
Thanks,
Anil
Anil
Re: Use the same input file in Sub program and main program.
That is a new question - start a new topic but I suggest that you get familiar with the fundamentals of CICS before starting to ask such questions as that study will probably provide you with the answers that you are seeking.
Regards
Nic
Nic
- Robert Sample
- Global Moderator
- Posts: 1899
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Use the same input file in Sub program and main program.
Since you do not define any files in a COBOL program running under CICS, your question is pointless. CICS defines all files; the program defines none.
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