Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to differentiate the main program and subprogram by code

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sravanreddy
Warnings : 1

New User


Joined: 25 Feb 2005
Posts: 2
Location: hydeabad

PostPosted: Mon Nov 21, 2005 3:07 pm    Post subject: How to differentiate the main program and subprogram by code
Reply with quote

Hai,
This is SRAVN,
HOW TO IDENTIFY IS THIS MAINPROGRAM OR SUBPROGRAM BY SEEING APPLICATION PROGRAM?WITH OUT USING JCL?l
Back to top
View user's profile Send private message

iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Mon Nov 21, 2005 3:34 pm    Post subject: Re: COBOL
Reply with quote

Hi sravanreddy,

1)Subprogram can be identified if that code contains " GO BACK" (usually "STOP RUN will not be used in sub programs because the control will not return to the main program, it terminates).

2) By looking into the "procedure division using" statement.

Please correct me if I am wrong.
Back to top
View user's profile Send private message
sbalajibe

New User


Joined: 15 Aug 2005
Posts: 62

PostPosted: Mon Nov 21, 2005 3:42 pm    Post subject:
Reply with quote

Hi

Adding to that
linkage section has to be defined for the subprogram
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 680
Location: NJ

PostPosted: Mon Nov 21, 2005 4:40 pm    Post subject: subprogram
Reply with quote

hi frnd,
As per balaji and iknow u can check ur subprogram by considering both thier results ie., GO BACK and LINKAGE SECTIONG .. other than that if u are coding so then try to use the prefix in the prog-id such that it will be helpful to u!!!
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Nov 22, 2005 4:16 am    Post subject: Re: How to differentiate the main program and subprogram by
Reply with quote

sravanreddy,

My postscript from my limited experience. The GOBACK verb is commonly used in both main and sub-programs, so this is no guarantee. The sub-programs only method of receiving data from and returning data to the main program is through the use of the linkage section. Therefore, a reasonable way to check if the program is a sub-program is through the use of the linkage section. *disclaimer ? the Linkage section can also be used in main programs to receive user-parameter data from the JCL, so checking the linkage section is NOT a 100% method. I good understanding of the program is the best way. A well written program will have all this information in the comments area.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Nov 22, 2005 6:11 am    Post subject:
Reply with quote

Adding to what David said, a subpgm doesn't necessarily have to use the "USING" phrase in the POC DIV stmt. When no data is being passed back or forth, it's not required.

It's a rare occurance, but it can happen.
Back to top
View user's profile Send private message
fawzy47
Currently Banned

New User


Joined: 22 Oct 2005
Posts: 42

PostPosted: Tue Nov 22, 2005 7:32 am    Post subject: How to identify a Subprogram from MainProgram
Reply with quote

Hi,
The Subprogram is Identified by Procedure Division using and Exit Program, However, maybe the calling program is a subprogram for another calling program
I hope that can help
Fawzy
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Tue Nov 22, 2005 5:37 pm    Post subject: Re: How to differentiate the main program and subprogram by
Reply with quote

Hi

We can identify the main program/sub-program by looking into the libraries in which library the main program/ sub-program is run.

Correct me if I am wrong.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 23, 2005 7:33 am    Post subject:
Reply with quote

They both can run from the same library.
Back to top
View user's profile Send private message
mijanurit
Currently Banned

New User


Joined: 26 Aug 2005
Posts: 33
Location: bangalore

PostPosted: Sun Nov 27, 2005 7:07 pm    Post subject:
Reply with quote

hi!

we can diffrentiate the main prog and subprog by linkage section if data passing is happend between the two progs.

if data is not passing betwn the progs then we cant defferentiate main and sub progs.

another option by seeing last statement if it contains EXIT PROGRAM then it is subprog.
but if it contains GO BACK then we cant defferentiate. bcz GO BACK can be coded in main program as well as in subprog.

third option is to check "program logic".
Back to top
View user's profile Send private message
Durga

New User


Joined: 13 Apr 2005
Posts: 3
Location: PUNE

PostPosted: Fri Dec 02, 2005 12:05 pm    Post subject: Re: How to differentiate the main program and subprogram by
Reply with quote

Hi Friends,

All the posts are correct but as per my knowledge we can identify the sub program and main program thru linkage section.
Data can be passed to main program thru JCL (PARM parameter) if that is the case then in the Linkage Section there should be a variable with the length declared as s9(4) Comp before declaring the variable (which contains the data).
In sub programs there is no need to declare the length variable.

So i think by this we can identify :)
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Dec 04, 2005 3:22 am    Post subject:
Reply with quote

Hi Durga,

A main pgm may not have any data passed o it thru the PARM. In that case it won't have a Linkage Sect.

The only way to ID a batch COBOL pgm as a main pgm that uses sub pgms is to look for a "CALL " stmt.

As to sub pgms, there's no way to tell if a pgm is NOT a sub pgm. You can use all that's been discussed here to ID it as a sub pgm. If none of those things are in the code, you CAN'T make a judgement.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IBEGENER RETURN CODE 12 anilkumar922 All Other Mainframe Topics 5 Wed Dec 13, 2017 11:41 am
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
No new posts Finding the plan when code compiled u... Ahemad DB2 1 Fri Dec 01, 2017 6:38 pm
No new posts Strange Code amitc23 COBOL Programming 6 Tue Nov 28, 2017 11:25 am
No new posts Calling IKJEFT01 program from Rexx upendrasri CLIST & REXX 8 Wed Nov 15, 2017 4:27 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us