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

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Previous topicNext topic

Topic Author
Anil
Registered Member
Posts: 58
Joined: Sun Jun 16, 2013 12:41 am
Zodiac: Sagittarius

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

Post by Anil » Mon Oct 16, 2017 12:55 pm

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: 1379
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

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

Post by Robert Sample » Mon Oct 16, 2017 6:27 pm

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.




Topic Author
Anil
Registered Member
Posts: 58
Joined: Sun Jun 16, 2013 12:41 am
Zodiac: Sagittarius

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

Post by Anil » Tue Oct 17, 2017 12:18 am

Read about EXTERNAL clause. Is not it for variables and not files?


Thanks,
Anil

User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1379
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

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

Post by Robert Sample » Tue Oct 17, 2017 12:58 am

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.




Topic Author
Anil
Registered Member
Posts: 58
Joined: Sun Jun 16, 2013 12:41 am
Zodiac: Sagittarius

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

Post by Anil » Sat Oct 28, 2017 5:57 pm

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: 597
Joined: Wed Apr 23, 2014 8:45 pm

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

Post by nicc » Sat Oct 28, 2017 6:50 pm

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: 1379
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

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

Post by Robert Sample » Sun Oct 29, 2017 8:19 am

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.




Topic Author
Anil
Registered Member
Posts: 58
Joined: Sun Jun 16, 2013 12:41 am
Zodiac: Sagittarius

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

Post by Anil » Fri Nov 03, 2017 11:51 am

Thanks Robert.


Thanks,
Anil

Previous topicNext topic

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