View previous topic :: View next topic
|
Author |
Message |
sravanreddy Warnings : 1 New User
Joined: 25 Feb 2005 Posts: 2 Location: hydeabad
|
|
|
|
Hai,
This is SRAVN,
HOW TO IDENTIFY IS THIS MAINPROGRAM OR SUBPROGRAM BY SEEING APPLICATION PROGRAM?WITH OUT USING JCL?l |
|
Back to top |
|
|
iknow
Active User
Joined: 22 Aug 2005 Posts: 411 Location: Colarado, US
|
|
|
|
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 |
|
|
sbalajibe
New User
Joined: 15 Aug 2005 Posts: 62
|
|
|
|
Hi
Adding to that
linkage section has to be defined for the subprogram |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
fawzy47 Currently Banned New User
Joined: 22 Oct 2005 Posts: 42
|
|
|
|
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 |
|
|
iknow
Active User
Joined: 22 Aug 2005 Posts: 411 Location: Colarado, US
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
They both can run from the same library. |
|
Back to top |
|
|
mijanurit Currently Banned New User
Joined: 26 Aug 2005 Posts: 33 Location: bangalore
|
|
|
|
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 |
|
|
Durga
New User
Joined: 13 Apr 2005 Posts: 3 Location: PUNE
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
|