Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
42Activity
0 of .
Results for:
No results containing your search query
P. 1
Sub-Programs in COBOL

Sub-Programs in COBOL

Ratings: (0)|Views: 2,221|Likes:
Published by Quasar Chunawalla
This tutorial demonstrates how to write sub-programs in COBOL. For more tutorials and articles, please visit http://www.mainframes360.com
This tutorial demonstrates how to write sub-programs in COBOL. For more tutorials and articles, please visit http://www.mainframes360.com

More info:

Published by: Quasar Chunawalla on Dec 31, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

09/18/2014

pdf

text

original

 
 TCS Public
INSURANCE 2.0QUASAR SHABBIR CHUNAWALAquasar.chunawala@tcs.comFind many more articles on my website :
http://www.mainframes360.com/ 
 
Sub-programs in COBOL
01/01/2010
 
 TCS Public
Introduction
When a Structured Approach is applied to build software, the entire computer applicationprogram is broken down into smaller modules. You divide the application into smallermodules, each module further into sub-modules and so on, till you are able to managethem. When the Computer Program starts, the Main module is invoked. Depending onthe functionality the user wants, the Main module, calls one or more sub-modules toaccomplish this task. The Main module along with all the Sub-modules togetherconstitute the Application.
Single Module COBOL Program
A COBOL Program is divided into many divisions, sections and paragraphs. This is howa simple Hello World COBOL Program looks – 
Program – Hello World in COBOL
The entry point, starting point of a COBOL Program is the
PROCEDURE DIVISION
. Thisis the point at which, the control enters the program. The statements inside theProcedure division are performed step-by-step, one-after-the other in a sequentialmanner.
STOP RUN
is used to terminate the entire application.
IDENTIFICATION DIVISION
is used the identify the program name and author.
ENVIRONMENT DIVISION
specifies any input and output files used by the program.
DATA DIVISION
gives the input and output record formats, as well as any temporaryvariables, being used in the program.
PROCEDURE DIVISION
can contain severalsections and divisions, to organize the program and control the flow.
 
 TCS Public
Calling a Sub-Program
The Main Module in a COBOL Application can reference another external sub-programthat has been separately compiled, by employing
CALL
Statement.Very often, different applications often require the same functionality. If there is a sub-routine that offers this functionality, it can be re-used, shared by many applications,instead of having to write it from scratch, from a fresh slate. Thus, you don’t have to re-invent the wheel.
Sub-modules act as re-usable software components.
 A program containing the
CALL
Statement is called
Calling Program
. The sub-programbeing called is said to be the
Called Program
. When you transfer control to a sub-program, there are 2 ways to do it :
At the beginning of the sub-program
At a particular point in the sub-programIn COBOL, the phenomenon of Recursion, where one COBOL Program calls itself, is notallowed. Moreover, circular calls are also not allowed(A calls B, B calls C, C calls A).
Call Statement
The COBOL
CALL
statement has the following syntax :
CALL ‘sub-program’
Examples :
CALL ‘PROGRAM1’
Given below is application, which consists of a Main Module
INDIA
, which calls two sub-modules
BRAZIL
and
CHINA.
Program – INDIA Program calling BRAZIL and CHINA

Activity (42)

You've already reviewed this. Edit your review.
Francis Miville liked this
1 thousand reads
1 hundred reads
treasur liked this
lionkingsr liked this
sdineeshkumar liked this
DineshManivannan liked this
Sampad Sekhar liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->