COBOL650
COBOL650
COBOL650
PL
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
INTRODUCTION
This manual is a guide on how to properly write Cobol
programs on the IBM-PC using Ansi-Standard COBOL Version
6.50. It is a guide on structured coding style and good
programming techniques, as well as a COBOL manual. It
will explain in detail the features used and the
examples, but will limit the discussion to the most
commonly used features of COBOL.
Our goal as programmers is to write reasonably efficient
programs that are easy for other programmers to read,
this is necessary for maintaining the program. Whenever
possible, I have tried to present a style that is useful
and has been tested on other computer systems,
especially the large IBM mainframe used in business. I
acknowledged the possibility that the reader may one day
use what he learns from this manual to write programs
for such mainframes, or may port software, that is
already written on these machines to the PC using COBOL
6.50.
LIMITIATIONS
You should note that :
1) COBOL Version 6.50 does not have the sort/merge
feature. This is being added and may be out by the
time you receive this manual. Please note the readme
file on the floppy.
NOTE:SORT MERGE HAS BEEN ADDED TO THE LIBARY.
2) It does not have the report writer feature and never
will.
3) It does not have the communications feature such as
CICS. I will probably add this into it, but at this
time I do not have any plans to.
4) Certain features are implimented at it's first or
lowest level.
5) It does have extensive screen formatting features
that are not available in Cobol for the mainframe.
The manual is divided into 2 parts. Chapters ? -
chapters ? will familiarize the reader with the most
important components of Ansi-Standard COBOL Version 6.50
and will allow him or her to start writing programs.
Chapters ? - chapters ? are very important once he or
she starts writing actual and especially more complex
programs. The last chapter is very important in that it
illustrates how to use the COBOL COMPILIER to write
programs and how to write applications.
INTRODUCTION PAGE 1
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
TABLE OF CONTENTS
Cobol Version 6.50 users Manual
Introduction
LIMITIATIONS
CHAPTER 1
Hardware and Software 1
Computer Systems 1
Types of Computer Systems 1
Hardware 2
Software 2
System Software 2
Programs 2
Pseudo Code 3
Figure 1.1 3
Applications 3
Developing Applications 3
CHAPTER 3
ANSI-COBOL Version 6.50 4
Introduction 4
General Characteristics 4
X3.23-1974 4
Components of COBOL 5
Statements 5
example 3.1 5
Sentence 6
example 3.2 6
Clause 6
example 3.3 6
Paragraph 7
example 3.4 7
Section 7
example 3.5 8
STATEMENT FORMAT 8
example 3.6 9
Cobol Character Set 10
Rules For Punctuation 10
Characters used in Conditions 10
Characters used in Arithmetic 11
Characters used for print editing 11
Types of Words 12
Reserved Words 12
Reserved Words List
Reserved words ACCEPT - RERUN 13
Reserved Words List
Reserved words list RESERVE - ZEROS 14
Non-reserved words rules 15
Data Format 15
Elementary Data Items 15
Group Data Items 16
Records 16
Files 16
COBOL Coding Form 17
CHAPTER 4
Basic COBOL Statements
INTRODUCTION 18
The ACCEPT statment (format 2)
Fig.4.1
The (PRINTER) DISPLAY STATEMENT
example 4.2 20
example 4.3 21
THE MOVE STATEMENT 21
EXAMPLE 4.4 21
EXAMPLE 4.5
THE ADD STATEMENT 23
EXAMPLE 4.6 23
EXAMPLE 4.7 24
THE SUBTRACT STATEMENT 24
EXAMPLE 4.8 24
EXAMPLE 4.9 25
THE MULTIPLY STATEMENT 25
EXAMPLE 4.10 25
EXAMPLE 4.11
THE DIVIDE STATEMENT 27
EXAMPLE 4.12 27
EXAMPLE 4.13 28
THE GIVING CLAUSE 28
EXAMPLE 4.14 28
EXAMPLE 4.15 29
THE ROUNDED CLAUSE 29
EXAMPLE 4.16 30
EXAMPLE 4.17 31
THE PERFORM STATEMENT 31
EXAMPLE 4.20 31
THE ON SIZE ERROR CLAUSE 32
EXAMPLE 4.22 32
THE GO TO STATEMENT 33
EXAMPLE 4.24 34
THE COMPUTE STATEMENT 35
EXAMPLE 4.26 35
CHAPTER 5
BASIC FILE OPERATIONS
INTRODUCTION 37
FILES 38
FILE ORGANIZATION 38
RECORDS 38
OPEN STATEMENT 39
OPEN RULES 39
THE CLOSE STATEMENT 39
THE READ STATEMENT 40
THE WRITE STATEMENT (PRINT FILE) 40
EXAMPLE 5.01 41
CHAPTER 6
CODING THE IDENTIFICATION
AND ENVIRONMENT DIVISIONS
INTRODUCTION 43
THE IDENTIFICATION DIVISION 44
THE ENVIRONMENT DIVISION. 44
THE CONFIGURATION SECTION 44
THE INPUT-OUTPUT SECTION 45
RULES FOR CODING
THE INPUT-OUTPUT SECTION 45
CHAPTER 7
Hardware
The IBM-PC's are composed of several hardware
components. These are the systems unit, Electronics
comprising the microprocessor, either the 8088, 80186,
80286, 80386, and the newer 80486. Memory which maybe
extended, expanded or conventional and a video display
unit, This maybe any one of the types listed below and
who knows what will come up next. Monocrome, CGA, BGA,
VGA, VEGA drives the keyboard and the hard drives.
Software
There are 2 types of software. Applications software is
written to solve a specific user problem. Examples are
software that prints payroll checks or displays
inventory stock information. This software is either
written by the user himself using a language like COBOL,
BASIC, or FORTRAN or bought off the shelf as a complete
package. Software, manuals, technical support, etc.
Such packaged software is generally written by an
independent software company.
System's Software
System software does not solve specific problems, but
rather makes it easier for the user to use computer
system. It is generally developed by hardware or
independent software companies. Examples are operating
systems such as DOS, compilers such as Ansi-Standard
COBOL and interpreters such as IBM Basic, saved on
diskette or on hard drive and before it can be used it
must first be loaded into the computers memory. This is
done by typing in the proper command such as COBOL600
followed by the enter key.
Programs
A set of instructions written together as a single unit
defines both a beginning and an end is called a program.
Thus a program is a specific piece of software, system
software and application software. They are more
commonly known as systems programs and applications
programs respectively. In this manual the latter terms
will be used. Note that when a program is executing it
is said to be running. In other words the program
executes is the same as the program is running or the
program runs. Computer people often say the job runs or
the job is running.
PAGE 2
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
Pseudo Code
We will illustrate the concept of a program by using
Pseudo Code, which is a mix of words that are valid in
programs and other descriptive words that are not.
While a program written in it cannot execute because of
invalid words it's primary use is to make the program
logic easy to understand on paper. This is shown in
figure 1.1. Note the capitalized words are valid in
COBOL programs.
FIGURE 1.1
______________________________________________________________
: :
: ACCEPT first operator-entered number into memory. :
: ACCEPT second operator-entered number into memory. :
: ADD first number TO, second number GIVING result-field. :
: DISPLAY result-field. :
:______________________________________________________________:
Pseudo Code of a segment of a program code that adds 2 numbers and
displays the sum.
Applications
An application, more commonly known as an application
system to simple system, is a specific job or sequence
of jobs that run or will be run on the computer. For
instance, a payroll system prints out paychecks, W2
forms, etc. An inventory system allows the operator to
enter or verify stock information on a video display
unit, etc. In this user's manual we will use system for
a specific application, thus payroll system instead of
payroll application.
Developing Applications
When a computer user needs an application he has a
choice of either buying it off the shelf as a package
"programs, manuals, tech support, etc." or developing
the system himself. If he decides on the latter he
first has to determine his requirements in detail and
design a system that impliments the application. This
is known as system design. In large organizations this
systems design is generally done by the systems analyst
who consults the user on his requirements and then
translate them into a series of specifications that can
be given to the applications programmers. They in turn
translate these specifications into applications
programs that can be run on the computer.
PAGE 3
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
Components of COBOL
Although COBOL is close to the English Pros in style, it
has it's own Syntax rules. We can think of a COBOL
program as a book, consisting of 4 parts each being a
COBOL division. Each division consists of 1 or more
sections. Each section corresponding to a chapter in a
book. Each section in turn consists of 1 or more
paragraph which in turns consists of 1 or more
sentences. We will now define certain COBOL terms, but
we will restrict our discussion to how they are used in
the most common division, the PROCEDURE DIVISION, where
the logic is stated. Most definitions are however valid
for other divisions, which are much easier to code than
the PROCEDURE DIVISION.
STATEMENTS
A statement is a basic unit of the PROCEDURE DIVISION.
It is a correct combination of words and symbols that
specifies an action to be done, "ADD, MOVE, DIVIDE,
ETC.", or a condition to be tested "IF". Unless
subordinated to another statement as for example in IF
conditon it is best for program and readability to code
them starting in column 12. Figure 3.1 shows a segment
of a program code with 6 statements. The last statement
is quite long and therefore coded in 2 lines. Also for
readability the continuation is indented from this.
Your first exposure to typical COBOL program that the
code is quite easy to understand.
______________________________________________________________________________
1234567890123456789012345678901234567890123456789012345678901234567890123456789
0
IF W010-MONTH-SALES GREATER THAN 499.99
MOVE "*" TO W040-DETAIL-EXCEPTIONAL-SALES
ELSE MOVE TO W040-DETAIL-EXCEPTIONAL-SALES.
MOVE W010-MONTH-SALES TO W040-DETAIL-MONTH-SALES
MOVE W010-ANNUAL-SALES TO W040-DETAIL-ANNUAL-SALES
WRITE SALES-PERFORMANCE-LINE FROM W040-SALES-DETAIL-LINE
AFTER ADVANCING W040-PRINT-SKIP LINES.
EXAMPLE 3.1
_______________________________________________________________________________
PAGE 5
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
Sentence
A sentence is 1 or more statements that ends in a period
and is followed by a space. Notice it is followed by a
space. The beginning of a sentence is always a
statement that is not subordinated to another and should
therefore start in column 12. This concept of a
sentence is very important and the programmer is advised
to terminate a statement with a period when possible.
This makes a statement independent of other statements
and thus avoids potential problems as you will see later
on in figure 3.2. Figure 3.2 shows a segment of a
program code with 4 sentences. These are actually the
same statements as figure 3.1, but it now has 4
sentences from the 4 periods that end statements.
Figure 3.1 only has 2 sentences.
______________________________________________________________________________
1234567890123456789012345678901234567890123456789012345678901234567890123456789
0
IF W010-MONTH-CELLS GREATER THAN 499.99
MOVE "*" TO W040-DETAIL-EXCEPTIONAL-CELLS
ELSE MOVE TO W040-DETAIL-EXCEPTIONAL-CELLS.
MOVE W010-MONTH-CELLS TO W040-DETAIL-MONTH-CELLS.
MOVE W010-ANNUAL-CELLS TO W040-DETAIL-ANNUAL-CELLS.
WRITE CELLS-PERFORMANCE-LINE FROM W040-CELLS-DETAIL-LINE
AFTER ADVANCING W040-PRINT-SKIP LINES.
EXAMPLE 3.2
_______________________________________________________________________________
Clause
A clause is part of complex statement and is only
meaningful in specific statements. Examples are
"GIVING" "ROUNDED". Clauses of an arithmetic statement.
It maybe mandatory or optional depending on the
statement. Figure 3.3 shows use of 2 clauses and a
MULTIPLY statement.
______________________________________________________________________________
1234567890123456789012345678901234567890123456789012345678901234567890123456789
0
MULTIPLY W010-NUMBER-OF-HOURS BY W030-HOURLY-RATE
GIVING W020-WEEK-GROSS-PAY
ROUNDED.
EXAMPLE 3.3
______________________________________________________________________________
PAGE 6
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
Paragraph
A paragraph is 1 or more sentences that together perform
a certain function maybe grouped in 1 paragraph by
putting them under a paragraph header consisting of a
paragraph name and a period. For program readability,
this paragraph header is best coded starting in column
8. The concept of a paragraph is very important since
we will learn later on that it is best to execute the
logic by controlling paragraphs through the verb
PERFORM. Therefore adjacent paragraphs should be
seperated from each other by a line seperated. "* in
column 7". Figure 3.2 does 1 function for instance
print a detail line from data coming from a record. It
can then be coded as a paragraph putting a paragraph
header before it. Figure 3.4 is the result.
______________________________________________________________________________
1234567890123456789012345678901234567890123456789012345678901234567890123456789
0
*
*
C060-PRINT-CELLS-REPORT-DETAIL.
MULTIPLY W010-NUMBER-OF-HOURS BY W030-HOURLY-RATE
GIVING W020-WEEK-GROSS-PAY
ROUNDED.
EXAMPLE 3.4
______________________________________________________________________________
Section
1 or more related paragraphs maybe grouped together in
one section by putting them under a section header which
consists of a section name followed by the literal
"SECTION" followed by period. The section ends
immediately before the next section header or at the end
of the program. Except for "DECLARATIVES SECTION" which
also ends with the "END DECLARATIVES" statement. The
concept of a section is very important in the PROCEDURES
DIVISION where as we will later discuss related
paragraphs are best grouped into sections. If we put
the paragraph into figure 3.4 under a section header we
get one section with 1 subordinate paragraph naturally
we can put as many paragraphs as you want in the same
section, but for readability of the program, the section
header is also coded started in column 8. Also we code
a line seperater which is an * in column 7 between the
section header and the paragraph header. The result is
in figure 3.5.
PAGE 7
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
______________________________________________________________________________
1234567890123456789012345678901234567890123456789012345678901234567890123456789
0
*
*
C000-PRINT-CELLS-REPORT SECTION.
*
C060-PRINT-CELLS-REPORT-DETAIL.
MULTIPLY W010-NUMBER-OF-HOURS BY W030-HOURLY-RATE
GIVING W020-WEEK-GROSS-PAY
ROUNDED.
EXAMPLE 3.5
______________________________________________________________________________
STATEMENT FORMAT
Each statement in the language has a general format and
the programmer has to use the prescribed rules for each
statement regarding spelling "reserved words must be
spelled correctly". Providing the names of data to be
used and the order of the clauses in the statement. To
a large extent the rules of format follow common sense.
For instance, program logic is coded with statements
which start with a verb like "ADD, MOVE, MULTIPLY, ETC."
followed by the operend used by the verbs followed if
any by optional clauses. For instances, to multiply 2
numbers we code:
MULTIPLY first-operend BY second-operend
GIVING product-field
ROUNDED
ON SIZE ERROR,
imperative statements.
The 2 operends are multiplied and the product is placed
in the product field if the GIVING option is specified.
It maybe rounded off and it may not fit into high order
left most part of the product field. The imperative
statements will be executed instead of the next
following statement. Note that the GIVING, ROUNDED, and
ON SIZE ERROR are optional clauses. Before we go any
further, examine fig. 3.6.
PAGE 8
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
______________________________________________________________________________
1234567890123456789012345678901234567890123456789012345678901234567890123456789
0
IDENTIFICATION DIVISION.
*
PROGRAM-ID. EXMP36.
*
***********************************************************
* DATE-WRITTEN. 08/13/90. *
***********************************************************
*
ENVIRONMENT DIVISION.
*
DATA DIVISION.
*
WORKING-STORAGE SECTION.
01 HELLO-WORLD PIC X(20)
VALUE "Hello world".
*
PROCEDURE DIVISION.
*
DISPLAY HELLO-WORLD.
STOP RUN.
EXAMPLE 3.6
______________________________________________________________________________
Types of Words
Reserved words are those that have a specific meaning in
COBOL and they must be spelled correctly and used in
only the way that they were intended. Examples are
"ADVANCING, MOVE, PAGE" etc. Program refined words,
non-reserved words, are coded by the programmer for the
following uses:
1) data names,
2) files names,
3) condition names,
4) procedure names.
Reserved Words
Reserved words have specific meanings in COBOL and
therefore use only according to proper Syntax rules.
These words must be spelled correctly. However, reserved
words enclosed in quotation marks become non-numerical
literals and are not reserved words. There are 3 types
of reserved words.
1) Key word - key word is a word which is required in
the statement. There are 3 types:
a) verbs, such as ADD, MOVE, READ.
b) required words that appear in certain statements,
such as TO and the ADD statement.
c) words that have specific functional meaning, such
as PAGE, ZERO, POSITIVE.
2) Optional words - an optional word may or may not be
included in a statement. Examples are GIVING,
ROUNDED, and ON SIZE ERROR, which are clauses in
arithmetic statements.
3) Connectives - connective is a word that joins or
connects 2 adjacent words. There are 2 types:
a) qualifier connective. This is "OF" which
associates a data name, condition name or
paragraph name with it's qualifier.
b) logical connectives. These are words used in
compound combinations. They are AND and OR.
PAGE 12
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
PAGE 19
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
34 ACCEPT W005-MESSAGE-FIELD.
35 DISPLAY W005-MESSAGE-FIELD.
36 STOP RUN.
--------------------------------------------------------
PAGE 20
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
22 *
23 *
24 DATA DIVISION.
25 *
26 *
27 ****************************************************
28 * *
29 WORKING-STORAGE SECTION.
30 * *
31 ****************************************************
32 *
33 *
34 01 W005-MESSAGE-FIELD PIC X(32).
35 *
36 *
37 PROCEDURE DIVISION.
38 *
39 DISPLAY-ACCEPTED-MESSAGE.
40 DISPLAY "PROGRAM PROG402: PRINT DISPLAY OUTPUT:"
41 UPON PRINTER-DISPLAY.
42 ACCEPT W005-MESSAGE-FIELD.
43 DISPLAY W005-MESSAGE-FIELD UPON PRINTER-DISPLAY.
44 STOP RUN.
--------------------------------------------------------
EXAMPLE 4.3
PROGRAM PROG402: PRINT DISPLAY OUTPUT:
THIS MESSAGE IS OPERATOR ENTERED
--------------------------------------------------------
PAGE 21
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
6 * *
7 * 1. DATE-WRITTEN. 08/01/90. *
8 * *
9 * 2. THIS PROGRAM DISPLAYS ON THE PRINTER *
10 * A MESSAGE ENTERED BY THE OPERATOR. *
11 * *
12 * 3. THE MESSAGE IS INITIALLY ENTERED INTO ONE *
13 * WHICH IS THEN MOVED TO ANOTHER FIELD BEFORE *
14 * BEING PRINTED ON THE PRINTER. *
15 * *
16 ***************************************************
17 *
18 *
19 ENVIRONMENT DIVISION.
20 *
21 CONFIGURATION SECTION.
22 *
23 SPECIAL-NAMES.
24 *
25 PRINTER IS PRINTER-DISPLAY.
26 *
27 *
28 DATA DIVISION.
29 *
30 *
31 ****************************************************
32 * *
33 WORKING-STORAGE SECTION.
34 * *
35 ****************************************************
36 *
37 *
38 01 W005-ACCEPT-MESSAGE-FIELD PIC X(32).
39 *
40 01 W005-DISPLAY-MESSAGE-FIELD PIC X(32).
41 *
42 *
43 PROCEDURE DIVISION.
44 *
45 DISPLAY-ACCEPTED-MESSAGE.
46 DISPLAY "PROGRAM PROG404: PRINT DISPLAY OUTPUT:"
47 UPON PRINTER-DISPLAY.
48 ACCEPT W005-ACCEPT-MESSAGE-FIELD.
49 MOVE W005-ACCEPT-MESSAGE-FIELD
50 TO W005-DISPLAY-MESSAGE-FIELD.
51 DISPLAY W005-DISPLAY-MESSAGE-FIELD
52 UPON PRINTER-DISPLAY.
53 STOP RUN.
--------------------------------------------------------
EXAMPLE 4.5
PROGRAM PROG404: PRINT DISPLAY OUTPUT:
THIS MESSAGE IS OPERATOR ENTERED
--------------------------------------------------------
PAGE 22
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
PAGE 23
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
38 *
39 PROCEDURE DIVISION.
40 *
41 PRINT-COMPUTED-VALUE.
42 ADD W005-FIRST-OPERAND TO W005-SECOND-OPERAND.
43 DISPLAY "PROGRAM PROG406: THE SUM OF 2 + 12 IS:"
44 UPON PRINTER-DISPLAY.
45 DISPLAY W005-SECOND-OPERAND UPON PRINTER-DISPLAY.
46 STOP RUN.
---------------------------------------------------------
EXAMPLE 4.7
PROGRAM PROG406: THE SUM OF 2 + 12 IS:
14
----------------------------------------------------------
THE SUBTRACT STATEMENT
The SUBTRACT verb subtracts two numbers and as options
rounds off the result, checks it for overflow, or places
it into a specific field. Here, we will take up the
most basic version of the statement where we subtract
two numbers (contained in the two operands ) and the
result is placed in the second operand ( the minuend)
and thus replaces the original value. The program is
shown in fig.4.8. Line 42 subtracts the two numbers,
which is then displayed on the printer. The result is
fig.4.9.
PAGE 24
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
21 PRINTER IS PRINTER-DISPLAY.
22 *
23 *
24 DATA DIVISION.
25 *
26 *
27 ****************************************************
28 * *
29 WORKING-STORAGE SECTION.
30 * *
31 ****************************************************
32 *
33 *
34 01 W005-SUBTRAHEND PIC 9 VALUE 2.
35 *
36 01 W005-MINUEND PIC 99 VALUE 12.
37 *
38 *
39 PROCEDURE DIVISION.
40 *
41 PRINT-COMPUTED-VALUE.
42 SUBTRACT W005-SUBTRAHEND FROM W005-MINUEND.
43 DISPLAY "PROGRAM PROG408: THE RESULT OF 12 - 2 IS:"
44 UPON PRINTER-DISPLAY.
45 DISPLAY W005-MINUEND UPON PRINTER-DISPLAY.
46 STOP RUN.
--------------------------------------------------------
EXAMPLE 4.9
PROGRAM PROG408: THE RESULT OF 12 - 2 IS:
10
---------------------------------------------------------
THE MULTIPLY STATEMENT
The MULTIPLY verb multiplies two numbers and as options
rounds off the product, checks it for overflow, or puts
it into a specific field. Here, we will take up the
most basic version of the statement where we multiply
two numbers (contained in the two operands) and the
product is placed in the second operand ( the
multiplier) and thus replaces its original value. The
program is shown in fig.4.10. Line 42 does the
multiplication which is then printed out. The result is
fig.4.11.
PAGE 25
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
4 *
5 ***************************************************
6 * *
7 * 1. DATE-WRITTEN. 08/01/90. *
8 * *
9 * 2. THIS PROGRAM DISPLAYS ON THE PRINTER *
10 * A VALUE COMPUTED FROM A MULTIPLY OPERATION. *
11 * *
12 ***************************************************
13 *
14 *
15 ENVIRONMENT DIVISION.
16 *
17 CONFIGURATION SECTION.
18 *
19 SPECIAL-NAMES.
20 *
21 PRINTER IS PRINTER-DISPLAY.
22 *
23 *
24 DATA DIVISION.
25 *
26 *
27 ****************************************************
28 * *
29 WORKING-STORAGE SECTION.
30 * *
31 ****************************************************
32 *
33 *
34 01 W005-MULTIPLICAND PIC 9 VALUE 2.
35 *
36 01 W005-MULTIPLIER PIC 99 VALUE 12.
37 *
38 *
39 PROCEDURE DIVISION.
40 *
41 PRINT-COMPUTED-VALUE.
42 MULTIPLY W005-MULTIPLICAND BY W005-MULTIPLIER.
43 DISPLAY "PROGRAM PROG410: THE PRODUCT OF 2 * 12 IS:"
44 UPON PRINTER-DISPLAY.
45 DISPLAY W005-MULTIPLIER UPON PRINTER-DISPLAY.
46 STOP RUN.
---------------------------------------------------------
EXAMPLE 4.11
PROGRAM PROG410: THE PRODUCT OF 2 * 12 IS:
24
----------------------------------------------------------
PAGE 26
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
PAGE 27
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
PAGE 28
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
17 ENVIRONMENT DIVISION.
18 *
19 CONFIGURATION SECTION.
20 *
21 SPECIAL-NAMES.
22 *
23 PRINTER IS PRINTER-DISPLAY.
24 *
25 *
26 DATA DIVISION.
27 *
28 *
29 ****************************************************
30 * *
31 WORKING-STORAGE SECTION.
32 * *
33 ****************************************************
34 *
35 *
36 01 W005-DIVISOR PIC 9 VALUE 2.
37 *
38 01 W005-DIVIDEND PIC 99 VALUE 12.
39 *
40 01 W005-QUOTIENT PIC 9.
41 *
42 PROCEDURE DIVISION.
43 *
44 PRINT-COMPUTED-VALUE.
45 DIVIDE W005-DIVISOR INTO W005-DIVIDEND GIVING W005-QUOTIENT.
46 DISPLAY "PROGRAM PROG414: THE QUOTIENT OF 12 / 2 IS:"
47 UPON PRINTER-DISPLAY.
48 DISPLAY W005-QUOTIENT UPON PRINTER-DISPLAY.
49 STOP RUN.
---------------------------------------------------------
EXAMPLE 4.15
PROGRAM PROG414: THE QUOTIENT OF 12 / 2 IS:
6
---------------------------------------------------------
THE ROUNDED CLAUSE
In certain arithmetic operations, especially division
and sometimes multiplication with decimals, there may be
extra digits in the result to the right of the decinal
point that cannot be accommodated in the data item that
holds this result. ANSI-COBOL automatically truncates
these digits from the result without rounding off the
remaining loworder (rightmost) digit, unless the
optional ROUNDED clause is included. Fig. 4.16 shows
the differnce between division without rounding and one
with rounding. Both versions will be displayed for
comparison. Lines 50 to 53 shows division without
rounding, followed by the corresponding display; and
lines 54 to 58, those with rounding. Incidentally, line
52 shows how a non-numeric literal is continued in the
next line. The result is fig.4.17. The quotient of 5/3
PAGE 29
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
PAGE 30
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
47 PROCEDURE DIVISION.
48 *
49 PRINT-COMPUTED-VALUE.
50 DIVIDE W005-DIVISOR INTO W005-DIVIDEND GIVING W005-QUOTIENT.
51 DISPLAY "PROGRAM PROG414: THE QUOTIENT OF 5 / 3 UNROUNDED IS
52 - ":" UPON PRINTER-DISPLAY.
53 DISPLAY W005-QUOTIENT UPON PRINTER-DISPLAY.
54 DIVIDE W005-DIVISOR INTO W005-DIVIDEND
55 GIVING W005-QUOTIENT ROUNDED.
PAGE 31
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
10 *
11 PRINTER IS PRINTER-DISPLAY.
12 *
13 *
14 DATA DIVISION.
15 *
16 *
17 WORKING-STORAGE SECTION.
18 *
19 01 W005-DIVISOR PIC 9 VALUE 2.
20 *
21 01 W005-DIVIDEND PIC 99 VALUE 12.
22 *
23 01 W005-QUOTIENT PIC 9.
24 *
25 *
26 PROCEDURE DIVISION.
27 *
28 MAIN-LINE-LOGIC.
29 PERFORM PRINT-COMPUTED-VALUE.
30 STOP RUN.
31 *
32 *
33 PRINT-COMPUTED-VALUE.
34 DIVIDE W005-DIVISOR INTO W005-DIVIDEND GIVING W005-QUOTIENT.
35 DISPLAY "12/2 IS".
36 DISPLAY W005-QUOTIENT.
---------------------------------------------------------
THE ON SIZE ERROR CLAUSE
If after decimal point alignment and rounding, the high-
order (left-most) portion of the result cannot fit in
the data item for the result, the "size error" condition
occurs. If the ON SIZE ERROR option is not used in the
arithmetic statement, the result is unpredictable.
Otherwise, the imperative statements that fall under the
ON SIZE ERROR clause will be executed. An example is
fig.4.22.
PAGE 32
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
10 *
11 PRINTER IS PRINTER-DISPLAY.
12 *
13 DATA DIVISION.
14 *
15 WORKING-STORAGE SECTION.
16 *
17 01 W005-DIVISOR PIC 9 VALUE 0.
18 *
19 01 W005-DIVIDEND PIC 99 VALUE 5.
20 *
21 01 W005-QUOTIENT PIC 9.
22 *
23 *
24 PROCEDURE DIVISION.
25 *
26 MAIN-LINE-LOGIC.
27 PERFORM PRINT-COMPUTED-VALUE.
28 STOP RUN.
29 *
30 *
31 PRINT-COMPUTED-VALUE.
32 DIVIDE W005-DIVISOR INTO W005-DIVIDEND GIVING W005-QUOTIENT
33 ON SIZE ERROR
34 DISPLAY "ON SIZE ERROR ENCOUNTERED"
35 DISPLAY "PROGRAM ABORTING"
36 STOP RUN.
37 DISPLAY "No On Size error".
38 DISPLAY "PROGRAM EXITING NORMALLY".
39 STOP RUN.
---------------------------------------------------------
THE GO TO STATEMENT
The GO TO statement verb provides an unconditional
branch from the current set of statements to a specific
section or paragraph in the program. Unlike the PERFORM
verb, there is no return to where it came from and the
execution will continue right at the section or
paragraph specified as the operand of the verb. Many
studies in structured programming have shown that the
uncontrolled use of this verb can make the program logic
hard to follow because of the many "jumps" that occur.
I therefore suggest that we only use this verb in
certain conditions. Fig. 4.24 shows an example of the
GO TO.
PAGE 33
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
PAGE 35
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
CHAPTER 5
BASIC FILE OPERATIONS
INTRODUCTION
Cobol was deveeloped for business applications and as
such was designed to make it easier ( compared to other
language ) for programmers to write programs for
applications like PAYROLL, INVENTORY CONTROL, ACCOUNTS
REC. ECT. While its arithmetic capablities, though more
than adequate for business applications, are not as
extensive as those of fortran, its ablitity to process
large amounts of data of different formats from
different locations make it the most popular programming
language for commercial applications.
PAGE 37
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
FILES
PAGE 41
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
51 C000-MAIN-LINE-LOGIC.
52 *
53 OPEN INPUT EMPLOYEE-ADDRESS-MASTER
54 OUTPUT EMPLOYEE-ADDRESS-PRINT.
55 MOVE "0" TO W005-END-OF-FILE-SWITCH.
PROG501 COB 15:25:03 02-Sep-90 PAGE 2
Line Number Source Line ANSI 74-85 Standard Cobol V.6.0 (c)1990.
56 PERFORM C060-READ-EMPLOYEE-MASTER.
57 PERFORM C020-PROCESS-EMPLOYEE-MASTER
58 UNTIL W005-END-OF-FILE.
59 CLOSE EMPLOYEE-ADDRESS-MASTER
60 EMPLOYEE-ADDRESS-PRINT.
61 STOP RUN.
62 *
63 C020-PROCESS-EMPLOYEE-MASTER.
64 *
65 MOVE EMPLOYEE-ADDRESS-MASTER-NAME
66 TO EMPLOYEE-ADDRESS-PRINT-LINE.
67 MOVE 3 TO W005-LINE-SKIP.
68 PERFORM C040-WRITE-DETAIL-LINE.
69 MOVE EMPLOYEE-ADDRESS-MASTER-STREET
70 TO EMPLOYEE-ADDRESS-PRINT-LINE.
71 MOVE 3 TO W005-LINE-SKIP.
72 PERFORM C040-WRITE-DETAIL-LINE.
73 MOVE EMPLOYEE-ADDRESS-MASTER-CITY
74 TO EMPLOYEE-ADDRESS-PRINT-LINE.
75 MOVE 3 TO W005-LINE-SKIP.
76 PERFORM C040-WRITE-DETAIL-LINE.
77 PERFORM C060-READ-EMPLOYEE-MASTER.
78 *
79 C040-WRITE-DETAIL-LINE.
80 *
81 WRITE EMPLOYEE-ADDRESS-PRINT-LINE
82 AFTER ADVANCING W005-LINE-SKIP LINES.
83 *
84 C060-READ-EMPLOYEE-MASTER.
85 *
86 READ EMPLOYEE-ADDRESS-MASTER
87 AT END, MOVE "1" TO W005-END-OF-FILE-SWITCH.
PAGE 42
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
INPUT-OUTPUT SECTION
The "INPUT-OUTPUT SECTION." contains the "FILE-CONTROL."
paragraph, which is coded in column 8, and which is
required if the program uses files. There will be
entries under this paragraph, one for each file used.
Each entry is a SELECT statement that starts in column
12, and may be continued on the next line, and ends with
a period. The format for the SELECT statement is:
SELECT data-file-name ASSIGN TO DISK|PRINTER
FILE STATUS IS data-name
ACCESS MODE IS SEQUENTIAL|RANDOM|DYNAMIC
ORGANIZATION IS SEQUENTIAL|LINE
SEQUENTIAL|RELATIVE|INDEXED
RECORD KEY IS data-name-2
RELATIVE KEY IS data-name-3
The following rules apply:
1. Use filenames that are self-documenting. In the
example I use EMPLOYEE-ADDRESS-MASTER and EMPLOYEE-
ADDRESS-PRINT as file names.
2. Use DISK if it is a disk file and PRINTER if it is
the printer.
3. The FILE STATUS clause is used for disk files with
relative or indexed file organization, data-name is a
two-character data item that contains the value set
after every I-O statement. The returned values are:
FILE STATUS value MEANING
______________________________________________
00 SUCCESSFUL COMPLETION
10 END OF FILE
21 KEY NOT IN SEQUENCE(INDEXED)
22 DUPLICATE KEY ON WRITE
23 NO RECORD FOUND
24 DISK FULL
30 HARDWARE ERROR (DISK NOT READY ECT.)
91 FILE STRUCTURED DESTROYED
PAGE 45
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
CHAPTER 7
CODING THE DATA DIVISION
Introduction
The data division is where data used in the program
except for literals used in statements are defined.
The data maybe coming from a file will be written to
a file or used in intermediate processing. It is
important that certain techniques be used so that the
data names can be easily located and read from the
program listing and thus facilitate program
debugging. It is also important that we select the
proper data format so as to help make the program
more efficient.
PAGE 46
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
Sections
This division starts with the division header "DATA
DIVISION" that is coded starting in column 8. There
are 4 optional sections that maybe defined all of
which start with a section header that is coded
starting in column 8. These sections are "FILE
SECTION", "WORKING-STORAGE SECTION", "LINKAGE
SECTION", "SCREEN SECTION" and must appear in that
order if defined.
FILE SECTION
This section starts with header "FILE SECTION" and
contains one entry for each file defined in the
select statement in the file control paragraph of the
ENVIRONMENT DIVISION. The file description entry has
the following format.
FD file name
LABEL RECORD | RECORDS IS | ARE OMITTED | STANDARD
VALUE OF FILE ID IS data name.
PAGE 48
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
-------------------------------------------------------------------------------
WORKING STORAGE SECTION
This section contains data that are mainly used for
intermediate processing such as counters, tables, etc.
This data are generally not directly related to records
and files. The file record entries under FDs except
where we use the into option of verb or from option of
the write or rewrite verbs. Coding techniques for this
section is basically identical to those of the file
section except the following:
1) The 01 level group item does not correspond to any
record and therefore the programmer may group data
items under it in any way he chooses. He should,
however, try to group data together that are related.
2) The value clause maybe used in this section.
LINKAGE SECTION
This section is used if the program is being called by
another program. It will contain description of data
items that the called program needs and has the
correspondence to certain data items defined in the
working storage section of the calling program. This
section will actually not have memory allocated for it,
but will just use the memory allocated to the
corresponding files in the calling program. Just like
the data items in the file section the value clause
maybe specified only for condition names.
SCREEN SECTION
This section defines format of the screen to be used in
the program for displaying formatted data. Display or
exhibit verbs or accepting formatted data except verbs.
PAGE 49
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
Structure Programming
This is a technique that grew out of research begun in
the academic community some 30 or 40 years ago. It's
main aim was to make programs easier to read and thus
understand by having the programmer code them in a
certain style. One of it's main ideas is to avoid any
GO TO statements since they made the larger quota to
follow. The unconditional branch caused by each GO TO
disrupts the normal flow of control from a statement to
the one following it. Some proponents of structure
programmings have expand and redefined this idea to
include many other techniques. They have not eliminated
GO TOs all together, but just restrict their use to
certain conditions.
Program Constructs
Structured programming requires statements follow the
rule of one entry and one exit. Constructs which
consists of one or more statements must acquire control
starting execution at only one point in a relinquished
control stop execution at only one point. Reading the
program listing is thus made easier since we know that a
construct will eventually exit at one point. Any branch
outside of the construct will only be temporary done
through performed verbs. From this we can conclude that
GO TOs are to be avoided. GO TOs are supported although
in version 6.50. Examples of this are MOVE, DISPLAY,
EXHIBIT, etc. Statements which we simply execute before
proceeding in the next statement. Let's look at the
following set of statements. MOVE "ERA 5" TO MESSAGE
005-MESSAGE-CODE. EXHIBIT NAMED W005-MESSAGE-CODE.
DISPLAY "TEST 01 RUN ABORTED". You will note that each
statement is simply executed and control flows right
through to the next statement.
The IF Condition
We must understand that statements under the true or
false boxes could be a combination of valid constructs.
The important thing is always is to have one entry point
and one exit thus nested IFs something that may seem
tricky to use are very powerful to the structure
programming. While confusing if done improperly they
are easy to understand if properly indented. Note that
the constructs start at the IF statement and ends with a
period. No matter what values of W005-TRANS-HOURS and
W01-HOURS-LIMIT are. Control will eventually reach the
statement following the construct. Perform until
constructs. The construct governed by the false
condition the performed body will be executed repeatedly
until condition becomes true. At which time the
apparent original construct exists. When the constructs
in the performed body must eventually set the condition
true to enable use to exit from the apparent construct
PAGE 51
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
Modular Programming
One of the developments in structure programming was the
idea of modularizing the program by coding into it's
sections. This idea is extensively used to COBOL
programs written for mainframes where the use of
advanced features like Sort require it. It is also
useful and is used in COBOL 6.50. It is mandatory if
the program is too large for computer memory requiring
it to be segmented. Secondly you may some day want to
write COBOl programs for mainframes or port the programs
that you have already written over to mainframes and you
would need to know how these sections are used.
The Main Line Section
The programs start to execute at the first verb of the
PROCEDURE DIVISION excluding statements and the
declarative section. It is therefore a good idea to
control the program logic in this area. It is also the
first part of the program a programmer would look at.
The most common name for this section is C000-MAIN-LINE.
C00 is a prefix which will be described later on. The
first paragraph of this section as a minimum does the
following:
1) Performs initialization section if any. This section
will execute the initial routines like read and
attail, accept the date used in processing, etc.
2) Open the files to be used in the section.
3) Perform the initial read of the input files.
4) Perform the paragraph that processes the input files
until the end of file perform until.
5) Performs the finalization section if any. This
section executes a final housekeeping routines like
print control, etc.
6) Close files using the section.
7) Issues a stop run statement.
Other Sections
Sections invogued by the mainline section to the perform
statements are coded in the following matter:
1) The first paragraph the section controls through the
perform statement the processing of the whole
section. It therefore does the following:
a) opens all files to be processed in the section.
b) performs initial read of the input files.
PAGE 52
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
Paragraphs
Paragraphs that fall under the section are coded as they
are needed. Each one should only do one function so as
to keep it as simple and as easy to read as possible.
If the paragraph you are currently coding does too many
different functions than you should break it up into
several paragraphs. Seperate all paragraphs from each
other. In front of section headers, space and a line
seperator between them.
Prefixes for Procedure Names
In much the same manner that the prefixes for data names
make it easier to pinpoint their location in the program
listing section and paragraph name should also have
prefixes. This task just is to have the prefix
consisting of a letter followed by 3 digit number
followed by hyphen. You can easily use the letter C for
the first section, F for the second, J for the third,
etc. However you prefer to do it. And have enough
letters in between for future modifications. The digits
start with 000 for the section header and incremented by
20 for the paragraphs. This should give you enough
numbers for the paragraphs in the section. Otherwise
makes succeeding paragraphs have 4 digit numbers in the
prefix.
CHAPTER 9
Screen Processing Format Accept 3
Introduction
One feature of personal computers is of any display unit
which is extensively used to accept data entered by or
displayed for the operator. Unlike typical COBOL
programs written for mainframes where the datas are
generally batched together by the data entry department
unless a teleprocessing package like CICS is used the
ANSI-STANDARD COBOL 6.50 allows use of format it's
grades for easily input and output of information. Much
like an online system the operator may enter data via
the keyboard and this maybe immediately used by the
program to add update retrieve for delete records and
files. We will deal here with the screen processing
based on the format 3 version of the accept verb. This
allows the processing of individual fields as they are
entered in the keyboard. Format 4 processing which is
actually simpler to code will be discussed later on.
PAGE 55
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
Screen Format
We will deal only with the IBM Monochrome Display Unit
which is 24 by 80 columns for information. While there
is a total of 1980 characters that maybe entered the
program generally uses only a portion of this capacity
in applications.
PAGE 57
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
1 - LOW-LEVEL BLUE
2 - LOW-LEVEL GREEN
3 - LOW-LEVEL LIGHT BLUE
4 - LOW-LEVEL RED
5 - LOW-LEVEL MAGENTA
6 - LOW-LEVEL BROWN
7 - LOW-LEVEL WHITE
8 - LOW-LEVEL GRAY
9 - HIGH-LEVEL BLUE
10 - HIGH-LEVEL GREEN
11 - HIGH-LEVEL LIGHT BLUE
12 - HIGH-LEVEL RED
13 - HIGH-LEVEL MAGENTA
14 - HIGH-LEVEL YELLOW
15 - HIGH-LEVEL WHITE
j. The BACKGROUND-COLOR operand is coded as the
FOREGROUND-COLOR operand with the exception
of only the 0 - 9 colors.
k. The "VALUE IS literal" operand is used for
headers and field identifiers or any field
that must contain an initial value when the
screen is displayed. Data fields generally
do not have this operand because the data
will be what is entered by the operator.
l. The "PIC IS picture string" operand is used
for data fields, the "FROM", "TO", and
"USING" operands in certain combinations.
m. For most applications, the "USING
identifier" is the most useful. This means
that the data item will receive the data
entered be the operator via the ACCEPT verb
and will also be the source of the data on
the DISPLAY verb.
n. The "FROM indentifier" operand will contain
data to be displayed on the screen through a
MOVE instruction. This operand functions
only in the DISPLAY mode.
o. The "TO indentifier" operand is used for
data entry fields. This operand functions
only with the ACCEPT verb.
THE DISPLAY VERB
In chapters 3 and 4, I explained the use of the DISPLAY
verb. I will now give a more detailed explanation,
especially on the aspect of the verb that displays data
on the formatted screens. the format is:
DISPLAY screen-name
Screen-name is the same as that defined in the SCREEN
SECTION. The location on the display where the data
items will show is defined in the LINE and COLUMN
operands of that item. If you wish you can write to the
screen location by using the DISPLAY verb. The format
is:
PAGE 58
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
PAGE 59
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
24 PRINTER IS PRINTER-DISPLAY.
25 *
26 *
27 DATA DIVISION.
28 *
29 ***************************************************************
30 * *
31 WORKING-STORAGE SECTION.
32 * *
33 ***************************************************************
34 *
35 * USES OF W005-KEYBOARD-KEY-SWITCH
36 * ] . F9 KEY -- END OF JOB.
37 *
38 01 W005-KEYBOARD-KEY-SWITCH PIC 99.
39 88 W005-F9-KEY-ACTIVATED VALUE 10.
40 *
41 01 W005-RECORD-ACCEPTED-COUNT PIC 9(4) VALUE +0.
42 *
43 01 W010-EMPLOYEE-WK-RECORD.
44 05 W010-EMPLOYEE-WK-NAME PIC X(30).
45 05 W010-EMPLOYEE-WK-STREET PIC X(25).
46 05 W010-EMPLOYEE-WK-CITY PIC X(25).
PROG901 COB 13:38:54 03-Sep-90 PAGE 2
Line Number Source Line ANSI 74-85 Standard Cobol V.6.50(c)1990.
47 /
48 ***************************************************************
49 * *
50 SCREEN SECTION.
51 * *
52 ***************************************************************
53 *
54 *
55 01 SCREEN1-ADDRESS-ENTRY.
56 05 BLANK SCREEN.
57 05 LINE 1 COLUMN 16 VALUE "E M P L O Y E E"
58 HIGHLIGHT.
59 05 LINE 1 COLUMN 35 VALUE "A D D R E S S"
60 HIGHLIGHT.
61 05 LINE 1 COLUMN 52 VALUE "E N T R Y"
62 HIGHLIGHT.
63 05 LINE 3 COLUMN 24 HIGHLIGHT
64 VALUE "NAME:".
65 05 SCREEN1-NAME LINE 3 COLUMN 30
66 PIC X(30)
67 REVERSE-VIDEO
68 USING W010-EMPLOYEE-WK-NAME.
69 05 LINE 5 COLUMN 22 HIGHLIGHT
70 VALUE "STREET:".
71 05 SCREEN1-STREET LINE 5 COLUMN 30
72 PIC X(25)
73 REVERSE-VIDEO
74 USING W010-EMPLOYEE-WK-STREET.
75 05 LINE 7 COLUMN 18 HIGHLIGHT
PAGE 60
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
76 VALUE "CITY/STATE:".
77 05 SCREEN1-CITY LINE 7 COLUMN 30
78 PIC X(25)
79 REVERSE-VIDEO
80 USING W010-EMPLOYEE-WK-CITY.
PROG901 COB 13:38:54 03-Sep-90 PAGE 3
Line Number Source Line ANSI 74-85 Standard Cobol V.6.50(c)1990.
81 /
82 PROCEDURE DIVISION.
83 *
84 ***************************************************************
85 * *
86 C000-MAIN-LINE SECTION.
87 * *
88 ***************************************************************
89 *
90 C020-MAIN-LINE-LOGIC.
91 MOVE 98 TO W005-KEYBOARD-KEY-SWITCH.
92 PERFORM C120-DISPLAY-NEW-SCREEN.
93 PERFORM C040-PROCESS-NAME-ENTRY
94 THRU C100-PROCESS-SCREEN-EXIT
95 UNTIL W005-F9-KEY-ACTIVATED.
96 PERFORM C980-EOJ-ROUTINE.
97 STOP RUN.
98 *
99 C040-PROCESS-NAME-ENTRY.
100 ACCEPT ( 3, 30 )
101 W010-EMPLOYEE-WK-NAME.
102 ACCEPT W005-KEYBOARD-KEY-SWITCH FROM ESCAPE KEY.
103 IF W005-F9-KEY-ACTIVATED
104 GO TO C100-PROCESS-SCREEN-EXIT.
105 *
106 C060-PROCESS-STREET-ENTRY.
107 ACCEPT ( 5, 30 )
108 W010-EMPLOYEE-WK-STREET.
109 ACCEPT W005-KEYBOARD-KEY-SWITCH FROM ESCAPE KEY.
110 IF W005-F9-KEY-ACTIVATED
111 GO TO C100-PROCESS-SCREEN-EXIT.
112 *
113 C080-PROCESS-CITY-ENTRY.
114 ACCEPT ( 7, 30 )
115 W010-EMPLOYEE-WK-CITY.
116 ACCEPT W005-KEYBOARD-KEY-SWITCH FROM ESCAPE KEY.
117 IF W005-F9-KEY-ACTIVATED
118 GO TO C100-PROCESS-SCREEN-EXIT.
119 EXHIBIT NAMED W010-EMPLOYEE-WK-NAME UPON PRINTER-DISPLAY.
120 EXHIBIT NAMED W010-EMPLOYEE-WK-STREET UPON PRINTER-DISPLAY.
121 EXHIBIT NAMED W010-EMPLOYEE-WK-CITY UPON PRINTER-DISPLAY.
122 ADD 1 TO W005-RECORD-ACCEPTED-COUNT.
123 PERFORM C120-DISPLAY-NEW-SCREEN.
124 C100-PROCESS-SCREEN-EXIT. EXIT.
125 *
126 C120-DISPLAY-NEW-SCREEN.
127 MOVE SPACES TO W010-EMPLOYEE-WK-NAME
PAGE 61
ANSI-COBOL 6.50
USERS MANUAL
COPYWRITE 1990
128 W010-EMPLOYEE-WK-STREET
129 W010-EMPLOYEE-WK-CITY.
130 DISPLAY SCREEN1-ADDRESS-ENTRY.
PROG901 COB 13:38:54 03-Sep-90 PAGE 4
Line Number Source Line ANSI 74-85 Standard Cobol V.6.50(c)1990.
131 /
132 C980-EOJ-ROUTINE.
133 IF W005-RECORD-ACCEPTED-COUNT GREATER THAN ZEROS
134 DISPLAY "JOB PROG901: SUCCESSFUL ENTRY COMPLETED"
135 UPON PRINTER-DISPLAY
136 ELSE DISPLAY "JOB PROG901: UNSUCCESSFUL ENTRY"
137 UPON PRINTER-DISPLAY.
138 EXHIBIT NAMED W005-RECORD-ACCEPTED-COUNT
139 UPON PRINTER-DISPLAY.
PAGE 62