Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Main Program or Sub program
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> HomeWorks & Requests
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    Post subject: Main Program or Sub program
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: 356
Location: New York

PostPosted: Tue Mar 11, 2008 11:23 am    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
Reply with quote

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

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

Senior Member


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

PostPosted: Tue Mar 11, 2008 12:50 pm    Post subject:
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

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

Active Member


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

PostPosted: Tue Mar 11, 2008 5:18 pm    Post subject:
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

Site Director


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

PostPosted: Tue Mar 11, 2008 10:18 pm    Post subject:
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

Senior Member


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

PostPosted: Tue Mar 11, 2008 11:58 pm    Post subject:
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

Site Director


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

PostPosted: Wed Mar 12, 2008 9:12 am    Post subject:
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

Senior Member


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

PostPosted: Wed Mar 12, 2008 10:52 am    Post subject:
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    Post subject:
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: 1439
Location: Bangalore,India

PostPosted: Wed Mar 12, 2008 1:19 pm    Post subject:
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    Post subject:
Reply with quote

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

Senior Member


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

PostPosted: Wed Mar 12, 2008 2:00 pm    Post subject:
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: 1439
Location: Bangalore,India

PostPosted: Wed Mar 12, 2008 2:03 pm    Post subject:
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

Site Director


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

PostPosted: Thu Mar 13, 2008 12:10 am    Post subject:
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    Post subject:
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

Senior Member


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

PostPosted: Sun Mar 16, 2008 2:26 pm    Post subject:
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    Post subject:
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> HomeWorks & Requests All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts A sample of exit program for exit XMN... lind sh CICS 2 Mon Oct 03, 2016 5:07 pm
No new posts Need points to tune IMS Checkpoint Pr... satish.ms10 IMS DB/DC 2 Fri Sep 30, 2016 4:12 pm
No new posts ISPF program to set SCRNAME prino TSO/ISPF 5 Fri Sep 30, 2016 2:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us