Use the same input file in Sub program and main program.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Anil
Registered Member
Posts: 70
Joined: Sun Jun 16, 2013 12:41 am

Use the same input file in Sub program and main program.

Post by Anil »

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.
Thanks,
Anil
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1885
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Use the same input file in Sub program and main program.

Post by Robert Sample »

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.
Anil
Registered Member
Posts: 70
Joined: Sun Jun 16, 2013 12:41 am

Re: Use the same input file in Sub program and main program.

Post by Anil »

Read about EXTERNAL clause. Is not it for variables and not files?
Thanks,
Anil
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1885
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Use the same input file in Sub program and main program.

Post by Robert Sample »

Did you not read page 178+ of the 6.2 version of the manual? It says
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.
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.
Anil
Registered Member
Posts: 70
Joined: Sun Jun 16, 2013 12:41 am

Re: Use the same input file in Sub program and main program.

Post by Anil »

Thanks Robert.

So in CICS will all the files be defined as EXTERNAL as they are used by so many programs?
Thanks,
Anil
nicc
Global Moderator
Global Moderator
Posts: 691
Joined: Wed Apr 23, 2014 8:45 pm

Re: Use the same input file in Sub program and main program.

Post by nicc »

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
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1885
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Use the same input file in Sub program and main program.

Post by Robert Sample »

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.
Anil
Registered Member
Posts: 70
Joined: Sun Jun 16, 2013 12:41 am

Re: Use the same input file in Sub program and main program.

Post by Anil »

Thanks Robert.
Thanks,
Anil
Post Reply

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

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”