View previous topic :: View next topic
|
Author |
Message |
sbprem1
New User
Joined: 05 Mar 2010 Posts: 5 Location: Chennai
|
|
|
|
Please resolve this: Is it possible to use multiple PROGRAM-IDs in as single COBOL program? |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Well Prem, why dont you resolve it yourself? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
sbprem1 wrote: |
Please resolve this: Is it possible to use multiple PROGRAM-IDs in as single COBOL program? |
What?
Why?
Huh?
Say again?
Please explain? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
With IBM Enterprise COBOL for z/OS 3.4.1 you'll get a syntax-error, saying A duplicate "PROGRAM-ID" paragraph header was found.
Well, Manuals say - COBOL programs are divided into DIVISIONS and SECTIONS which, depending upon the specific DIVISION and SECTION and the requirements of the specific program, may be further divided into paragraphs. Each paragraph is preceded by a paragraph name which may appear only once in a given SECTION. In this case "PROGRAM-ID" appears more than once in the same SECTION. So the indicated duplicate paragraph name was ignored. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
But even if that was possible why would one like to call some program with two different names? Shakespers's famous quote does not fit well at all the places - COBOL just does not like duplicate names... |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Check the Cobol Reference Manual, Part 2. Cobol Source Unit Structure. That will answer your question, or at least give you the knowledge to place a more qualified question here.
Also, if you intend to have multiple entry points in your source module, you should reference the ENTRY statement in the same manual.
Lastly, do confirm your intentions with your installation or development support, as introducing multiple modules in the same source deck (pds-member) can cause conflict in some (most) source library systems. I think you should have an explicit architectural requirement to exploit these possibilities. |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
The answer to the original question is either YES or NO, depending on what is meant by the term "program". In a single program unit, the answer is NO, but in a "nested" program, the answer is YES. From the Enterprise COBOL Language Reference Manual (sic):
A COBOL program can contain other COBOL programs, which in turn can contain still other COBOL programs. These contained programs are called nested programs. Nested programs can be directly or indirectly contained in the containing program. Nested programs are not supported for programs compiled with the THREAD option. In the following code fragment, program Outer-program directly contains program Inner-1. Program Inner-1 directly contains program Inner-1a, and Outer-program indirectly contains Inner-1a:
Code: |
Id division.
Program-id. Outer-program.
Procedure division.
Call "Inner-1".
Stop run.
Id division.
Program-id. Inner-1
...
Call Inner-1a.
Stop run.
Id division.
Program-id. Inner-1a.
...
End Inner-1a.
End Inner-1.
End Outer-program. |
|
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
sbprem1 wrote: |
Please resolve this: Is it possible to use multiple PROGRAM-IDs in as single COBOL program? |
Am i missing something? Thought this site is to give help in solving others
problems they came across AFTER doing something.
The only thing i did see the TS DO is saying "please resolve this".
I almost got fooled by the word "please" |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Ronald Burr wrote: |
The answer to the original question is either YES or NO, depending on what is meant by the term "program". In a single program unit, the answer is NO, but in a "nested" program, the answer is YES. |
You can provide multiple entry points into a single program. Execution will start at the statement following the ENTRY statement.
This construct can be used to provide alternative linkage areas to a module, or it can be used to execute completely different paths in your module. The last option is not recommended (by me , at least). If you have different functionalities, make different modules! |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
PeterHolland wrote: |
sbprem1 wrote: |
Please resolve this: Is it possible to use multiple PROGRAM-IDs in as single COBOL program? |
Am i missing something? Thought this site is to give help in solving others
problems they came across AFTER doing something.
The only thing i did see the TS DO is saying "please resolve this".
I almost got fooled by the word "please" |
I think it is allright to seek the advice of the forum on one's intentions, only in this case the topic poster have offended the forum by putting a very general question that could easily be answered by COBOL manuals. |
|
Back to top |
|
|
|