How to identify the program(main/Subpgm)?

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
Aparna Vipin
Member
Posts: 10
Joined: Thu Apr 09, 2009 3:11 pm

How to identify the program(main/Subpgm)?

Post by Aparna Vipin » Wed Feb 10, 2010 3:24 pm

How to identify whether a cobol program is a main program or Subprogram,Other than finding out by program name ie eg:AB100P/AB100S??

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Wed Feb 10, 2010 3:42 pm

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.
Natarajan
Chennai

Aparna Vipin
Member
Posts: 10
Joined: Thu Apr 09, 2009 3:11 pm

Post by Aparna Vipin » Wed Feb 10, 2010 4:01 pm

but in most of our programs in my proj is having goback in main program....wat will it do?where will it go?

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Wed Feb 10, 2010 4:22 pm

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.
Natarajan
Chennai

Aparna Vipin
Member
Posts: 10
Joined: Thu Apr 09, 2009 3:11 pm

Post by Aparna Vipin » Wed Feb 10, 2010 4:29 pm

Thanks for your quick response

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Feb 10, 2010 4:38 pm

Other than finding out by program name
How does program-name help in identifying the type of program?
Regards,
Anuj

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Feb 10, 2010 4:47 pm

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.
Regards,
Anuj

anv2010
Member
Posts: 5
Joined: Fri Feb 05, 2010 12:11 am
Location: New Jersey, US
Contact:

Post by anv2010 » Thu Feb 11, 2010 2:10 am

Do you need to make the distinction at run-time, problem diagnosis, or just by the causal program source observation?
Smart/RESTART :: Checkpoint Restart for z/OS batch applications

Aparna Vipin
Member
Posts: 10
Joined: Thu Apr 09, 2009 3:11 pm

Post by Aparna Vipin » Thu Feb 11, 2010 10:13 am

How to identify during run time?

anv2010
Member
Posts: 5
Joined: Fri Feb 05, 2010 12:11 am
Location: New Jersey, US
Contact:

Post by anv2010 » Thu Feb 25, 2010 9:44 pm

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.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others