View previous topic :: View next topic
|
Author |
Message |
hmurali Warnings : 1 New User
Joined: 08 Mar 2005 Posts: 17
|
|
|
|
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 |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
see the Procedure division statement. |
|
Back to top |
|
|
hmurali Warnings : 1 New User
Joined: 08 Mar 2005 Posts: 17
|
|
|
|
Could more details be provided...what do i need to look for in the procedure division.. |
|
Back to top |
|
|
ashwinreddy
Active User
Joined: 16 Sep 2004 Posts: 106 Location: Hyderabad
|
|
|
|
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 |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
LINKAGE is also used for getting EXEC card parms, which would not be considered a sub-program call. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
eh..so all the suggestions from me are ruled out...
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
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 |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
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 |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
here ALL the Cobol programs ends with GOBACK. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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.. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
Agree with Dick.
Here we have daily searchs in program libraries in order to get the call-ers/call-eds list. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi acevedo,
What criteria do You use to search 'call-eds' (is call-eds equivalent to CALLed programs aka sub-routines)? |
|
Back to top |
|
|
acevedo
Active User
Joined: 11 May 2005 Posts: 344 Location: Spain
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Hi Dick,
Thanks, a little 'devil' in me leaves me today.. |
|
Back to top |
|
|
|