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

Main Program or Sub program


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
hmurali
Warnings : 1

New User


Joined: 08 Mar 2005
Posts: 17

PostPosted: Tue Mar 11, 2008 11:20 am
Reply with quote

How do i identify if a particular program is a main program or a sub-program by just looking at the program.
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 355
Location: New York

PostPosted: Tue Mar 11, 2008 11:23 am
Reply with quote

see the Procedure division statement.
Back to top
View user's profile Send private message
hmurali
Warnings : 1

New User


Joined: 08 Mar 2005
Posts: 17

PostPosted: Tue Mar 11, 2008 11:24 am
Reply with quote

Could more details be provided...what do i need to look for in the procedure division..
Back to top
View user's profile Send private message
ashwinreddy

Active User


Joined: 16 Sep 2004
Posts: 106
Location: Hyderabad

PostPosted: Tue Mar 11, 2008 12:43 pm
Reply with quote

Hi,

If i see a Procedure division using phrase i would assume that it is called program and if not then it is calling program.

There are many others ways to differentiate

1) Linkage section in called program
2) Call in calling program


Please read the manual on the above link to be more comfortable.

Cheers
Ashwin
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Tue Mar 11, 2008 12:45 pm
Reply with quote

not too many options in PROCEDURE DIVISION... search in manual

publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/FRAMESET/igy3lr30
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Tue Mar 11, 2008 12:50 pm
Reply with quote

Hi,

Sub-module (called program) would have this statement:
Code:
PROCEDURE DIVISION USING Linkage-variables.
while main (calling) program will have just PROCEDURE DIVISION (unless it's again CALLed by some other program).


This topic is been discussed earlier as well, please search the forum on the keyowrd 'Linkage'. One such link is here for Your reference

www.ibmmainframes.com/viewtopic.php?t=6822&highlight=
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Tue Mar 11, 2008 5:18 pm
Reply with quote

LINKAGE is also used for getting EXEC card parms, which would not be considered a sub-program call.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 11, 2008 10:18 pm
Reply with quote

Hello,

Quote:
LINKAGE is also used for getting EXEC card parms, which would not be considered a sub-program call.
And the other side of the coin is that you might call a subprogram and pass no parameters. . . So, the "called" module might have no LINKAGE section or PROCEDURE DIVISION USING. . .
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Tue Mar 11, 2008 11:58 pm
Reply with quote

eh..so all the suggestions from me are ruled out... icon_smile.gif

I was too equiped with my one 'sub-module' while posting my previous post that I didn't think about Phrzby's point, but if this
Quote:
you might call a subprogram and pass no parameters
is there why should one CALL a sub-program?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 12, 2008 9:12 am
Reply with quote

Hello,

Quote:
point, but if this
Quote:

you might call a subprogram and pass no parameters
is there why should one CALL a sub-program?

Because of sub-processes that are self-contained (i.e. need no paramater data) that are invoked from a variety of "main" processes and the designers wanted to "share code" as much as possible rather than maintan muotiple versions of the code.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Wed Mar 12, 2008 10:52 am
Reply with quote

dick scherrer wrote:
Because of sub-processes that are self-contained (i.e. need no paramater data) that are invoked from a variety of "main" processes and the designers wanted to "share code" as much as possible rather than maintan muotiple versions of the code.
ok, got it. Then what should be suitable answer for the main question
Quote:
How do i identify if a particular program is a main program or a sub-program by just looking at the program.
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Wed Mar 12, 2008 12:50 pm
Reply with quote

Quote:
How do i identify if a particular program is a main program or a sub-program by just looking at the program?



In general:
in a batch program with linkage if the first field is the length... then I would assume it's a main program:

Code:
******************************************************************     
*                    LINKAGE SECTION                             *     
******************************************************************     
 LINKAGE SECTION.                                                       
*                                                                       
 01 REG-PARM.                                                           
    05 PARM-LONG                     PIC 9(02).                         
    ....


in other case, if a program has parameters I would assume it's a subprogram...of course, the exception could be that example of a subprogram with no parameters...
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Wed Mar 12, 2008 1:19 pm
Reply with quote

Just to add somemore confusion for the already exisiting one -

Why cant we look how the pgm is passing control back the program/os?
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Wed Mar 12, 2008 1:40 pm
Reply with quote

here ALL the Cobol programs ends with GOBACK.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Wed Mar 12, 2008 2:00 pm
Reply with quote

Hi,

You mean GO BACK for sub-program & STOP-RUN for main?

In my shop for a 'stand alone' program we use GO BACK only, so should I consider every such program a sub-program.. icon_confused.gif
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Wed Mar 12, 2008 2:03 pm
Reply with quote

Quote:
here ALL the Cobol programs ends with GOBACK.

Quote:
In my shop for a 'stand alone' program we use GO BACK only, so should I consider every such program a sub-program..


I anticipated this before posting. So posted following line

Quote:
Just to add somemore confusion for the already exisiting one -
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 13, 2008 12:10 am
Reply with quote

Hello,

Quote:
Then what should be suitable answer for the main question

Quote:
How do i identify if a particular program is a main program or a sub-program by just looking at the program.

I am not aware of a way to know for 100% sure if a module is "main" or "called" by only looking at the source code. . .
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Thu Mar 13, 2008 7:00 pm
Reply with quote

Agree with Dick.

Here we have daily searchs in program libraries in order to get the call-ers/call-eds list.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Sun Mar 16, 2008 2:26 pm
Reply with quote

Hi acevedo,

What criteria do You use to search 'call-eds' (is call-eds equivalent to CALLed programs aka sub-routines)?
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 344
Location: Spain

PostPosted: Tue Mar 18, 2008 5:42 pm
Reply with quote

here all CALLs must be dynamic and the working field must have the format C-SUBROUTINENAME...so we can track wich program/subroutine calls to a given subroutine.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Wed Mar 19, 2008 12:33 am
Reply with quote

Hi,

Ok does that mean, we can not set a general rule for finding a CALLed module, it might change across sites ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Mar 19, 2008 1:36 am
Reply with quote

Hello,

Quote:
we can not set a general rule for finding a CALLed module, it might change across sites
Yes, we cannot set a general rule that will always work.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


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

PostPosted: Wed Mar 19, 2008 2:30 am
Reply with quote

Hi Dick,

Thanks, a little 'devil' in me leaves me today.. icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top