Page 1 of 1

How to identify the program(main/Subpgm)?

Posted: Wed Feb 10, 2010 3:24 pm
by Aparna Vipin
How to identify whether a cobol program is a main program or Subprogram,Other than finding out by program name ie eg:AB100P/AB100S??

Posted: Wed Feb 10, 2010 3:42 pm
by Natarajan
my .2 cents....

If the program has linkage section in it and it is not a CICS program. it might be a sub program.

if the program dont have stop run& has goback, it is a subprogram.

Posted: Wed Feb 10, 2010 4:01 pm
by Aparna Vipin
but in most of our programs in my proj is having goback in main program....wat will it do?where will it go?

Posted: Wed Feb 10, 2010 4:22 pm
by Natarajan
yes, we can use GOBACK in main progam also.
Normally, in many shops main programs contain STOP RUN.


GOBACK used in main program behave like a STOP RUN. GOBACK issued from a
subprogram behaves like a EXIT PROGRAM, it does not change status of any files in that run unit.

Posted: Wed Feb 10, 2010 4:29 pm
by Aparna Vipin
Thanks for your quick response

Posted: Wed Feb 10, 2010 4:38 pm
by Anuj Dhawan
Other than finding out by program name
How does program-name help in identifying the type of program?

Posted: Wed Feb 10, 2010 4:47 pm
by Anuj Dhawan
From the syntactic perspctive, a COBOL subprogram is nearly identical to that of a COBOL program; in particular, it has the same four divisions: IDENTIFICATION, ENVIRONMENT, DATA, and PROCEDURE.

However, in a sub-program DATA DIVISION includes a LINKAGE section, in addition to the FILE and WORKING-STORAGE sections. in LINKAGE section programmer describes the subprogram's formal arguments.

Another syntactic difference is that, in a subprogram, the PROCEDURE DIVISION header includes a USING clause that lists the names of the formal arguments and, in so doing, indicates the order in which the corresponding actual arguments must be listed by the caller in making a call to the subprogram.

Finally, to terminate execution of a subprogram (and return control to its caller), the statement GO-BACK is used, rather than STOP RUN. STOP-RUN statement will, as usual, have the effect of terminating execution of the whole logical unit of work; in other words, if it is executed within a subprogram, control will not return to its caller.

Posted: Thu Feb 11, 2010 2:10 am
by anv2010
Do you need to make the distinction at run-time, problem diagnosis, or just by the causal program source observation?

Posted: Thu Feb 11, 2010 10:13 am
by Aparna Vipin
How to identify during run time?

Posted: Thu Feb 25, 2010 9:44 pm
by anv2010
Hello.

1. Compile your program with the following COBOL compiler options: MAP, XREF and LIST (just to obtain extra information for our analysis).

2. Find ' TGT '

Code: Select all

*** TGT MEMORY MAP ***                        
TGTLOC                                        
                                              
000000  RESERVED - 72 BYTES                   
000048  TGT IDENTIFIER                        
00004C  RESERVED - 4 BYTES                    
000050  TGT LEVEL INDICATOR                   
000051  RESERVED - 3 BYTES                    
000054  32 BIT SWITCH   
000058  POINTER TO RUNCOM
00005C  POINTER TO COBVEC                      
. . .
Please note the location of RUNCOM, it's at +58 off TGT.

3. The following IBM manual provides some information with which to map RUNCOM:

http://publibz.boulder.ibm.com/cgi-bin/ ... T#FIRSTHIT

The IBM LE RUNCOM block would allow you to determine whether or not your program is the main or a sub-program within IBM LE runcom unit.

4. We have an assembler routine that performs these TGT /RUNCOM analysis during COBOL applications run.

I hope my information helps somewhat.

Best.