Containing programs



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Containing programs

Postby Alison Oliveira » Fri Feb 17, 2012 10:28 pm

Containing programs is the same as programs that contains sub-programs or procedures???
Alison Oliveira
 
Posts: 37
Joined: Fri Jan 20, 2012 9:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Containing programs

 

Re: Containing programs

Postby Robert Sample » Fri Feb 17, 2012 10:35 pm

What is the context of your usage? I've never heard of using "containing program" for a main or calling program -- but then, I've only been working with COBOL and mainframes for over 35 years so far.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Containing programs

Postby Alison Oliveira » Fri Feb 17, 2012 10:41 pm

I read in a manual... :
"Use the COMMOM attribute on the PROGRAM-ID clause to specify that your program can be called by the containing program or by any program or by any program in the containing program..."

I am talking about this "containing program"...
Thanks for help!
Alison Oliveira
 
Posts: 37
Joined: Fri Jan 20, 2012 9:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Containing programs

Postby Akatsukami » Fri Feb 17, 2012 11:03 pm

IIRC, this is ANSI-85 COBOL. A containing program would have a contained (the more common term is "nested") program before its END PROGRAM statement.

(ETA: I think that this feature is strictly for CICS, but not being a CICS programmer I'm not certain.)
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Containing programs

Postby Robert Sample » Fri Feb 17, 2012 11:07 pm

Containing programs have nested programs. A nested program is a subprogram, but not all subprograms are nested. A subprogram source can be completely independent of the calling program. In fact, the calling program can call the subprogram dynamically, so the subprogram may not even be in the same load library as the calling program.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Containing programs

Postby Monitor » Sun Feb 19, 2012 9:27 pm

This is correct : Cobol -85.
This is not correct: for CICS only, as it is COBOL STANDARD, it is valid for all programs.
Nested programs is a way of structuring a program in different programs instead of having paragraphs. A mixture is probably most common.
Nested programs makes it possible to have separate Working-Storage Sections for each program, thus (1) hiding/protections data and (2) no need for unique names, each contained program is a comletely separate program. You may call the nested programs with parameters, as always, which you cant when using paragraphs, BUT you can also expose variables from the outer program, My-Program, so they are available in the other, contained, programs, by marking the 01 or 77 level as GLOBAL.

A small example, but more details to read in the manual of course!

Id Division.
Program-Id. My-Program.
Working-Storage Section
77 My-Global-Data Pic xxxx  GLOBAL.
01 Param1.
   . . .
Procedure Division
    . . .
    Call 'My-Nested-Program1' Using Param1
    Call 'My-Common-Program'
* This call is valid only if the called program has the COMMON attribute
* as it is not a direct contained program. It is contained in the
* My-Nested-Program1
    . . .
    GoBack
.
Id Division.
Program-Id. My-Nested-Program1.
Working-Storage Section
Linkage Section.
01 Param1.
   . . .
Procedure Division Using Param1.
    . . .
* No declaration needed here
    If My-Global-Data......
    Call 'My-Common-Program' 
* This call would have been valid without the COMMON attribute, since it is a direct contained program.
    . . .
    GoBack
.
Id Division.
Program-Id. My-Common-Program Is COMMON.
Working-Storage Section
. . .

   . . .
Procedure Division
    . . .
    . . .
   
    . . .
    GoBack
End Program My-Common-Program.
End Program My Nested-Program1.
End Program My-Program.
Monitor
 
Posts: 98
Joined: Wed Jan 18, 2012 8:59 pm
Has thanked: 0 time
Been thanked: 7 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post