132 97 16MB
English Pages 272 Year 1970
%' ^--^1^,
Funclamentals of
BOL
^'''^m^
#ifte*iM ;fv
Progra
mm,.-.
it-*-
iV
a'
/•-' -5' -
't^!-
A
Fundamentals of
COBOL
Programming
r
Digitized by tlie Internet Arcliive in
2012
http://archive.org/cletails/funclamentalsofcoOO
Fundamentals of
COBOL
Programming
Carl Feingold, C.P.A., C.D.P. Los Angeles Trade and Technical College University of California Extension, Los Angeles
WM.
C.
BROWN Dubuque, COMPANY Iowa
PUBLISHERS
Copyright
Wm.
C.
© 1969 by
Brown Company
Publishers
ISBN0-697-08101-X All
rights
reproduced
in
permission in
Second
No part of this book may be any form or by any process without writing from the copyright owner.
reserved.
Printing,
1970
Printed in the United States of America
Preface
After years of dedicated effort by a relatively small group of individuals,
COBOL has emerged as the leading business today. COBOL is enjoying a wide and popular
data processing language in use
acceptance by the business community and is being adopted as the standard business programming language by more companies each day. The continuing efforts of the various COBOL committees plus the support from governmental agencies give promise that COBOL will meet the needs of the users today and well into the future. COBOL not only enjoys support from its users and computer manufacturers but from numerous consulting and software firms who are directing their resources towards additional aids for COBOL users in forms of flow charting, cross reference dictionaries and package programs. This book is so designed that the reader may learn all the basic components of COBOL and apply these principles to the writing of COBOL programs. The practical programming approach plus the theoretical principles presented should provide the programmer with a sound basis for the understanding of the COBOL
programming language.
COBOL program, the COBOL before any
student must have some knowledge of all four program can be written. This normally requires the student to be halfway through the course before he is able to write a COBOL program. Of the four divisions, the Data and Procedure are the largest and most difficult to write. The other two, Identification and Environment Divisions, can be learned in a rather short period of time. In teaching COBOL I have experimented with introducing the Procedure Division before the Data Division with the hope that the student may be able to write COBOL programs sooner in the course. I have also reversed the sequence and have taught the Data Division before the Procedure Division vidth the same amount of success. My conclusion is that regardless of which of the two major divisions are taught first, the student will have to read ahead to
In a
divisions of
acquire an elementary understanding of the other division before he can start programs.
to write
COBOL
The book
is
so arranged that the first four chapters are devoted to the
introduction, the basic components, the Identification
and Environment Diviand waiting COBOL programs. As the student proceeds through the Data Division, he should be reading ahead in the Procedure Division. At this particular point in the course, the student should start waiting COBOL programs using the ten problems supplied in the appendix. These problems progress from the simple to the more complicated programs. sions
Prefacje
vi
The
latter part of the
book explains the many features which allow the user
to obtain a necessary function
without a detailed program. Many of the followCOBOL compilers and are available to
ing features are incorporated in most the users.
These features have been standardized and are now part of the standard
COBOL
package. Report Writer Feature. The production of reports of various types has always placed a large burden in terms of machine and programming time on the business data processing user. The Report Writer Feature allows the programmer to describe his report pictorially in the Data Division thereby minimizing the amount of Procedure Division coding necessary. Sort Feature. Sorting has always constituted a large percentage of the workload in a business data processing installation. Therefore an efficient sort program is most welcome and is a necessary part of any business software system. Declarative and Linkage Sections, Asynchronous Processing. The newer techniques of processing data with random accessing and using mass storage devices permits the programmer through the use of Asynchronous processing to overlay operations at object time thus reducing the time required to execute a sequence of operations. Additional and Opticmal Features. These features provide the user of a large system with optional techniques that may be applied to a COBOL program. COBOL Programming Techniques. These techniques are presented so that the programmer at this stage of development may apply these and write a more efficient COBOL program. I am indebted to the IBM Corporation for gratuitously granting permission to use the numerous illustrations, charts, photos and diagrams that made the text more meaningful. My special thanks to the Burroughs Corp. for permitting me to use their excellent problems and illustrations in the book. My last special thanks is to my wife Sylvia, who served as the chief typist, confidante, proofreader and without whose encouragement the book would never have been written.
Acknowledgment
The following information
reprinted from
is
COBOL
the Conference on Data Systems Languages
U.
S.
Government Printing
Edition 1965, published by printed by the
(CODASYL), and
Office.
COBOL report and specfrom this report as the basis for an instruction manual or for any other purpose is free to do so. However, all such organizations are requested to reproduce this section as part of the introduction to the document. Those using a short passage, as in a book review, are requested to mention "COBOL" in acknowledgment of the source, but need not quote this entire section. "Any organization ifications in whole
"COBOL
is
interested in reproducing the
or in part, using ideas taken
an industry language and
is
not the property of any
company
or group of companies, or of any organization or group of organizations. or implied, is made by any contributor or by the Committee as to the accuracy and functioning of the programming system and language. Moreover, no responsibility is assumed by any contributor, or by the committee, in connection therewith.
"No warranty, expressed
COBOL
"Procedures have been established for the maintenance of
COBOL.
Inquiries
concerning the procedures for proposing changes should be directed to the Executive Committee of the Conference on Data Systems Languages.
"The authors and copyright holders
of the copyrighted material
used herein
FLOW-MATIC (Trademark of Sperry Rand Corporation), Programming for the Univac ( R I and II, Data Automation Systems copyrighted 1958, 1959, by Sperry Rand Corporation; IBM Commercial Translator Form No. F28-8013, copyrighted 1959 by IBM; FACT, DSI 27A52602760, copyrighted 1960 by Minneapolis-Honeywell )
have
specifically authorized the use of this material in
whole or
in part, in
COBOL specifications. Such authorization extends to the reproduction and use of COBOL specifications in programming manuals of similar pub-
the
lications".
vii
Contents
CHAPTER
PAGE
COBOL
1.
Introduction to
2.
Components
3.
Identification
4.
Writing
5.
Data Division
31
6.
Procedure Division
51
7.
Report Writer Feature
85
8.
Sort Feature
101
9.
Declarative and Linkage Section— Asynchronous Processing
113
10.
Additional and Optional Features
123
11.
COBOL
135
of
1
COBOL
5
and Environment Division
COBOL
Programs
15
21
Programming Techniques
Problems
147
Problems
159
COBOL Summary APPENDIX-COBOL Debugging COBOL Reserved Word List Glossary of COBOL Terms
177
Illustrative
Language
189 191
199
Index
COBOL
183
Program Sheets
IX
HffI
Chapter
1
COBOL
Introduction to COBOL
is
defined as a
Language. As such it computer users, both
is
COmmon
Business Oriented
in
industry
service, to establish a standard
and government
common business language that could be processed on the various computers without any reprogramming. The federal government, one of the largest users of data processing equipment, was faced with the enormous task and expense of reprogramming each time a different type of computer was installed.
produce a
processing market.
the
data processing needs
COBOL
has been designed to meet the needs of the users today and in the future at decreasing
COBOL by the
4.
is
the only language translator supported
users including the Federal Government.
COBOL
users will
be skeptical of any new equip-
ment without COBOL capabilities; therefore it incumbent upon the computer manufacturers
5.
participate
wholeheartedly
progress in
COBOL.
COBOL
7.
technological
all
the major It
is
sing. 8.
COBOL as
the 9.
it
is
is not plagued by computer obsolesence constantly being revised to accomodate
newer computers. has a self documentary feature
COBOL
in
that
English language statements are easily understood by managers and nonprogramming per-
the
sonnel.
of data processing professionals,
POPULARITY
as the leading
are
for the popularity of 1.
is
to
data processing language included in more software packages of computer manufacturers than any other language. COBOL has proven that it is machine independent in that it can be processed through various computer configurations with the minimum of program change. Although COBOL was primarily designed for commercial users, it has evolved as a highly sophisticated language in other areas of data procesis
available today.
6.
in
After a decade of dedicated effort
The following
of
costs. 3.
COBOL
were presented in a report by the Conference on Data Systems Languages (CODASYL) in April of 1960. The group was inspired by the difficulty of program exchange among the users of computer equipment. The combined effort of the group was utilized to produce a business-oriented language that would permit a single expression of a program to be compiled on any computer presently operative or contemplated in the future. This would reduce the reprogramming costs and provide an interchange of computer programs amongst the users. The final specifications were written in 1960, and improved in 1961 and 1965 by the repeated efforts of the CODASYL committee. COBOL has emerged as the leading data processing language and is enjoying a wide and popular acceptance in the data initial specifications for
2.
language for program-
ming business data processing applications. The committee was formed in 1959 at the insistence of the Department of Defense with the express purpose to
The
responsiveness to the community.
the result of the efforts of
some
of the reasons
COBOL
advanced
today.
COBOL has been continuously standardized by repeated meetings of the CODASYL committee to improve the language and to guarantee its
language
in the
by
a small
COBOL
group
has emerged
data processing comat standard-
munity. The continued voluntary efforts ization and technological improvement in
the
COBOL
language will guarantee its responsiveness to the needs of information by management and its ability to survive the ever-changing data processing field.
Introduction
Common Language A great deal of controversy
arises
whether
COBOL
common
language: a programming language be compiled on any configuration of any computer. COBOL programs are written for comis
truly a
that can
minimum capacity of 32,000 characters. would eliminate many of the smaller computers
puters with a
This
from using in
a
programmer write
COBOL
if
he
a
more
efficient
required.
COBOL
as yet is not completely common but is approaching this objective. It offers more commonality than any other processor presently in use. It is hoped that the continuing meetings of the CODASYL committee will make COBOL a more
rapidly
useful tool in the future. to
program in English, thus providing these personnel with the opportunit>' of judging the logic of the program.
COBOL has whereby a COBOL
efficiency of
the point
DISADVANTAGES
familiar with the
is
format to reduce the amount of conversion time necessary or to reduce the number of storage positions
The
COBOL
COBOL.
program hardware? The answer of course is yes. He can take advantage of such programming approaches as a packed decimal
Can
segments and each programmer may write one division. The format definition can be made available to all programmers engaged in the problem. Nonprogrammers and managers can read the 5.
steadily increased
program
is
more
new programmer who
disadvantages arise with the failure understand the language and
of the
to fully
use.
its
that a single COBOL program permanent solution without ever repro-
The expectation
1.
will provide
gramming. 2. Assuming that the programmer need be taught only the COBOL language without any knowledge of the hardware or the operation of the computer.
COBOL
3.
gram
codes a program on a one for one basis in some assembly language for a particular machine. Perhaps the COBOL program is not as efficient as an object program produced by a very good programmer in the symbolic language of the individual computer. efficient than that of a
Most
of personnel
will not generate a sophisticated pro-
similar to
one written
in the actual
language
of the particular computer.
COBOL
4.
processors
will
operate
only
with a
computer having certain storage capacity. The newer
COBOL
compilers require larger storage areas. With the introduction of larger and larger storage units, this
problem has been greatly reduced.
OBJECTIVES
ADVANTAGES The program
written in the English language, thus removing the programmer from the individual machine or symbolic language instructions required in the program. Although a knowledge of the individual instructions (symbolic and machine) are not required in programming, it is very useful to the writing of an efficient program if the programmer possesses some knowledge of the hardware and coding of the particular computer. 2. Pretested modules of input and output are included in the COBOL processor relieving the programmer of the tedious task of writing input and output specifications and testing them. 1.
is
COBOL
The programmer is writing in a language that familiar to himself, thus reducing the documentation required as the chance for clerical error is diminished. 3.
is
4. Because of the separate divisions in COBOL, a large program can be broken dowTi into various
1. To provide standardized elements in entr>' format that can be used on all computers regardless of make or model: A single common language that can be used by all. 2. To provide a source program that is easy to it has been written in the ENGlanguage. Nonprogrammers can understand the logic of the program as well as the programmers themselves.
understand because
LISH
3. To provide a language that is oriented primarily toward commercial appUcations. Thus the opportunity
provided to business people to participate in the programming. Although COBOL is oriented toward a problem rather than a particular machine, there are major differences in computers that have to be allowed for and adjusted to within the framework of the common language. These adjustments are usually minor and the programmer with a COBOL knowledge can leam these on the job. is
Name
TRUE AND FALSE QUESTIONS: T T T
F F F
T T
Date
Section
Encircle (T)
TRUE
or (F)
FALSE.
COBOL
3.
is a standard language for programming scientific data processing applications. The Department of Defense was the first to pioneer the need for a common business language. The express purpose of the CODASYL group was to produce a business oriented language that
F F
4.
A common
T T T T T T T T
F F F F F F F F
6.
T T
F F
T T T
F F F
1.
2.
could be compiled on a computer. business language tends to increase programming costs. One of the advantages of COBOL is that the language has been standardized due to the repeated meetings of the committee.
5.
COBOL COBOL COBOL COBOL
is
the only language supported by the users.
machine dependent language. plagued by computer obsolence. 9. is easily understood by non programming personnel. 10. A common language is defined as one that can be compiled on any configuration of a computer. n. COBOL is the most efficient program that can be written for a particular problem. 12. COBOL releases the programmer from the individual machine or symbolic languages. 13. The programmer need not possess any knowledge of the individual instructions as this will only serve to confuse him in writing his COBOL program. 14. Pretested modules of input and output are included in the COBOL process. 15. Since the programmer is writing in a language familiar to him, the documentation requires less in a COBOL program. 7.
8.
is
a
is
17.
A large program may not be broken down since it is necessary to write all four divisions. A COBOL program will provide a permanent solution without ever reprogramming.
18.
COBOL
16.
will generate a sophisticated
program
similar to
one written
in the actual
language of the
particular computer.
T T
F
19.
One
F
20.
COBOL
of the objectives of
COBOL
is
MULTIPLE CHOICE QUESTIONS: 1.
COBOL
is
to provide a
common language
that can
be used by
all.
provides the opportunity for business people to participate in programming.
Encircle the letter next to the correct answer.
defined as a
Commercial Business Oriented Language. B. Common Business Oriented Language. C. Certified Business Operated Language.
A.
D. None of the above. 2.
The
initial specifications for
COBOL
were presented
in a report
by
The Dept. of Defense. B. The IBM Corp. C. The CODASYL Committee. D. None of the above.
A.
3.
The reasons A.
COBOL COBOL COBOL
for the popularity of is
COBOL
today are
the only language translator supported by users.
the major data processing language available today. can be processed through various computer configurations with a D. All of the above.
B.
C.
4.
is
A common language is A programming language B. A programming language /\
A.
that can
be compiled on any computer.
written for a particular piece of equipment.
minimum
of
program change.
^ C.
A programming
source language especially written for a system 360 computer.
D. None of the above. 5.
A COBOL program A. B.
C.
is
generally
more
efficient than
One written in the actual symbolic or machine language of the computer. One written by a new programmer in an assembly language on one for one An object program produced by a very good programmer.
basis.
D. All of the above. 6.
COBOL
Some of the advantages of The program is written
in actual
A.
A
are
symbolic language of the machine.
program can be written at one time without the necessity of segmentation of the program. C. COBOL writes input and output modules. B.
large
D. None of the above. 7.
One A.
main disadvantages
of the
COBOL
of
COBOL
is
will not generate a sophisticated
program
similar to the
one
viritten in the actual
language of
the computer. B.
Non programmers cannot read
C.
More documentation
is
COBOL
programs.
required than in other programming languages.
D. All of the above. 8.
COBOL A. B.
A A
provides
source program easy to understand.
language oriented towards a commercial application.
C. Standardized elements that can be used in
all
computers.
D. All of the above.
QUESTIONS FOR REVIEW L Why was
common business language? committee meet and what was their major objective?
the federal government interested in developing a
2.
When
3.
List seven reasons for the popularity of
4.
Why
5.
What
6.
Is
did the
COBOL
has is
first
a
COBOL
CODASYL emerged
common language? as efficient as a
COBOL.
as the leading Is
COBOL
a
language
in the
data processing community?
common language?
program written
in a
symbolic language for a particular computer? Explain.
Chapter
Components COBOL is similar to the Enghsh language in the use of words, sentences and paragraphs. In order to write COBOL programs, the programmer should familiarize himself with basic components of COBOL
2
of
COBOL
program. All items used must be identified by a unique data name.
Procedure names are symboHc segments of the PROCEDURE DIVISION. These names are used for reference by the program in a decision-making operation. The basic concept of computer program-
Names. names attached
Procedure
programming. There are many terms, rules, entry and program structures to be learned before any attempt at COBOL programming is made. formats,
ming
the ability of the
program
to leave the
sequential order to another part of the program for further processing. The procedure names may
TERMS Source Program. The source program is written in COBOL language which will be later compiled into the machine language of the particular com-
consist entirely of numerals.
A
Condition Names.
ment
puter.
of a
name
condition
mnemonic name
to
is
the attach-
an item that
may
have various values.
Object Program. The machine language that was compiled from the source program.
Special
A program supplied by a computer manufacturer that will translate the source program into the machine language program.
Source Ccrmputer. This is the computer that is used to compile the source program. Usually the same computer is used for the object computer. Object Computer. This is the computer upon which the machine language program will be processed.
Character
Set.
The complete
set
of
COBOL
A symbolic attached to an item that is being used in the program. All reference to the item will be through the name although the value may change many times throughout the execution of the program. The name must be unique or identified with the file in which it is found. Types of Names Data Names. Data names are assigned by the programmer to identify data items to be used in a
computer
in
the
ENVIRONMENT
DIVI-
Rules for the Assignment of Names 1.
Names may range from one
to
30 characters
in
length. 2.
3.
No
spaces (blanks) may appear Names may be formed from the
within a name. alphabet, numer-
and the hyphen. No special characters may appear in a name except the hyphen. Although hyphens may appear in a name, no name may begin or end with a hyphen. The procedure name may consist entirely of numerals but all other names must have at least one als
4.
identify certain data within a program. is
Special names are the mnemonic assigned to various components
may be
SION.
char-
to
that
of the
acters consists of 51 characters.
Names. Names are a means of establishing words
Names.
names
Compiler.
name
is
to various
5.
letter. 6.
Names which a higher level
must be qualified with name. (See qualification rules.)
are identical
Reserved Words Reserved words have preassigned meanings and must not be altered, misspelled or changed in any manner from the specific purpose of the word. A
i 1
o
i I
1
i
COBOL
Components of
CHARACl'ER SET through 9 Letters A through Z Special characters: Blank or space + Plus sign Minus sign or hyphen * Check protection symbol, asterisk / Slash = Equal sign > Inequality sign (greater than) < Inequality sign (less than) $ Dollar sign
Digits
)
Period or decimal point Quotation mark Left parenthesis Right parenthesis
;
Semicolon
. '
(
A -
Comma
.
Period
;
Semicolon
The following characters are used
in
arithmetic expressions:
-
Subtraction Multiplication / Division * * Exponentiation *
through 9 through Z (hyphen)
resu|lar-|wage|s.
The following characters are used
in relation tests:
Greater than Less than = Equal to >
'pes of
A.
Data names.
B.
Procedure names.
names used
in
COBOL
programming.
C. Condition names.
D. All of the above. 3.
The following rules apply to the assignment of names. A. Names may be formed from any combination of alphanumeric B.
C.
No hyphens may appear within a name. Names may range up to 30 characters in
characters.
length.
D. All of the above. 4.
Reserve words A. B.
C.
May be May be May be
used
any format determined by the programmer.
in
mispelled as compiler will interpret the altered
word
correctly.
by programming.
D. None of the above. 5.
Words that must be included A. Key words. B.
in a
program are called
Reserved words.
C. Bracket words.
D. None of the above. 6.
A
rule for qualification of data
A.
The
B.
A name may
C.
The highest
names
is
highest level permitted as a qualifier
is a record name. two levels in the same hierarchy as long qualifier must be a unique name.
appear level
at
as
it
is
qualified.
D. All of the above. 7.
Numeric A. B.
C.
May May May
literals
contain up to 30 digits. contain a decimal point in the extreme right position. contain a sign in the rightmost character position.
D. None of the above. 8.
An example
of a Figurative Constant
is
A. Blanks. B. Zeroes.
C. Digits.
D. None of the above. 9.
OR
an example of a
is
A. Relational expression operator. B. Logical expression operator.
C. Arithmetic expression operator.
D. None of the above. 10.
A
general rule applying to the use of punctuation is An arithmetic or logical operator must always be preceded and followed B. A period must alwa\s be preceded and followed by a space.
A.
C.
A
D.
.•Ml
semicolon
when used must
not be followed
by
of the above.
12
a space.
by
a space.
Name.
Date
Section
IDENTIFICATION QUESTIONS: Column
Indicate in
column 2 the
letter that identifies the item in
B
Translates source program
C
SPACE
Assigned to various components
D
Improve readability May be used in computations Assigned by programmer
H
STATEMENT COMPILER OPERATOR RESERVED WORDS NON-NUMERIC LITERAL
I
OPTIONAL WORDS
Must be enclosed
J
DATA NAMES
Preassigned meanings
E F
G
1.
Column 2
1
NUMERIC LITERAL SPECIAL NAMES
A
column
Figurative Constant
Expressing a thought Specify some sort of action in quotation
marks
QUESTIONS FOR REVIEW 2.
What should What do the
3.
Explain the different types of names used in
1.
4. 5. 6.
7. 8. 9.
10. 11.
What What What
Name What What What What
the
programmer
following terms
familiarize himself with before attempting to write a
mean
are the rules for assigning is
a
Reserved word and
in
COBOL;
COBOL
how
is it
programming and
their expressed purpose.
used?
seven rules for qualification of data names. is
a literal?
are the rules for the use of numeric literals?
are the rules for the use of non-numeric literals? is
a Figurative Constant?
What
is
main advantage
its
how
COBOL
12.
What
WTiat are Relational expression operators? What is the purpose of Logical expression operators?
16.
What What
COBOL?
are the rules for the use of words?
13. 14.
in
names?
to a
programmer? Give an example
urative Constant.
15.
program
Source program, Compiler, Object computer?
is
an operator and
is
it
used
in
programming?
are the important rules of punctuation? is
the difference between an imperative
and conditional statement?
13
of a Fig-
Chapter
3
Identification and
Environment Divisions IDENTIFICATION DIVISION The IDENTIFICATION DIVISION
is
Only three
of all four divisions to write.
Requirements
The
the simplest entries are
actually required, with the other paragraphs optional.
three entries required are,
Header-IDENTIFICATION DIVISION.
1.
Division
2.
Program-ID.
3.
Program Name. The program name must be enclosed
a.
Function
The function identify the
of the
program and
relative to the
Division is to provide other information
Identification to
b.
program. c.
d.
The
Format
[
AUTHOR entry
[
.
.
.
.
.
]
[DATE-WRITTEN entry
[
.
.
.
SECURITY entry
.
entry
.
.
.
]
Identification
program name must
contain up to six additional para-
(AUTHOR, INSTALLA-
ENVIRONMENT DIVISION The ENVIRONMENT DIVISION is the sion of COBOL that is machine dependent.
one
divi-
The
pro-
grammer would have
with the
to familiarize himself
characteristics and special names of the machine upon which the particular source program is to be run. All the aspects of a COBOL program that are dependent upon the physical characteristics of a specific com-
. ]
.
.
may
a
.
]
.
.
[REMARKS
FIGURE 3.1.
.
DATE-COMPILED entry
[
.
division
in
contain any of the numerals, letters or special characters terminated by a period. The programmer has complete freedom in what he chooses to write in these optional paragraphs. Entries in the REMARKS portion of the program usually stipulate the purpose of the program and what the program is to accomplish.
.]
INSTALLATION entry
.
.
.
gram name. The first character be a letter.
TION, DATE-WRITTEN, DATE-COMPILED, SECURITY, and REMARKS). The sentences used in the optional paragraphs may
.
'program-name'
quo-
The program name can contain no more than 8 characters. No special characters are allowed in the pro-
graphs with fixed names
IDENTIFICATION DIVISION
PROGRAM-ID
in
tation marks.
puter are provided for in this division. A link is provided between the logical concept of the files and the physical aspects of the devices upon which the files will be processed and stored.
. ]
Division— Format
15
R
Identification and Envibonment Divisions
16
1
denJt
1
F
1
CAT ON
D
1
progIram- D EXP ENSE AUTHlOR
1
1
V
;
1
S
1
1
ON
.
.
1
S
I'
'
. '
!
.
BROW N
ICHAR LES 1
nstIalla t' ON
!
. 1
.
I
DATA DEV GES
Idyna M\ C
dateI-wr TTEN Inove MB E dateI-com P LE 1
9, D
1
965
.
1
96 5
.
1
1
;
AV A ILA BLE TO ONL Y .
1
ENVIRONMENT DIVISION
[object-computer
INPUT-OUTPUT SECTION FILE-CONTROL .
...]
.
.
.
Environment Division
.
.
Division
divided into two paragraphs. Source-Compwfer which defines the computer upon which the compilation is to take place. Also on some computers, the size and range of main storage to be used as well as a particular model number. Object -Computer which defines the computer upon which the object compiled program is to be run. Also the same specifications as to size and range of main storage to be used and the particular model number may be stipulated. is
•iJ
[I-O-CONTROL APPLY-entry
ALL TMEN T
Configuration Section The Configuration Section specifies the overall characteristics of the computers involved. The section
SOURCE-COMPUTER
SELECT-entry
N G OF D EPAR
.
CONFIGURATION SECTION
[
1
Example— Identification
FIGUAE 3.2.
FIGURE 3.3.
i
.
Iprod UCES A W EEKL Y LI ST lOPER AT N G EX PENS ES, BY
Format
,
•
SECUIr TY ICOMP ANY- CONF ID EN T lAL Iauth OR Z ED P ERSO NNEL
remaIrks
.
!
Inove MBER 10, ,
,
,
I
1
IN C
1
]
—Format Input- Output Section
The
Function
The function of the Environment Division is to upon which computer the source program
specify
be compiled and the computer that will be used program. In addition, all input and output files will be assigned to individual hardware devices. Any special input and output techniques that will be used in the processing of the data will be defined here. will
to execute the object
The two the
ENVIRONMENT DIVISION
Input- Output Section must be included any source program if there are any input or output files required. As most programs involve the processing of files, this section is required in most in
is
divided into
sections: the CONFIGURATION SECTION INPUT-OUTPUT SECTION.
and
programs. The Input
- Output Section is concerned with the definition of the input and output devices as well as the most efficient method of handling the data
between the devices and the object program.
The section is divided into tvvo paragraphs: File Control paragraph and the I-O-Control Paragraph. The individual clauses that comprise these paragraphs may appear in any sequence within their respective
Identification and
Environment Divisions
17 1
'
1
ENV iIrONM ENT
D
V
1
S
1
1
ON
1
•
'
1
1
,
« i
CONFjl GUR AT
SE CT
N
1
1
N
'
\
. •
:
1 j
1
j
1
SOURlCE-C OMPU TER BM- 360 F30.
1
!
.
:
i
II
:
1
I ;
1
1
j
obje!ct-c OMPU TER F30. BM- 36
1
1
i
.
!l 1
i
1
1
NPUlT-OU TPUT SEC T
1
ON
i
V
(
1
1
,
• '
:
1
Fi
i'
'
leI-con TROL ISELE CT P URCH AS N G-F
^
•
1
1
LE"
1
!
i
'S YS01 5' U N T- RECO RD ASS GN T ISELE CT P URCH ASE- REPO RT-F LE ASSI GN T o; 'S YS02 7' U N IT- RECO RD
1
2
1
1
540R
'UNi t;.:
' i
i
1
;
1
1
;
j
40 3
uInit
;
•
!
1
!
'
' i
1
1
;
;
'
i
1
:i
-0-lCONT ROL !appl Y LA ST-L NE TO F ORM- OVER FLOVi ON P URCH ASE- REPO RT-F LE. .
1
1
!
1
1
!
i
;
1
;
I
'
1 1
1
'
1
1
Example— Environment
FIGURE 3.4.
Division
sentences or paragraphs but must begin at the margin.
B
iB 28
24
20
16
12
File Control Paragraph Select Statement The SELECT entry must begin with the word SELECT and must be given for each file referred to by the COBOL source program. A separate SELECT statement is required for each file named in the Data Division. File name. The unique name of the file assigned in the File Description entry in the Data Division of the source program. This name will also be used in entries in the Procedure Division.
32
ENV IRON ME NT D V S ON N SE CT ON CONFil GUR AT SOURJCE-C OMPU TER F40 BM- 36 OBJE!CT-C OMPU TER BM- 360 D30 I
I
I
I
I
I
.
!l
.
FIGURE 3.5.
Example— Configuration
Section
npu1t-ou TPUT SEC T ON F leI-con TROL ISELE CT E XPEN SE-F UT L TY 2400 ISELE CT F XPEN SE-L 1
1
.
1
1
1
1
1
1
1 ' 1
S
YSOO 5'
FIGURE 3.6.
.
LE, ASS UN T ST, ASS
1
1
GN
TO
GN
TO
SYSO 04'
.
1
UNI T-RE CORD
Example— Input-Output
'
1
1
1
NO.
000 00000
000
111111111111111111111111111111
PAYMENT DATE DATE AMOUNT D'COUNT NET M D Y M D Y INVOICE
«
41
42 43 44 4; I!
222222 222222222222222222222222222222 222 22222 22222
oooo'oo
O'O 010
a
4(4; 4; 4141 4a 4S^ y\i; S3k4
11111 11111
n
111
1
a»
111
SI SI
11
I
1
1
OlO UlU U'U
1
ill
ill
I
I
!^C til I
2 2|2 2J2
ooooloo i7|«
1
1
1
U I
If 71
I
00
OI3 (,0
?4 75 7»
1
1
1
7l|«
|/l
Ijl 'I'
1
I
2222
2222I22
3
3333
3333|33
4 4I4 4|4 4
4444
4 4 4
2 2 2 2 2|2 2 2 2|2 2|2 2
I
333333 3333 33333 33333 3333333 333333333 333 33333 33333 33I33P3
3 3 3
3 3
3J3
3J3 3J3
444444 44444444444444 444444444444444
4
444 44444 44444
4 4.4
555555 5555555555
5
555 55555 55555
5 5I5 5|5 b 5 5 5 5|5 5 5 5|5 5|5 5
4 « 4 4 4I4 4J4
4|'4
4
I
55 55
5
555555555555
I
55
EEE6ES EEEEEEEEEEEESEEBEEEEEEEEEEEEE6
E
E 6 E
EEEE
7 7 7 7 7 7 7
77 77
E E
777777 777777777777777777777777777777
7
7
118 18
8
S 8
EE
I
I
18
8 8 8 8 8
88 888
88888
G
EEEEi
EEGEIEG
7
7777,
77 77|7
7
888
8
I
I
I
E5,G E|GE
E G E E|E G
7 7|7 7'7 7 7 7
7
7
eb'egJe 7
7I7
7J7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
5555
5555I55
7J7
8 8l8 8,8 8 8 8 8 8'8 8 8 8|8 8|8 8 8 8 8 8
8J8
999999 999999999999999999999999999999 999 99999 99999 I
I
]
1
9
t
7
in?
s 10
I
13
H n
II
II
't
«
»
21
;? 13
N n :t
I'
n
>< ic 3p
Ie
M P L OYEE -
toz :o2 :o2
1
DE NT
1
F
1
CAT ION
3]
m
js 31 31 31 )! in 41
4.-
Example— Record
FIGURE 5.5B.
01
;
« 44
4^ 4i 41
U VR
I!T EI
head NG-IlI N!EH3 I
ADIvlAlNlclllNy
II lAlFlTklR,
!
iLlllNlE'sr
Izi
1.
2. 2.
When
an end of volume is reached for multiple volume files, such as tape files, volumes are is rewound and the next reel normal standard header and trailer
switched, the tape is
written. All
labels are written. 3.
4.
An OPEN
statement must be executed prior to first WRITE statement for
lN"rEGER
After a record has been released, the logical record named by the record name is not longer avail-
statement, the
If
The
file
7.
FD
entry in the Data Division
When
WRITE
a
statement
the
FROM
option
is
used, the data-name-1
must not be the name of an item in the file containing the record name. The FROM option converts the WRITE into a MO\T and WRITE statement. Data-name-1 must be the name of an input area or working-storage area. Moving takes place according to the rules of the statement without regard to the CORRESPONDING
MOVE
the
AFTER
0, 1, 2,
or 3 only.
Data Name If a data name is used as an option, the name represents an independent item whose value determines how the forms will be spaced or skipped. The picture must be X. Permissable values and interpre-
tations are as follows: Value
Interpretation
blank
Single spacing
(zero) -
Double spacing
(hyptien)
+ 1
When
WRITE
3 designates triple spacing.
Triple
(plus) tlirougli
option. 8.
used as the option in the
is
executed, the record name record is released to the output device. The format requires the record name rather than the file name.
When
is
number must be unsigned and must
designates a carriage control eject-skip to channel 1 of the ne.xt page. 1 designates single spacing. 2 designates double spacing.
name must
associated with the record
be defined in the of the program.
an integer
have a value of
ment.
6.
The output record must contain one more byte than the capacity- of the printer. For example 133 bytes are required for a 132 position printer. The extra byte must be the first byte of the output area whose picture is X defined in the record description entn,- as FILLER. The compiler will generate instruction to insert the appropriate carriage control character as the first byte of the record.
the execution of the the file.
able for processing. All necessary processing of a record must be done prior to the WRITE state5.
stacker 8
B. Printing Operations (After Advancing).
!
Example—Write Statement
FIGURE 6.14.
of
spacmg
Suppress spacing
9
Skip
to
channel
1
through 9
re-
12
re-
spectively.
option
is
used, the
acter in each logical record of the
first
file
char-
must be
A.
B,
C
Skip
to
channel
spectively.
10,
11,
Procedure Division
57
Close
CLOSE
The
statement terminates the processing of one or more data files and releases the areas that serve as buffers for those files.
7
r
CLOSE
aj
r=-
[R EEL
r file-name
[^UNIT 1^
FIGURE 6.15.
ACCEPT data-name
1
FIGURE 6.17.
J
J
A CLOSE
2.
Format— Accept Verb
to 80 characters of data may be obtained from the systems input device ( diskfile, tape drive, card reader, etc.). The data must be punched into a card and entered into the computer together with the job control cards at the time the object pro-
may be executed only for been previously opened. When applicable, the end of file labels (trailer labels) are written and the file is positioned at
gram
to be executed. same input or output device is specified for the READ and ACCEPT statement, the result may be unpredictable.
statement
that have
files
FROM CONSOLE ]
L Up
Format—Close Verb
Rules Governing the Use OF THE Close Statement 1.
[
Rules Governing the Use OF the Accept Statement
I I
console.
|
fwiTH NO R EWIND *] ^ WITH LOCK J-Z. J
I
Accept The ACCEPT statement obtains low volume information from the systems logical device or from the
If
2.
is
the
the beginning. 3.
The
and Output) are not
optional clauses (Input
written for
ACCElPT c|urreInt-dIate FIGURE 6.18.
I
in the WorkingStorage Section of the Data Division. The data to be moved will come from the leftmost positions of the input block. When the CONSOLE option is used, as
UNIT
option is specified (REEL or UNIT are interchangeable COBOL reserved words) for an input or output file, the reel of the file will be closed prior to its normal end. If the reel is a part of an input file, no checka. ing of ending labels will occur. If the reel is the last of a file, an error may result at object time since no end of file will occur. b. If the reel is part of an output file, the standard end of reel processing will take place immediately. c. For both input or output files, if neither LOCK or option is specified, the reel will be rewound. If the option is used, the current reel is not rewound. If the LOCK option is used, the current reel is not rewound, employing a technique insuring that the file cannot be written upon or read from. If the REEL or UNIT is not specified for an input or output file, the following will prevail for the various options. If the CLOSE statement is specified without a. any option (neither or LOCK), there is an impHed rewind of the current (final) or
NO REWIND
NO REWIND
5.
NO REWIND
reel.
b.
FROM
5.
many
72 characters are accepted from the console keyboard. The ACCEPT statement causes a message code followed by "awaiting reply" to be automatically generated. The operation is suspended until the operator types the same message code and necessary information for the program. The message code serves as a key in the control program to correlate the console input with the proper program.
If
the
LOCK
reel will
option
is
used, the current (final)
be rewound instructing that
be read or written upon.
it
cannot
as
Display
The DISPLAY statement causes the writing volume data on the systems
of
low
logical output device.
(data-name"\ f oPON CONSOLE 1 literal j •-. UPON SYSPONCh I
FIGURE 6.18A.
J
Format— Display Verb
Rules Governing the Use of the Display Statement 1. As many as 120 characters may be written on
NO REWIND
If the option is written, the current (final) reel will remain in its current
position. c.
Example— Accept Statement
The data name wiU be described
Example—Close Statement 4.
REEL
.
I
3.
FIGURE 6.16.
If
from| con|sole|
SALES- STAT ST CS.
iCLOSE
4.
|
files closed.
2.
device ( disk file, tape unit, printer, punch, etc. ) the same input or output device is used for both the WRITE and DISPLAY statement, the output resulting from the statements may not be in the sequence in which the statements were encountered. If
1
Procedure Division
58
iD
I
SP LAY
G rv E
CU RRENT DA TE'
UPON CON SOLE FIGURE 6.18B.
Format
Example— Display Statement
(data- nameliteral ( figurative-constant
MOVE
' numeric or an elementary
either
report item.
PURCHASE -JQUAnH"! T nto total-cost, givi'ng uIn t-Ic ostI.
IdiVIDE
I
I
Example—Divide Statement— Into and
FIGURE 6.44.
Giving Option
MULTIPLY QUANTITY BY PRICE GIVING AMOUNT .
FIGURE 6.41.
5.
6.
Example— Multiply Statement— By and
6.
Data-name-3 may represent an elementary' numeric item or an elementar\- report item.
7.
Data-name-1 or numeric-literal-l serves as the divisor and data-name-2 or numeric-literal-2
Giving Option
Data-name-1 and data-name-2 must represent elementary numeric items. The calculated product replaces the value in data-name-3 and is edited according to the
serves as the dividend. 8.
replaces the original value of datais
edited
according to the items
picture.
items picture. 9.
In both
by zero
Divide
The DIVIDE statement
The quotient name-3 and
specifies
the
division
of
one numerical data item by another and using the result to replace the value of an item.
In
all
Into and Into
SIZE
& Giving )
ERROR
four arithmetic statements,
ING by
(
results in a
is
if
the
a division
condition.
word GIV-
not used, the last operand (one replaced
result)
may
not be a Hteral.
Procedure Division
65
Comput-e statement specifies the use of an expression, a data-name, or a numeric
arithmetic literal
The COMPUTE statement permits most arithmetic operations to be performed in much the
COMPUTE
The
same manner
as specifying arithmetic verbs.
for a series of arithmetic operations.
Rules for the sequence of calculation of arithmetic expression containing a combination of operators. 1.
Parenthetical arithmetic expressions are calculated
2.
All exponentiations are
3.
Multiplication
4.
Addition and subtraction are performed last from
first.
I'data-name- 2
COMPOTE data-name-l
(
RODNDED
]
numeric- literal \ floating-point-literal ^arithmetic- expression
=^
from [ON SIZE ERROR imperative statement.
. .
left
FIGURE 6.45.
left to right.
to right.
Format—Compute Verb
Rules Governing the Use of THE Compute Statement
The
arithmetic expression can consist of any meaningful combination of data-names, numeric
1.
performed next. and division are calculated next
the figurative constant zero joined following operators: literals,
Operator
by the
Sequence Control Verbs The SEQUENCE CONTROL statements are designed to specify the sequence in which the various source program instructions are to be executed. Statements, sentences and paragraphs of the Procedure Division are executed normally in the sequence in
which they are written except when one of these sequence control verbs is encountered. Four verbs
Aritlimetic Function
+
Addition Subtraction
o
* Multiplication
/
Division
**
p-1.
Exponentiation
H H^ !C0MP 1
UTE CAPA C TY = UT L RAN GE 4 CON SUMP T ION (
1
1
(
1
SP AN) / FF IC ENC Y)
yelRFloRU p-3
1
|
I
«
TY *
^Ha'-I
E
multiplication
1
.
P-2,
P-Z,
P-3.
p-3.
P-4.
P-4.
division
^
COMPUTE CAPACITY = (UTILITY • SPAN) \/ (RANGE + CONSUMPTION • EFFICIENCY)
\
addition
FIGURE 6.46.
2.
3.
/
multiplication
Example—Compute Statement
Operators are preceded and followed by spaces. When the data-name-2 or numeric literal option operais used, the result is the same as a
MOVE
tion. 4.
The value be written
of the result of the calculation must to the right of the equal sign as the FIGURE 6.46A.
item represented by data-name-l. 5.
6.
7.
Data-name-l must be either an elementary numeric item or an elementary report item. The calculated value is placed here and is edited according to the items picture. Data-name-2 must represent an elementary numeric item. The ROUNDED and SIZE ERROR options apply also to the
COMPUTE
statement.
Differences—Co To and Perform Verbs
used for procedure branching operations. The GO TO and PERFORM interrupt the normal sequence and transfer control to another point in the program. The ALTER verb is used to modify a branch instruction and the STOP verb is used to halt the execution of the program. are
verbs
1
]
Procedure Di\tsion
66
GO TO
nth Control is transferred to 1st, 2nd procedure name as the value of the data- name
2.
GO TO
statement provides a means of transferring control conditionally or unconditionally to another point in the program. The PERFORM also
The
is
Igo
I
GO TO
2
1,
The data-name must have ing at one and continuing
3.
x,[
t|o
y,
a range of values start-
successively upward.
dIepenIdingI
|z,
on Istat|us.
procedure-najne. Example
FIGURE 6.50. FIGURE 6.47.
—Go
To
Statement— Depending on Option
Format—Go To Verb
data-name has a value outside of the range through n, no branch occuj's and control passes to the next statement after the GO TO If the
4.
of
causes a branch out of normal sequencing but in addition provides a retiu-n back to the program.
1
statement.
In a branching operation, after the transfer to the particular point in the program is executed, normal flow of control is resumed at the begin-
Un'COXDITION'AL 1.
A in
procedure-name (name of paragraph or section Procedure Division) must follow the GO TO
ning of the particular procedure.
statement.
Alter
The
ALTER
statement
of an unconditional !go
t-o
compare -tr!ansajct on -NUMBER;S
FIGURE 6.48.
2.
I
is
used
to
modify the effect
GO TO
statement elsewhere in the program, thus changing the sequence of operations to be performed.
.
Example—Go To Statement— Unconditionally
If the procedure-name is omitted, a paragraph must be assigned. The paragraph name must be the only name in the paragraph and must be modified by an ALTER statement prior to the
ALTER {procedure-name-l
I
|
I
I
TO PROCEED TO procedure-name-2 }
I
L
|
J
GO
3.
TO statement. execution of the TO If the procedure-name is omitted and the sentence is not preset by an ALTER statement prior to its execution, erroneous processing will
GO
occur. 4.
The final
5.
A
GO TO
statement can only be used as the sentence in the sequence in which it appears.
procedure-name may be the name
FIGURE 6.51.
Rules Govterning the Use OF THE Alter Statement 1.
A GO TO in
a
of the pro-
GO TO
Depending On (Condifional Go To) The DEPENDING ON option permits multiple branch types of operations according value of a data name. 1.
statement to be altered must be written paragraph consisting solely of the
single
statement is part of. It is permissible to branch from a point in the program back to the beginning of the procediore.
cedure that the
Format—Alter Verb
The data-name must have
a
ALTER STEP-1 TO PROCEED TO PROCESS-2. STEP-1.
•
to the current
positive
GO TO PROCESS- 1. •
integral
ALTER STEP-1 TO PROCEED TO PROCESS-2.
value.
STEP-1.
GO TO.
JGO TO procedure- nameI
(procedure-name- 2.
..
I
DEPENDING ON data-name FIGURE 6.49.
Format— Go
To Verb Depending On Option
In both cases, when STEP-1 is executed, an unconditional branch is taken to PROCESS-2.
FIGURE 6.52.
Example— Alter Statement
k
Procedure Division unconditional
67
GO TO
statement preceded by a
If
paragraph name.
The ALTER statement replaces the procedure name specified in the GO TO statement (if any) by the procedure name specified in the ALTER
2.
procedure-name-2
control
the procedure-name-2 paragraph section.
When
procedure-name-2 is specified, the relaof procedure-name- 1 and procedurename-2 must exist. Execution must proceed from procedure-name- 1 throughout the last statement of procedure-name-2. GO TO and PERFORM statements are permitted between procedurename- 1 and the last statement in procedurename-2 providing that the sequence ultimately returns prior to the final statement in procedurename-2. tionship
statement.
Perform
The PERFORM statement provides a method of temporarily transferring control from the normal sequence of procedure execution in order to execute
The
7.
PERFORM
is specified and is a section, transferred after the last statement of
is
last
statement referred to must not contain
an unconditional GO TO statement. If the logic of the procedure requires a conditional exit prior
procedure-name
Format—Perform Verb
FIGURE 6.53.
P-2.1 EXI T
some other procedure a specified number
of times,
FIGURE 6.55.
At the conclusion of the execution, control is transferred back to the statement immediately following the point from which the transfer was made. PERFORM has several different formats which or until a condition specified
is
vary in complexity. In the simplest form, the procedure referred to is executed once each time the PERFORM is encountered. Other formats provide repetitive execution using one or more optional controls to control the "looping."
Governing the Use of THE Perform Statement
satisfy the requirement. sists
solely of a
EXIT. 8.
The procedure-name may be either a paragraph or section name. The word SECTION is not required.
9.
Rtjles
The procedure-name must not be is
10.
performed, the PERFORM transfers the sequence control to the first statement of Procedure- 1 and also provides for the
11.
return of the control. The point at which the control is returned to the main program depends on the structure of the procedure being executed.
12.
When
a procedure
EXIT verb is used to An EXIT statement conparagraph name and the word
to the last sentence, the
a procedure of
1.
Example— Exit Statement
satisfied.
is
name
the
PERFORM
of
statement
a part.
A
procedure-name can be referenced by more than one PERFORM statement. Procedures to be performed can be outside the main program or can be part of the main routine so that they can be executed in line. A referenced procedure may itself contain other
PERFORM 13.
which the
statements.
All procedures
which they are
must be arranged to be performed.
in the
order in
IpERfIoRM NET-lpAY-ICALc!uLATl| 0N~ FIGURE 6.54.
Simple Perform
Example—Perform Statemenf
In a simple 2.
If
Procedure-Name- 1
a Procedure-name-2
3.
4.
is
a paragraph
name and
not specified, control is returned immediately after the last statement of the procedure-name- 1 paragraph. If procedure-name- 1 is the name of a section and procedure-name-2 is not specified, control is returned after the last statement of the prois
cedure-name- 1 section. If procedure-name-2
is
control
option the procedure ref-
is
PERFORM specified,
PERFORM
executed once and then control passes to the next statement after the PERFORM statement. All statements in paragraphs or sections named in procedure name-1 (through procedure name-2) con-
erenced
procedure-name- 1
THRU
procedure-name-2
is
transferred after the last statement or procedure-
name-2 paragraph.
FIGURE 6.56.
Format—Perform Verb—Thru
Option
1
1
Procedure Division
68 stitute the
range and are executed before control
data-
If
is
name
is
used,
it
must have an integral
value.
returned.
The data-name
or the
number must have
values. If the value of the data- name
THRU MAJOR-TOTAL. Example— Perform Verb—Thru
Times The TIMES option provides
Option
4.
|
Format—Perform Verb— Times
The number formed name.
is
as
used, a counter
is
UnHI The
UNTIL option operates in the same manner Times option with the exception that no counting takes place and the PERFORM causes an evaluas the
of times the procedure
specified
is
name-1.
Option
Rules Governing the Use OF THE Times Option 1.
option
PERFORM
|
J
FIGURE 6.58.
TIMES
the
process is repeated until the value of the counter is equal to the number of "times" specified. At that point control is passed to the next statement following statement. An initial value of zero will cause no execution of procedure-
I
L
When
up and this counter is tested against the specified number of execute (times) before control is returned to procedure-name- 1. The counter is incremented by one after each execution and the
|
/-integer ^v procedure-name- 2 ]\.data-naineyTIMES [ THRU
I
Option
set
PERFORM.
I
I
Example—Perform Verb—Times
FIGURE 6.60.
a
PERFORM procedure-name-
i
zero or
PERFORM MONTHLY-INTEREST 3 TIMES. PERFORM CREDIT-CARD-ISSUE NO-OF-COPIES TIMES.
means for performing a procedure a repetitive number of times and then returning the control back to the next statement after the
positive
negative, control is transferred immediately to the next statement following the PERFORM.
Iperform minor-total
FIGURE 6.57.
is
a
number
is
to
or as
be pera
data
PERFORM procedure-name[
THRU procedure-ncime-2]
UNTIL test-condition POSITIVE
MOVE ZERO, TO 'COUNT
1
ZERO OR NEGATIVE
FIGURE 6.61.
Format— Perform Verb— Until
Option
ation of a specified test condition instead of testing
'
the value of a counter against a specified
PERFORM PROCEDURE ONE TIME
number
of executions.
•
1
ADD
1
TO "count"
FALSE
PERFORM PROCEDURE ONE TIME
YES
TRUE next aentence FIGURE 6.59.
next aentenae Logic
Diagram—Perform Verb— Times
Option
FIGURE 6.62.
Logic
Diagram— Perform Verb— Until
Option
Procedure Division
69
Rules Governing the Use OF THE Until Option 1.
The
test condition
may be
compound
a simple or
MOVE
INITIAL VALUE TO BASE ITEM
expression. 2.
The
is evaluated before the speexecuted. If the test condition is true, control passes to the next statement after the statement. The specified procedure is not executed.
test
cified 3.
condition
procedure
is
EVALUATE
PERFORM
\
FALSE
.
n
^TEST-CONDITION/
PERFORM PROCEDURE ONE TIME
INCREASE VALUE OF BASE ITEM BY SPECIFIED AMOUNT
-H
naxt eentanae
Iperf
ORM PART -PRO CESS UNT L CONT ROL- NUMB ER S EQ UAL TO
1
1
1
FIGURE 6.63.
Example—Perform Verb— Until
74
FIGURE 6.65.
.
Diagram— Perform Verb—Varying
Logic
Option
Option
ing upon whether the
BY
value
is
positive or nega-
tive.
the condition
not true, control transfers to
4.
If
5.
procedure-name- 1 The process is repeated until the is determined to be true.
is
condition
test
2.
3.
The specified test condition may be simple or compound. The data name is set to the specified initial value FROM ) when commencing the PERFORM state(
ment. 4.
Varying The Varying option
is used to PERFORM a procedure repetitively, increasing or decreasing the value of a data name once for each repitition until a
specified condition
is
Then
test-condition-1
condition
(UNTIL).
evaluated
It
immediately following the PERFORM statement and no execution of the procedure takes place.
satisfied.
iPERF
PERFORM procedure-name-l VARYING data-name-1
(
THRU procedure-name- 21
/
UNT
1
AFTER data-naine-4
Z 1
>ERF ORM 1
BYrnumeric-literal-3-\ / vdata-name-3
ORM UNT
V
,
A
L
ARYI NG A 1
S
E
FRO M
QUAL TO
1
1
1
BY
1
.
FROM /-numeric- literal- 2 ^ ''data-ncune-2
[
is
true, control passes the next statement
is
ONTIL test-condition-1
V A
L
ARY NG A FRO M BY S G REAT ER T HAN 0. 1
1
1
1
1
1
FROM rnumeric-literal-U-t \data-naune-5
Z, 1
Iperf ORM
J
UNT
1
Z 1
V
,
A
L
ARY NG A FRO M 0. S E QUAL TO 1
BY
1
»
1
1
1
1
BYrnxjneric-literal-e-y / \data-naine-6
UNTIL test-condition- 2
1
IPERF ORM Z
UNTI
FIGURE 6.66.
FIGURE 6.64.
UNTIL test-condition-3
A FRO M QUAL TO 0.
ARYI NG 1
S
E
1
BY
1
,
1
Format— Perform Verb—Varying
Example— Perform Verb
—
Varying Option
1
Option
is
Rules Governing teie Use OF THE Varying Option
The option may be used to increment or decrement the value of one or more data names depend-
the statement is false, the procedure specified procedure-name-l through procedure-name-2 executed once. The BY value is added to data
If
in
1.
A
FROM (-numeric-literal} \data-name-8
[AFTER data- name-
BYrnumeric-literal-gA / ^data-name-9
V
.
L
name-1 and again causes the test-condition-1 to be evaluated. This process continues until the conditional expression is found to be true. Thereupon control passes to next statement after PER-
Procedure Di\tsiox
70
FORM.
FROM
clauses mvist in the BY and represent numeric values but need not be integers: such values may be positive, negative or zero.
The items used
SET
•
•
•CATt-NAKE-l ANC> TO
• CATA-NAt FALSE Ttrue '
ll
F
!l
F
TO 27. ERVI CE-C ODE S E QUAL ADD 5 00 TO AMOU NT D UE S NOT GREA TER THAN C ALL- T ME TO MINI MUM, MOV E 'B ASE RATE S
1
MOVE 8 TO GREATEST
,
1
1
MOVE C TO GREATEST
'
LEGE ND.
i next eentence
^-^ i
I
1
1
l_i
{ FINAL
RESET ON
tion in the print line
I
clause pre-
FIGURE 7.14.
Format— Sum
Clause
be
omitted, or not
may be the counters defined in the same re-
Working-Storage or Linkage section or
name COLUMN integer
I
of their
sum
port. All arithmetic rules apply to a summation; Dataname-l and data-name-3 may not be subscripted.
Format—Column
FIGURE 7.11.
Clause 1.
specified, the data item will not
be printed. Integer
2.
When Two
the
SUM
clause
is
specified,
items are defined, one is within Print Line and the other is a sum counter. The counter contains the sum of all data names specified in the clause.
SUM
SUM
specifies the leftmost print position. 3.
SUM
When
the report group containing the clause is printed, the value from the clause is moved to print line unless the sum counter has a data-
SUM
Group indicate The GROUP INDICATE
clause specifies that the data item being defined is to be printed only after the control break. This clause can be specified only within a Detail Group description.
name. The data-name names the sum counter; not the data item in the print 4.
SUM
The
line.
summation of
clause causes automatic
data. 5.
GENERATE
statement refers to a group, the report group is executed, the values of data-name-l, etc. are added to the sum counter unless the option is used. When the UPON option is used, the values in data-name-l, etc. are added to the continuously when the GENERATE referring to a
DETAIL REPORT
GROUP INDICATE
I
Whenever
L
UPON
FIGURE 7.12.
Format— Group
Indicate Clause
SUM
Source
SOURCE
data-name-2
used to move source data to the data item being defined. The move is performed in accordance with the rules of the MOVE verbs.
The
clause
is
6.
The
is
executed.
values of data-name-3, etc.
(names of other
source entries) are added to this sum counter when the report group(s) containing these sum counters are printed. 7.
SOURCE data-name
I
L
After the report group containing a sum counter has been printed, the sum counter is reset to zero unless a
FIGURE 7.13.
Format—Source
Clause
8.
RESET clause refers to RESET option is specified, it.
the
the normal
automatic resetting of the counter is overridden and the counter is reset to zero only when a control break occurs as specified in the RESET clause.
Data-Name Data-name is the name of data item being moved. The name must be defined in the File, WorkingStorage or Linkage Section. The data-name can be
When
Page Counter
PAGE- COUNTER
qualified or subscripted.
by the compiler
to
is
name
a fixed data
be used by the report
specified
v^Titer.
Sum The
SUM
tion of data
FOOTING
clause
is
used to cause automatic summa-
and may appear only in the report group description.
CONTROL
Rules Govterning the Use OF THE Page Counter 1.
ER Data-Names The data-names following the items to be summed and
is
PAGE- COUNT-
2.
PAGE- COUNTER may be
3.
dure Division Statements. One page counter for each report.
SUM
are all the word are defined in the File,
a new page is started, incremented by one.
Each time
referred to
by Proce-
)
Report Writer Feature
90 4.
5.
When more
than one report description entry appears in the REPORT section, PAGE- COUNTER must be quaUfied. Initially the counter is set to one. If any other starting value is desired, it may be set by a statement in the Procedure Division after the INITIATE statement has been executed. PAGECOUNTER is incremented automatically there-
r
1
INITIATE report-name ...
I
|
L
J
FIGUR{ 7.16.
Format— Initiate Statement
Report— Name ( s These are the names of the various reports that are to be started. They must be defined in the Report
after.
Description Entry in the Report Section of the Data Division.
Line Counter
The
LINE-COUNTER
name
a fixed data
is
One INITIATE
gen-
2.
3.
is
required for each re-
The INITIATE statement does not open the file with which the report is associated. An OPEN statement must be given prior to the INITIATE statement
Rules Governing the Use OF THE Line Counter 1.
statement
port name.
erated by the Report Writer and is used to determine when headings and footings should be produced.
for the report.
LINE-COUNTER may
be referred
to
by Proce-
dure Division Statements. When more than one report entry appears in the Report Section, the LINE- COUNTER must be qualified by the Report clause. The LINE-COUNTER is reset after every page. At any given time, the LINE-COUNTER represents the number of the last line printed or skipped
Generate
The
GENERATE
statement
is
used to produce a
report.
GENERATE data-name
I
L
to. 4.
The LINE- COUNTER
used by the Report is Writer for test and control purposes. Programmers should exercise caution when changing the value by Procedure Division statements as the ensuing format control may be unpredictable.
To produce
FIGURE 7.17.
Data-name can be the name of detailed report group or the name of a report.
PROCEDURE DIVISION
Rules Go\'erning Use of Generate Statement
a written report using the Report Writ-
1.
INITIATE, GENERATE and TERstatements must be used in the Procedure
er Feature, the
MINATE Division.
2.
A USE BEFORE REPORTING ment may be written the Procedure Division alter or
declarative state-
the Declarative Section of
in
the
if
programmer wishes
manipulate the data before
it
is
3.
to
printed in
the report.
I
4.
sect ion- name SECTION
.
detail line is produced, if the data name references a detail report group. No detail line is produced if data name is the name of report. The appropriate headings and/or page footings are produced. Specific control breaks are recognized in order Final, Major, Intermediate or minor and the appropriate headings and footings are printed. Updates and resets sum coimters on an associated control break.
USE BE FORE REPORTING data-name. Format— Use
is
used to end a pre-
viously initiated report. All control footings, page footings and report footings associated with the report are printed and the Report Writer fimctions are completed.
L
FIGURE 7.15.
A
Terminate The TERMINATE statement
I
I
Format—Generate Statement
Before Reporting Statement
Initiate
The INITIATE statement
[
is
used
counters before processing a report.
TERMINATE report-name.
L
to
initialize
all
FIGURE 7.18.
Format— Terminate Statement
I
Report Writer Feature
91
Rules Governing the Use of THE Terminate Statement Report-name is the name of the report 1.
5.
entry.
The
control footings are the same as if a control at highest control level.
break had occurred 3.
The
TERMINATE
statement does not close the
file.
4.
A CLOSE statement must TERMINATE statement.
be written
is
written for each
report.
as it appears in the Reports clause of the File Description
2.
One TERMINATE statement
for
the
USE BEFORE REPORTING-DECLARATIVE SECTION This statement is used to perform procedures immediately before the specified report group is processed. It can also be used to suppress printing of specified report groups.
Data-name
is
the
name
a report group other than Detail Report Group.
of
Report Writer Feature
92
OCOOOO OCOOIO C00C20 000C30 C00040 0COO5O CCC060 C00C70 000080 0C0C90 OCOIOO 000110 C00120 CC0130 C00140 000150 0C0180 OC0190 0CO20O 000210 00C220 000230 000240 000250 C00260 000270 000280 000281 000290 000300 0C0310 0C0320 OC0330 0C0340 CC0380 0CC390 0CO4OO 0C041O 0C0420 000430 000440 000450 000460 000470 C00480 CC0490 C00500 000510 000520 000530 CC0540 0C0550 000560 CC0570 000580 000590 000600 000610 000620 000630 000640 C00650 CC0660 C0C661
000670 CCC680 000690 0CC700 000710
IDENTIFICATION DIVISION. PROGRAM-IO. 'ACME*. INSTALLATION. ACME ACCOUNTING DEPARTMENT. REMARKS. THE REPORT WAS PRODUCED BY THE REPORT WRITER FEATURE. ENVIRONMENT DIVISION. CONFIGLRATION SECTION. SOURCE-COMPUTER. IBM-360 F50. OBJECT-COMPUTER. IBM-360 F5C. INPUT-OUTPUT SECTION. FILE-CCNTRCL. SELECT INFILE ASSIGN TO 'SYSIN* UTILITY. SELECT REPORT-FILE ASSIGN TO 'SYSPRINT' UTILITY. DATA DIVISION. FILE SECTION. FD INFILE LABEL RECORDS ARE OMITTED DATA RECORD IS INPUT-RECORD RECORDING MODE F. INPUT-RECORD. 01 FILLER PICTURE AA. 02 DEPT PICTURE XXX. 02 FILLER PICTURE AA. 02 NO-PURCHASES PICTURE 99. 02 FILLER PICTURE A. 02 TYPE-PURCHASE PICTURE A. 02 MONTH PICTURE 99. 02 DAY PICTURE 99. 02 PICTURE A. 02 FILLER COST PICTURE 999V99. 02 FILLER PICTURE X(59). 02 FD REPORT-FILE, REPORT IS EXPENSE-REPORT LABEL RECORDS ARE STANDARD. WORKING-STORAGE SECTION. SAVED-MONTH PICTURE 99 VALUE 0. 77 77 SAVED-DAY PICTURE 99 VALUE 0. 77 CONTINUED PICTURE X(ll) VALUE SPACE. FILLER. 01 RECORD-MONTH. 02 03 FILLER PICTURE A(9) VALUE IS 'JANUARY 03 FILLER PICTURE A(9) VALUE IS 'FEBRUARY FILLER PICTURE A(9) VALUE IS 'MARCH 03 03 FILLER PICTURE A(9) VALUE IS 'APRIL 03 FILLER PICTURE A(9) VALUE IS 'MAY FILLER PICTURE A(9) VALUE IS 'JUNE 03 FILLER PICTURE A(9) VALUE IS 'JULY 03 03 FILLER PICTURE A(9) VALUE IS 'AUGUST FILLER PICTURE A(9) VALUE IS 'SEPTEMBER 03 03 FILLER PICTURE A(9) VALUE IS 'OCTOBER FILLER PICTURE A(9) VALUE IS 'NOVEMBER 03 FILLER PICTURE A(9) VALUE IS 'DECEMBER 03 02 RECORD-AREA REDEFINES RECORD-MONTH OCCURS 12 TIMES. 03 MONTHNAME PICTURE A(9). REPORT SECTION. RD EXPENSE-REPORT CONTROLS ARE FINAL, MONTH, DAY PAGE 59 LINES HEADING 1 FIRST DETAIL 9 LAST DETAIL 48 FOOTING 52. TYPE REPORT HEADING. 01 LINE 1 COLUMN 27 PICTURE A(26) VALUE IS 02 'ACME MANUFACTURING COMPANY'. LINE 3 COLUMN 26 PICTURE A(29) VALUE IS 02 'QUARTERLY EXPENDITURES REPORT'. 01 PAGE-hEAD TYPE PAGE HEADING LINE 5. COLUMN 30 PICTURE A(9) SOURCE MONTHNAME OF 02 RECORD-AREA (MONTH). COLUMN 39 PICTURE A(12) VALUE IS 'EXPENDITURES'. 02 COLUMN 52 PICTURE X(ll) SOURCE CONTINUED. 02 LINE 7 COLUMN 2 PICTURE X(35) VALUE IS 02 •MONTH CAY DEPT NO-PURCHASES'. 02 COLUMN 40 PICTURE X(33) VALUE IS •TYPE COST CUMULATIVE-COST'. 01 DETAIL-LINE TYPE DETAIL LINE PLUS I.
FIGURE 7.19.
Example— COBOL Program
Report Writer Feature
Report Writer Feature 000720 0C0730 000740 000750 CC0760 000770 000780 000790 01 000800 000810 0CC820 OG0830 000840 000850 000860 000870 000880 01 000890 000 900
0C091O OC0920 0CC930 0C0940 0C0950 CCC960 0C0970 000980 OCIOOO 001010 001020 001030 C01040 OC1050 0C1060 C01070 001080 001090 001100 001101 001102 001103 001104 001110 001120 001121 001130 0C114O 001141 001150 001160 001161 00117C AOO A02 A02 AOl A04 A04 AOl AOl AOl AOl
AOl A03 A03
93
COLUMN 2 GROUP INDICATE PICTURE A(9) 02 SOURCE MONTHNAME OF RECORO-AREA (MONTH). COLUMN 13 GROUP INDICATE PICTURE 99 SOURCE DAY. 02 COLUMN 19 PICTURE XXX SOU?lCE DEPT. 02 COLUMN 31 PICTURE 19 SOURCE NO-PURCHASES. 02 02 COLUMN 42 PICTURE A SOURCE TYPE-PURCHASE. COLUMN 50 PICTURE ZZ9.99 SOURCE COST. 02 TYPE CONTROL FOOTING DAY LINE PLUS 2. 02 CCLUMN 2 PICTURE X(22» VALUE IS 'PURCHASES AND COST FOR* COLUMN 24 PICTURE 19 SOURCE SAVED-MONTH. 02 COLUMN 26 PICTURE X VALUE IS •-'. 02 COLUMN 27 PICTURE 99 SOURCE SAVED-DAY. 02 CCLUMN 30 PICTURE ZZ9 SUM NO-PURCHASES. 02 MIN CCLUMN 49 PICTURE $$$9.99 SUM COST. 02 02 COLUMN 65 PICTURE $$$$9.99 SUM COST RESET ON FINAL. LINE PLUS 1 COLUMN 2 PICTURE X(70) VALUE ALL '*'. 02 TYPE CONTROL FOOTING MONTH LINE PLUS 1 NEXT GROUP NEXT PAGE. COLUMN 16 PICTURE A(14) VALUE IS 'TOTAL COST FOR'. 02 COLUMN 31 PICTURE A(9) SOURCE MONTHNAME OF RECORD-AREA 02 (SAVED-MONTH).
01
01
01
02 COLUMN 40 PICTURE AAA VALUE 'WAS'. INT COLUMN 46 PICTURE $$$9.99 SUM MIN. 02 TYPE CCNTRCL FOOTING FINAL LINE PLUS 1. COLUMN 16 PICTURE A(26) VALUE IS 02 'TOTAL COST FOR QUARTER WAS'. 02 COLUMN 45 PICTURE $$$$9.99 SUM INT. TYPE PAGE FOOTING LINE 55. 02 LINE 57 COLUMN 59 PICTURE X(12) VALUE IS, 'REPORT-PAGE-', COLUMN 71 PICTURE 99 SOURCE PAGE-COUNTER. 02 TYPE REPORT FOOTING. 02 LINE PLUS 1 C3LUMN 32 PICTURE A(13) VALUE IS 'END OF REPORT'.
PROCEDURE DIVISION. DECLARATIVES. PAGE-HEAD-RTN SECTION. USE BEFORE REPORTING PAGE-HEAD. PAGE-HEAD-RTN-rwITCH. 60 TO PAGE-HEAD-RTN-TEST PAGE-HEAD-RTN-TEST. IF MONTH = SAVED-MONTH MOVE '(CONTINUED)' TO CONTINUED ELSE MOVE SPACES TO CONTINUED MOVE MONTH TO SAVED-MONTH. GO TO PAGE-HEAO-RTN-EXIT. PAGE-HEAD-RTN-SUPPRESS. MOVE 1 TO PRINT-SWITCH. PAGE-HEAD-RTN-EXIT. EXIT. END DECLARATIVES. OPEN INPUT INFILE, OUTPUT REPORT-FILE. READ INFILE AT END GO TO COMPLETE. INITIATE EXPENSE-REPORT. READATA. GENERATE DETAIL-LINE MOVE DAY TO SAVED-DAY READ INFILE AT END GO TO COMPLETE. GO TO READATA. COMPLETE. ALTER PAGE-HEAD-RTN-SWITCH TO PROCEED TO PAGE-HEAD-RTN-SUPPRESS, TERMINATE EXPENSE-REPORT CLOSE INFILE, REPORT-FILE. STOP RUN. 02 AOlOl 00200 01 AOlOl 00100 02 COlOl 01600 02 B0102 00200 10 A0102 01000 10 C0102 08000 02 B0105 00200 10 A0108 01000 08 B0108 01248 20 D0108 03840
06 C0329 04800 20 E0331 06000 10 G0331
0500C
FIGURE 7.19.
Continued
Report Writer Feature
94
—
&
ACME MANUFACTURING COMPANY
-QUARTERLY EXPENOTTURFS REPORT
^
JANUARY MONTH
DAY
DEPT
NO-PURCHASES
2 1
2
EXPENDITURFS TYPE
A A C
COST
CUMULATIVE-COST
2.00 1.00 16.00 On
AND COST FOR 1-01 $19. $19.00 tt**************-^*****i^*******************f******** ******* ************* ©== PURCHASES 5
JANUARY
02
AOl
2
B
A04 A04
10 10
A C
2.00 10.00 80.00
PURCHASES AND COST FOR 1-02
$92.00 22 $111.00 **^**itli^**^L^L*^tif************************ ************************* ******* JANUARY 05 AOl B 2.00 2
PURCHASES ANO COST FOR 1-05 $113.00 $2.00 2 *it*^***Hc**it'********************************iti************************** JANUARY 08 AOl 10 A 10.00 AOl 8 12.48 B AOl 20 38.40 PURCHASES AND COST FOR 1-08
JANUARY
13
AOO AOO
PURCHASES ANO COST FOR 1-13
$6n.8«
38 4
R
1
C
6.24 8.00
$14.24
5
$173.88
$188.12
«**i^*:^**4c*** ************************* ***4
'
!
.
^ULT IPLY CUS TOME RS sjo ^ PR INT- OUT.
1
\
i
B Y
1
:
•
POO,.
i
'
1
,
i
3.
00 G IV
IN
&R OSS.
G-
i
!
1 i
:
.
i
,
1 1
> •
i 1
!
'
1
!
.
1
i
i
:
i
.
'
i
1
1
;
i 1
'
'
i
IstVl
'
'•
1
1
:
1
!
>
i
i
I'^kl.
:
'
1
'
t
1
'
lU'UT
cIms TOME PR INT- 0|UT.
IPLY
&0 T Q
i
R$ & Y
?.
?0 G VIN (r 1
!
(t-P
i
0§S;. !
I i
• !
!
1
1
1
1
' ,
i
1 !
1
i
i 1
1
1
i
1
'
I '
1
i
1
1
1
:
j
1
'
'
I
t
' 1
;
t
iPERM -Vav t.r
'
> :
1
1 '
1
:
!
' 1 1
1 .
MULT IPLY cus TOME RS GO T PR NT- OUT.
B Y 4. 00 &
1
VIN G-
G-R
OSS.
1
1
]
'
'
i
1
FIGURE 11.2.
The Procedure Division can be
written as a series
of sub-routine paragraphs. This technique will permit
the programmer to write procedures in any sequence he wishes. Each procedure will be referenced by a procedure name thus allowing the programmer more flexibility in the writing of the program. A GO TO statement at the end of each paragraph directs control of the program. The disadvantage of using this approach is that these paragraphs cannot be referred to by a PERFORM statement as each statement ends with a GO TO statement which is invalid for the PERFORM statement. This disadvantage can be overcome through the use of an EXIT paragraph at the end of each procedural series of paragraphs. Since the last statement in the Procedure Division denotes the end of the source program, it is imperative that all divisions remain in the proper sequence.
Example—Subroutines
sequence is disturbed, many diagnostic errors be generated unnecessarily.
If the
will
Increasing the Efficiency of
Procedure Division Entries A program can be made more efficient in the Procedure Division with some of the techniques described below.
Intermediate Results statements as a up intermediate result fields to contain the results of these operations. The compiler can process complicated statements, but not always with the same efficiency of storage utilization as the source program. Because truncation may occur during compilation, unexpected
The compiler
succession
of
treats
operations
intermediate results
mav
arithmetic
and
occur.
sets
CoBOL Programming Techniques
141
Binary Data
Then
an operation involving binary operand requires an intermediate result greater than 18 digits, the compiler converts the operands to internal decimal before performing the operation. If the result field, is binary, the result will be converted from internal decimal to binary. If an intermediate result will not be greater than nine digits, the operation is performed most efficiently If
as binary data fields.
COBOL
Library Subroutinies
COBOL
COBOL
30 Digits
number
the
ate result field
is
of digits in a decimal intermedi-
greater than 30, the field
is
truncated
A
warning message will be generated at compilation time but the program flow will not be into 30.
A,
up the expression
as follows:
3 GIVING INTERMEDIATE-RESULT-A.
write:
DIVIDE
C
INTO
INTERMEDIATE-RESULT-A
GIVING
INTERMEDIATE-
RESULT-B.
Then compute
the final results
by
writing:
ADD INTERMEDIATE-RESULT-B, 27.600 GIVING
B.
Initialize arithmetic fields before using them in computation. Failure to do so may result in invalid results or the job might terminate abnormally.
Comparison Fields Numeric comparisons
are usually done in
Compu-
format therefore Computational-3 is the most efficient data format. Because the compiler inserts slack bytes which can contain meaningless data, group comparisons should not be attempted when slack bytes are within the group unless the programmer knows the contents of
tational-3
the slack bytes.
Move Statement
Intermediate Result Greater
When
Then
split
Arithmetic Fields
If a decimal multiplication operation requires an intermediate result greater than 30 digits, a library subroutine is used to perform the multipUcation. The result of this multiplication is truncated to 30 digits. library subroutine is used to perform A division if ( 1 ) the divisor is equal to or greater than 15 digits, ( 2 ) the length of the divisor plus the length of the dividend is greater than 16 bytes or (3) the scaled dividend is greater than 30 digits (a scaled dividend is a number that has been multiplied by a power of 10 in order to obtain the desired number of decimal places in the quotient).
Than
ADD
terrupted at execution time. This truncation the result to be invalid.
may
cause
Performing a move for an item greater than 256 bytes in length requires the generation of more instructions than are required for a move item of 256 bytes or less.
Open and Close Statements Each opening or closing of a file requires the use main storage that is directly proportional to the number of files being opened. Opening or closing more than one file with the same statement is faster of
On
Size
Error SIZE
ON
ERROR OPTION applies only to the final tabulated results; not to intermediate result The
fields.
A
method
of
avoiding
unexpected
intermediate
make critical computations by assigning maximum (or minimum) values to all fields and
results
is
than using a separate statement for each file. Separate statements, however, require less storage area.
For example,
to
analyzing the results by testing the critical computations for results expected. Because of concealed intermediate results, the final result is not always obvious. The necessity of computing the worst case (or best case ) results can be eliminated by keeping statements simple. This can be accomplished by spHtting up the
statement and controlling the intermediate results to be sure unexpected final results are not obtained. For example, COMPUTE B First define
=
(A
+
3)
adequate
/ C
+
i.e.,:
OPEN INPUT
FILE-A, FILE-B,
FILE-C. rather than OPEN INPUT FILE-A. OPEN INPUT FILE-B. OPEN INPUT FILE-C.
Accept Verb
The Accept verb does not provide
for the recogni-
from the card reader. When COBOL detects /* card it drops through to the next statement. Because no indication of this is tion of the last card being read
given by
27.600.
intermediate result fields
one statement
COBOL,
the end-of-file detection requires
Thus the programmer must provide own end card (some card other than /*) which
special treatment.
02 INTERMEDIATERESULTA
PICTURE S9(6)V999.
his
02 INTERMEDIATERESULT-B
PICTURE S9(6)V999.
he can
test to detect
an end-of-file condition.
CoBOL Programming Techniques
142
Recommended
Paragraph Names Paragraph names use storage when the PERFORM verb is used in the program. Use of paragraph names for
comments requires more storage than the use
coding,
MOVE A TO
B.
PERFORM ROUTINE.
of
Note or a blank card. Use Note and/or a blank card for identifying in-line procedures where para-
NOTE JOES-ROUTINE. ROUTINE. COMPUTE A = D + E
graph names are not required.
Some
a
For example, avoid writing the following:
MOVE A TO B. PERFORM JOES-ROUTINE. JOES-ROUTINE.
COMPUTE A = D + C
*
F.
programming techniques that will aid the programmer in preparing efficient programs have been explained and illustrated. Additional programming techniques will be found in the reference manuals of the computer manufacturers. It is hoped as the programmer becomes more proficient in COBOL programming, he will develop his own programming * F.
of the
techniques.
Name
T T T T T
F
F F F F
Section
1.
2. 3. 4.
5.
F F
6. 7.
Date
TRUE AND FALSE QUESTIONS: Encircle (T) TRUE or (F) FALSE. COBOL produces a program as efficient as one written in the basic language A problem should be properly defined before attempting to write a program. The Identification Division is the simplest of all COBOL divisions to write.
of the computer.
The name of the programmer must be included in the Identification Division. The Remarks paragraph of the Identification Division should provide pertinent information tive to the
T T
^
rela-
program.
The Environment Division The Environment Division
is
the only division in
COBOL
links the devices of the
that is problem oriented. computer system and the data files
to
be proc-
essed.
T
F
8.
The
T
F
9.
T
F
10.
names used
external device
the same
manner
in the
Environment Division are assigned by the programmer
in
as data names.
Any
special input and output techniques Environment Division.
The Block Contains even though there
should be defined
in the File
Control paragraph of the
clause should be included in the File Description entry in the
is
Data Division
only one record per block.
T
F
IL The programmer may use Value clauses age Section of the Data Division.
T T T
F F F
12.
Pictvu-e clauses
13.
An
14.
If a
to assign initial values to
an item in the Working-Stor-
may be used in conjunction with group items. may have a Usage clause of computational.
alphabetic item
data item
is
used
in a series of arithmetic operations,
it
is
advisable to define
it
in the
Work-
ing-Storage Section of the Data Division in the computational mode.
T T T
F
15.
F
16.
F
17.
The most often used verb written in the Procedure Division is the GO TO verb. The addition of one decimal position in the data sending field will save valuable time in the cedure Division in eliminating decimal alignment instructions generated by the compiler.
T
F
18.
When
Decimal alignment
fields of
is
performed by the compiler.
unequal length are involved
in a
Pro-
move, the compiler generates additional instruc-
tions.
T T
F F
T T T
F F F
21.
23.
The absence of a sign in an arithmetic field will never affect the efficiency of a program. The final result of an expression included in a conditional statement is limited to six decimal places. The Redefines clause permits the use of the same area for work areas for input files that are proc-
T T T T T T T T
F
24.
Alternate grouping of data does not increase the efficiency of the program.
F F F F F F
25.
A
19.
20.
22.
Conversion of mixed data formats does not increase processing time. To perform arithmetic calculations, Display data is converted to Computational-3 in system 360 computers.
essed concurrently.
F
26. 27. 28.
hexadecimal
D
F F
T T
F F
treated as a positive sign in a system 360 computer.
The Procedure Division may be written as a series of subroutine paragraphs. Truncation of an intermediate result may result in an error. 31. If a decimal multiplication requires an intermediate result greater than 15
level.
29. 30.
library subroutine
T T
is
Redundant coding of usage designation is avoided by using a computational mode at a group The Procedure Division should be written using the Environment Division as a guide. The Write statement references a file name.
is
digits,
a
COBOL
used for the multiplication.
32.
The On
33.
Failure to initialize arithmetic fields before using
34.
Numeric comparisons are usually performed
35.
A Move
Size Error option applies only to the final result.
them
in
computations
may
result in invalid an-
swers.
more
instruction for an item greater that
instructions than one less than
in the
150 bytes.
143
Display mode.
150 bytes
(system 360) require the generation of
T
F
36.
Opening and closing more than one statements for each
file
with the same statement
is
faster than using separate
file.
T
F
37.
T
F
38.
Open and Close statements require more storage than a statement that opens and closes more than one file. The Accept verb does not provide for the recognition of the last card being read from the card
T T
F F
39.
The use
40.
A
Separate
reader.
name for comments requires more storage may be used for identification of in-Une procedures.
of a paragraph
blank card
MULTIPLE CHOICE QUESTIONS: L
It is
than the use of a note card.
Encircle the letter next to the correct answer.
imperative that the programmer adopt techniques that wiU increase the efficiency of a
COBOL
pro-
gram because B.
COBOL COBOL
C.
The programmer
A.
takes
much more
time to write than other language.
does not produce a program as efficient as one written in the basic language of the particular
computer. is
normally not familiar with the computer machine language.
D. All of the above. 2.
Prior to wTiting a program, the following should
be available
to the
programmer.
A. Appropriate flowcharts. B. Source
document formats.
C. Output formats.
D. All of the above. 3.
The entries that are required A. The name of the program. B. The date the program was C. The Remarks paragraph.
in the Identification Division are
written.
D. All of the above. 4.
The Environment Division
contains the following sections.
A. File Section. B. Configuration Section.
C. I-O-Control Section.
D. All of the above. 5.
Some
of the sections that can
appear in the Data Division are
A. File Section. B.
Linkage Section.
C. Report Section.
D. All of the above. 6.
A Record
Contains clause should be included in every File Description entry in the Data Division because
The compiler will not be able to determine the record size. B. The compiler checks record counts with block sizes. C. The compiler checks the agreement of record count with count D. None of the above.
A.
7.
of
Record Description
entry.
Writing output formats in the Working-Storage Section of the Data Division provides the programmer with the ability to A.
Document
the program properly.
B. Define headings with appropriate
Value clauses.
C. Skip the writing of File Description entries for output D. All of the above.
144
files.
Name 8.
Section
The compiler generates
Date
instructions to
A. Align decimal points.
Perform insertions
B.
in fields of
unequal lengths.
C. Convert data to the receiving field format.
D. All of the above. 9.
To
increase the efficiency of a conditional statement involving an arithmetic expression,
A. Both fields should have less than three decimal positions. B. Perform the computation separately, then make the comparison.
C. Perform the comparison
first,
then compute the arithmetic expression.
D. None of the above. 10.
Alternate groupings of data can be accompUshed with the A. Redefines clause. B. Alter clause.
C. Exit clause.
D. None of the above. 11.
The value of an item is F2 F4 F6 F9 B. F2 F4 F6 D9 C. F2 F4 F6 C9 D. None of the above.
-2469, the Picture
is
9(4), the item will appear as (system 360 computer).
A.
12.
The Procedure Division
is
actually written
from the
A. System flowchart. B. Planning chart.
Program flowchart,
C.
D. None of the above. 13.
Numeric comparison
in the
System 360
is
usually done in
A. Computational format. B. Display format.
C. Computational-3 format.
D. None of the above. 14.
Each opening and closing of a file requires the use A. The number of files being opened. B. The number of hardware devices actuated. C. The volume of the data in the files. D.
AU
of
main storage
that
is
proportional to
of the above.
roENTIFICATION QUESTIONS: Column
Indicate in
1
column 2 the
letter that identifies the
item in column
Column 2
A
USAGE CLAUSE
Conversion
B
ENVIRONMENT DIVISION MIXED DATA FORMATS
Provide information to reader of program
PICTURE CLAUSE ALTERNATE DESCRIPTION
Soiu'ce
Elementary item Computational
H
DATA DIVISION INTERMEDIATE RESULTS COBOL LIBRARY SUBROUTINES
I
IDENTIFICATION DIVISION
Machine oriented Decimal multiplication
J
DECIMAL ALIGNMENT
Redefines clause
C
D E F
G
30
digits
Move
145
document format statement
1.
QUESTIONS FOR REVIEW 1.
2. 3.
Why
is
What What
it
so important to \\Tite
an efficient
COBOL
program?
additional information should be included in the Identification Division? precautions should be taken in writing the Environment Division?
5.
Why Why
should the Records Contains clause be included in every File Description entr\' in the Data Division? is it desirable to wTite Data Division entries for ouput files in the Working-Storage Section?
6.
When
should the computational mode be used with data items? could storage be conserved in decimal alignment?
4.
7. 8.
9.
How How
does the compiler align fields of unequal length? WTiat problem is caused by operation involving data items of mixed data formats?
How
can
this
be over-
come? 10. 11.
Explain the operation of sign control in the efficiency of a program.
Why
is it
possible to have an inaccurate answer as a result of an arithmetic statement in a conditional state-
ment? 12.
List the basic principles of effective coding.
14.
How may How may
15.
What
13.
is
alternate groupings provide a
more efficient program? more effectively?
the Procedure Division be written
the danger of intermediate results in arithmetic operations?
146
Problem
1
SHAMPOO PAYROLL PROBLEM In a beauty salon, operators are paid by the amount and type of work they do. The shampoo operators receive $1.00 per customer, the hair cutters receive $2.00 per customer, the hair setters receive $2.50 per customer, the styUsts receive $4.00 per customer, and the permanent
Given:
Operator's
Type
operators receive $5.00 per customer.
name
of operator
Number Find:
wave
of customers.
Gross Pay (Print and punch out also; name, type and number of customers)
INPUT Card Columns
Field
1- 25
Name
26 27- 29 30- 80
Type Customers Blanks
OUTPUT Card Columns
Field
1 -25 26 27 29 30 -34 35 -80
Name Type Customers Gross — Pay Blanks
FORMULA Gross Pay
=
rate x customers.
147
^
Problem 2
DEPARTMENT STORE PROBLEM Customer's name Customer's address Customer's account no. Last month's balance
Given:
Payments made
made
Purchases
on a card; Find:
Service charge (rate
Amount due on the printer
for
for this
1V2%) month
is
each customer,
in the
form of a
bill
including
all of
the above information.
INPUT Card Columns
Field
1-15 16-50 51-55 56-60 61-65 66-70 71-80
Customers name Customers address Account no. Last balance
Month
sales
Payments Blanks
OUTPUT Print Positions
Field
1-3 4-18 19-20
Blanks
Name
of
Customer
Blanks Address of Customer Blanks
21
-
56
-
55 57
58-62 63-64
Customer Account Blanks Previous balance Blanks
Amount due
65-71 72-73 74-80 81-82 83-89 90-91 92-97 98-99 100-106
Blanks
107
Sales this
month
Blanks
Months payments Blanks Service charge
Blanks
-
(EDITED) (EDITED) (EDITED)
(EDITED) (EDITED)
120
FORMULAS TO BE USED Service charge
Amount due months
=
=
.015 * (last-balance - payments) ( rounded (last-balance - payments) service charge
+
+
sales.
148
I
Problem 3
BANK BALANCE PROBLEM Given:
in
an 80 column card
Account number
Type code:
either a 1
punch
or a 2 punch:
1 indicates a checking account 2 indicates a savings account
Deposits
Withdrawals Last Balance
Find:
in
an 80 column card
Account number
New
balance
INPUT Card Column
Field
Account no. Type code
1-5
Blanks Deposits
7-8
6
9-16 17-24 25-32 33-80
Withdrawals Last balance Blanks
OUTPUT Card Columns
Field
Number
1-5
New
6-12 13-80
balance Blanks
FORMULAS
New
balance
Interest
New
=
=
Last-balance - withdrawals + deposits. - withdrawals + deposits) Last-balance - withdrawals + deposits + interest.
rate x (last-balance
balance
=
149
)
)
Problem 4
"AFRICA" PAYROLL PROBLEM a payroll is to be processed in the following manner: contains a master record for every employee in the company. Each record contains the employee's name, his number, the regular and overtime hours he has worked during the month, the wages he has earned so far this year, his rate of pay, and the number of dependents he has. The payroll is processed in the
Each month
A
card
file
NET
PAY. The results are used to^^rint checks usual manner: computation of GROSS-PAY, FICA, \VH-TAX and and to create new master records. These new records contain the new YTD-GROSS and zeros in the hours field (both regular and overtime). These new records create the CARD-OUT file which will be used next month as CARD-IN. (During the month the regular hours and overtime hours are added in by another program.) This company has a subsidiary in Africa whose employees, though US citizens, are not required to pay income tax. These employees have A's in front of their numbers— other employee numbers will have spaces in these character positions.
This program will use a table of income tax exemptions according to the
number
of dependents
which
looks like this:
DEPENDENTS
2 $112
1
$0 Subtract from
GROSS-PAY
The formulas which
$56
3 $168
to find the taxable
5 $280
4 $224
6 $336
7 $392
amount.
the program will use are:
In America: (overtime hours * iy2 rate). Gross-Pay (regular hours " rate) FICA = .03125 * gross-pay. (If YTD is less than $4800). (gross-pay - sub) sub is exemption according to dependents chart. WH-TAX .18 NET PAY gross-pay - FICA - WH-TAX. In Africa: Gross-pay = (regular hours " rate) + (overtime hours " IV2 rate).
=
= =
+
**
WM-TAX = 0. FICA = .03125 " gross-pay. (If YTD NET-PAY = Gross-pay - FICA.
is
less
than $4800).
Card-In Field
Card Columns
Employee Name Employee Number
1-29 30-39 40
Blank Rate
41-43 44-45 46-50 51-55 56-62 63-80
Dependents Regular Hours Overtime Hours YTD-Gross Blanks
(
xxx.xx
(xxx.xx) (
xxxxx.xx
Card-Ouf-
(same as Card-In) Print-Out Field
Print Positions
CHECK-LINE-1
Name
1-29
Blanks
106 114
Date
30 107
Blanks
115-120 150
-
8 $448
9 $504
10 $560
CHECK-LINE-2 Blanks
Net-Pay Blanks
1
-
91 97
-
1
-
30 32 42
-
-
90 96 120
CHECK-LINE-3 Employee Name Blanks
Employee Number Blanks Gross Pay Blanks
-
-
29 31 41 43
44-50 52 57
Wh-Tax
51 53
Blanks
58-59
PICA
60 - 64 65 - 66 67 - 73 74 - 120
Blanks
Net-Pay Blanks
-
Problem 5
SALES Commissions are paid
to
varies with the product sold
AND COMMISSION PROBLEM
salesmen based upon the number of units that are sold. The unit commission total commission is based upon the number of units sold of each particular
and the
product. Sales are determined
by the number
of units sold times the individual product selling price.
Given:
Product 1
jmmissuon Rate $
2 3 4 5
Selling
Price $ 16.00 30.00
.10
.20
43.00 60.00 75.00
.30 .40 .50
INPUT RECORD FILE Card Columns
Field Territory
Number
1- 2 3- 5 6- 11 12- 30 31- 35
Salesman Number Date
Name Units Sold
Product
Number
36
PROBLEM 1.
Prepare a table of commissions for the five different products so that the product number
itself will
serve as a subscript. 2.
Prepare a table of selling prices for the five different products so that the product number
itself will
serve as a subscript. 3. Write a COBOL program that will read both the commission table and price table and then process each data card to calculate the commission for each salesman. At the same time, prepare a report of the number of units sold and amount of sales for each product by salesman, by territory and an overall total of sales.
151
OUTPUT FORMAT Heading
Monthly Sales and Commission Report January 1969 Indicate
all
other information that you
would deem necessary such
as salesman's
name, month,
territory,
units sold, etc.
Problem 6
PAYROLL REGISTER PROBLEM Write a
COBOL
summary card with
program that
will calculate
and print the Payroll Register
as indicated.
the information as indicated.
INPUT RECORD FILE
Card Columns
Field
1-3 4-5 6-7
Month
Day Year
14-16 17-21 57-61 62-65 69-72 73-75 76-79
Department Serial
Gross Earnings Insurance
Withholding Tax State
UCI
Miscellaneous Deductions
Code
(letter
E)
80
OUT? UT RECORD PRINTED REPORT Field
Printing Positions
Heading Line 1
2 3
WEEKLY PAYROLL REGISTER
WEEK ENDING EMPLOYEE
SEP
40-62 40-62 3-14 22-26 51-61 65-69
3 1968
NO.
GROSS
WITHHOLDING STATE 4
2-6
DEPT. SERIAL
10-15 20-27 31-39 44-47 56-58 66-68 74-85 89-100
EARNINGS INSURANCE PICA
TAX UCI MISC. DEDNS.
NET EARNINGS 152
Also to punch a
Detail
Department
3-5
Serial
10-14
Gross Earnings Insurance
21-26 33-37 43-47 54-58 65-68 76-80 92-97
PICA Withholding Tax State
UCI
Miscellaneous Deductions Net Earnings
XXXX.XX XXX.XX xxx.xx XXX.XX xx.xx xxx.xx XXXX.XX
OUTPUT RECORD — CARD Field
Card Columns
Month
9-11 12-13 14-16 17-22
Day Department Number Department Net Earnings
Code (Character
—
80
CALCULATIONS
= Gross Earnings
1.
PICA
2.
Net Earnings
=
x .044 (round to 2 places)
Gross Earnings - Insurance
-PICA - Withholding Tax -
State
UCI -
Miscellaneous
Deductions. the
Net Earnings are zero
or negative, go to error routine.
3.
If
4.
The Department Earnings value
5.
Calculate totals for
all
is
the
sum
of the Net Earnings for each employee.
columns by department
as well as
an overall
total for the entire payroll.
Problem 7
UPDATED PAYROLL PROBLEM COBOL
to update a master tape file vi'ith a current card file. Both input files are in sequence. Input tape records are in blocks of ten 52-character records. The updated output tape blocks will be the same size.
Write a
Social Security
program
Number
The exception
shall
list
be double spaced.
INPUT TAPE RECORD Positions
Field
Employee Name Social Security
6
-
25
26-34 35-41 42-47 48-52
Number
Old Year-to-date Gross Earnings Old Year-to-date Withholding Tax Old Year-to-date PICA 153
INPUT CARD RECORD
Card Columns
Field
1-2 3-5
Department Number
Number
Clock
Social Security
26-34 62-68 69-74 75-78
Number
Current Gross Earnings Current Withholding Tax Current PICA
Code
80
(Digit 1)
OUTPUT UPDATED TAPE RECORD Positions
Field
1-2 3-5 6-25
Department Number Clock Number
Employee Name Social Security
New New New
26-34 35-41 42-47 48-52
Number
Year-to-date Gross Earnings Year-to-date Withholding Tax Year-to-date PICA
OUTPUT PRINTED RECORD Print Positions
Field
4-5
Department Number
9-11 15-34 37-47 52-60 64-71 77-81
Clock Number
Employee Name Social Security
New New
Number
Year-to-date Gross Earnings
Tax
Year-to-date Withholding
Excess
PICA
XX EMPLOYEES OVER
xxx-xx-xxxx xx,xxx.xx x,xxx.xx xx.xx
$343.20.
OPERATIONS TO BE PERFORMED
=
1.
New
Year-to-date
2.
New
Year-to-date Withholding tax
Gross
Old Year-to-date Gross plus Current Gross.
=
Old Year-to-date Withholding Tax plus Current Withholding
Tax. 3.
4.
New If
Year-to-date
New
PICA = Old
Year-to-date
PICA
Name,
Social Security
Excess
PICA amount.
Year-to-date
PICA
exceeds $343.20, print
Number,
New
Year-to-date
154
plus Current
PICA.
Department Number, Clock Number, Employee Gross, New Year-to-date Withholding Tax and
I
Problem 8
SALES PROBLEM {REPORT WRITER FEATURE) REPORT
DAILY SALES REGISTER WEEK OF
SEP
PAGE
3
ENTRY DAY
CUSTOMER NUMBER
3 3
8257 11243 29031 29964 79992 85486
3 3
3 3
SALESMAN
SALE
NUMBER
AMOUNT
DAY 4 4
1179 2965 9002 13605 27654 32007 65952 99003
4
4 4 4 4 4
79 79 95
1,294.86
125
20.25
3
SALES
63.00 87.74
$ 2,823.71
$70,711.29 12,716.92
1
842.17
1
3,092.72
9
217.90 429.65 223.35
22 16 58 4
SALES
92 56
390 5006 12125 20239
4,000.00
$92,234.00 $
5
SALES
100 24
106 298
DAY
6
SALES
^7
256
3
7 7 7 7 7 7
321 652 18569
5 8 90 132 27 60
20106 20902 25452
27.00
897.32 371.98
181 145
DAY 6 6
$ 1,189.80 168.06
2 37
DAY 5 5 5 5
71 79
1
18.16 $ 1,314.46
$ 1,494.73 2,020.60 $ 3,515.33 $
79.53 590.10 95.18 421.15 706.42 55.80 2,166.96
DAILY SALES REGISTER WEEK OF
SEP
PAGE
3
ENTRY DAY
CUSTOMER NUMBER 407&4
SALESMAN
SALE
NUMBER
AMOUNT
43
NUMBER OF SALES
28
155
DAY 7 SALES TOTAL SALES
2
$ 1,914.35
$ 6,029.49
$105,916.99
»
"'
INPUT RECORD FILE Card Columns
Field
1-2 3-4 5-6 7-9
Month
Day Year Salesman
Number
10-14 51-57
Customer Number
Amount
Sales
CALCULATIONS Compute Compute Compute
the total sales value for each day of week. the total sales value for week the
number
of sales for
week.
Problem 9
COMMISSION PROBLEM [REPORT WRITER FEATURE) REPORT
SALES COMMISSION For
SALESMAN
CUSTOMER
2513 2513 2513
11110 12129 14983
4490 4490 4490 4490
Month
of Jonuory
INVOICE
1969
NET AMOUNT
RATE
$ 9,850.40
8 12
12066 13444 14092
10,986.00
6
110.20
$20,946.60 $ 1,250.00 12,359.20 690.70
25930 25220 44873 25118
15121 49690 72914 78345
REPORT
"
10 11 14
8
8,255.12
$22,555.02
TOTAL FOR MONTH OF JANUA RY
$315,946.25
•
'"
INPUT RECORD FILE Card Columns
Field
Code
1
2-6
(digit 5)
Invoice
13-19 35-42 43-46 54-55 56-62
Number
Customer Number Net Invoice Amount Salesman Number Commission Rate Commission Amount
CALCULATIONS Find the Find the
total sales
total sales
and and
total total
commissions for each salesman. commissions for entire sales force for month. 156
COMMISSION $
788.03 1,307.52 6.61
$ 2,102.16 125.00 $
'
1,359.51
96.70 660.41 $ 2,241.62
$30,642.51
'
°»
Problem 10
HOSPITAL PROBLEM (SORT FEATURE] A A United
card
punched
is
report
is
States.
for the
number
of patients in
each hospital of the United
prepared indicating the various patient
An
overall total
is
totals
for cities
States.
and counties within each
state
indicated for the entire United States.
INPUT RECORD FILE Card Columns
Field
1-6 7-8
Date State
County City Hospital
Number
Number
of Patients
9-11 12-14 15-18 70-75
OPERATIONS REQUIRED: 1.
Sort data cards in the following sequence; major-State, intermediate-County
2.
Prepare
listing
and minor-City.
per output record format.
OUTPUT RECORD FORMAT. Heading. Hospital Patient Report January 31,
STATE
COUNTY
CITY
1969
NUMBER OF PATIENTS
Overall totals with appropriate heading should be indicated for each different level.
157
of the
I
I
I
Problem
Illustrative
and
Customers invoices are prepared also design an invoice form.
at the
end of the month. Write a program
Input will contain the following:
Data Item Part
Card Columns
1-5
Number
Blank
6
7-19
Item Description Blank
20
Units
21-23
Blank
24
25-29
Unit Cost
Blank
30 44
Street
31
City and State
45-55
-
56
Blank
Date Invoice
1
57
-
64
65-67
Number
Name
68-80
159
to
perform invoice bilHng
.
160
lLLUSTR.\Tr\-E PbOBLEVIS
"ifSWl^^mft^ LIME NO. SF3. N^.
ST4TPMENT
SOUi^CE
CBO CL3-1 01/76/S9
PAGE
lOFNTIciCftTins OIVISIHN. PROGBi^'-ID.
•BtlL»aijTHnR.
jn^cpM GSTLING. 5c
.J
.
-
a
J
*
.^-
?•
""
ii.s
::
T'c -
ILL IN'
-
DATE. JAN. 8t 1969. INSTALLATION. L.A.T.T.C. ENVIRONMENT DIVISION.
najECT-co'^puTf^R.
IBH-360 E30. N0UT-1IJTPUT SECTION.
L?-IN
;005'
4S
'
UNIT-RECORD 2501. UNIT-RECORO 1403.
OATA DIVISION FILE SECTION. FD FILE-IN >-
L i
=( "=
! 02 FILLE"* 02 04TE PICTURE X{9).
SOURCE STSTEWENTO
LINC VT, SFO. NT.
02 INVniCE-NO PICTURE 999.
41 'UF*
42 41
PAGE
s
t
FD
T
CIL?--
—
ii-.—
J^^^^^^^^^^^H
2
1
OATA RECORD IS RECORD-OUT. RECORD-OUT PICTURE X(n3). ING-STORAGE SECTION. cnnNTC!? Ptr.TMOE °=
-'-
jca^^s.
"
DIFFERENT PTCTORE 99 V4LUE ZEUtre. TOTAL-ORDERED PICTURE 999 VALUE ZEROS, SU" PICTURE 9999799 VSLM' r ' " c>Arr 1 1 .'iL 1^
T2
-
7-?
'
1
11 . (
11
OESIf-.N-i.
.^^^^^^^^^^^^^H
^^^^^^^^^^^^H
Illustratix'e
Problems
SOURCE STATEMENTP
LINE NO. SEQ. NO. 82
83 84 85 86
02 FfLLER PICTURE X VAl.iI"^ •*• 0? FILLER VALUE SOACF PIC^'j^F 01
89 90 91