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

How to differentiate the main program and subprogram by code


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 411
Location: Colarado, US

PostPosted: Mon Nov 21, 2005 3:34 pm
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
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: 677
Location: NJ

PostPosted: Mon Nov 21, 2005 4:40 pm
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
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
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
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: 411
Location: Colarado, US

PostPosted: Tue Nov 22, 2005 5:37 pm
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
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
Search our Forums:

Back to Top