IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can we use multiple program-id in a single COBOL program?


IBM Mainframe Forums -> COBOL Programming
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
sbprem1

New User


Joined: 05 Mar 2010
Posts: 5
Location: Chennai

PostPosted: Fri Mar 05, 2010 1:48 pm
Reply with quote

Please resolve this: Is it possible to use multiple PROGRAM-IDs in as single COBOL program?
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Mar 05, 2010 1:50 pm
Reply with quote

Well Prem, why dont you resolve it yourself?
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri Mar 05, 2010 2:07 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Mar 05, 2010 5:03 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Mar 05, 2010 5:06 pm
Reply with quote

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... icon_smile.gif
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Fri Mar 05, 2010 6:05 pm
Reply with quote

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
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Mar 05, 2010 6:07 pm
Reply with quote

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
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Mar 05, 2010 6:10 pm
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Fri Mar 05, 2010 6:19 pm
Reply with quote

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
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Fri Mar 05, 2010 6:29 pm
Reply with quote

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. icon_confused.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top