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

why do we write sub program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jmalli
Currently Banned

New User


Joined: 19 Jul 2006
Posts: 8

PostPosted: Fri Dec 08, 2006 9:51 am
Reply with quote

Hello Friends.
could you please let me know ,why do we write the sub program ? what are the advantages ? please give me details about it .
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Fri Dec 08, 2006 10:00 am
Reply with quote

Sub programs are used so that we can easly find the errors in the program
its a common matter a program with 1000 lines of code will be difficult to debug so we are dividing it into some subprograms with 200 or 300 lines so that we can easly identify the errors
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Dec 08, 2006 5:27 pm
Reply with quote

I find subprograms are a nice way to package functionality into a convenient "black box" for multiple programs to use.
Back to top
View user's profile Send private message
yaju4ever
Warnings : 1

New User


Joined: 30 Sep 2006
Posts: 19
Location: mumbai

PostPosted: Fri Dec 08, 2006 10:43 pm
Reply with quote

jmalli wrote:
Hello Friends.
could you please let me know ,why do we write the sub program ? what are the advantages ? please give me details about it .

well dear as my knowledge subroutine is used to divide ur large size progrm in to smaller and more manageable parts ..... cobol subroutine is saperatly compiled program.....and when same module is required in more than one applications it may be helpfull to design it in the saperatly compiled program...
Back to top
View user's profile Send private message
dnreddy

New User


Joined: 08 Dec 2006
Posts: 8
Location: chennai

PostPosted: Mon Dec 11, 2006 3:02 pm
Reply with quote

There are several reasons to create subprograms. More than one may apply in a given case.
1) Make Programs Smaller
Traditionally, COBOL programs tend to be large and monolithic. Such big programs are hard to read and harder to maintain. For unusually large load modules, it is useful to break out the major functions into subprograms of a more manageable size.
2) Make Code Reusable
If you find yourself writing the same code more than once, consider burying it in a subprogram, especially if:
? The code is extensive or tricky, or
? There are many potential uses for it.
3) Build Firewalls Around Change
In any application, some parts are are more volatile than others. Consider isolating the most volatile parts in subprograms. Then changes will be easier: first because you only need to change one program, and second because that one program is small and simple. You still need to identify and relink all of the relevant load modules (unless the subprogram is called dynamically), but you would have to do that much anyway.
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 Write line by line from two files DFSORT/ICETOOL 7
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
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top