CIS COBOL Language Reference
CIS COBOL Language Reference
3Sf)/
-c.
::s ....--1-·
CD CD
><
lN
lf\
"-·
c)\
v
.........
............
t~
~)'..
~
f
C'·
, j.:
~1, .. .: : .
. ':•. ~ ..
CIS COBOL Language Refe r e nc e Manua l
Part no ~ 0900~
Issue no 1
Da t e Feb r uary 198~
~Copyright
~
Acorn Computers Limited 1984
Copyright Micro Focus Limited 1978, 1980, 1982, 1983
Neither the whole nor any part of the information contained in, or the
-
product described in, this manual may be adapted or reproduced in any
material form except with the prior written approval of Acorn Computers
Limited (Acorn Computers).
The ·product described in this manual and products for use with it are
subject to continuous development and improvement. All information of
a technical nature and particulars of the product and its use (including
the information and particulars in this manual) are given by Acorn
-
Computers in good faith. However, it is acknowledged that there may be
errors or omissions in this manual. A list of details of any amendments
or revisions to this manual can be obtained upon request from Acorn
Computers Technical Enquiries. Acorn Computers welcome comments and
suggestions relating to the product and this manual.
Technical Enquiries
Acorn Computers Limited
Fulbourn Road
Cherry Hinton
Cambridge CB1 4JN
CIS COBOL, LEVEL II COBOL, FORMS-2 ANIMATOR and FILESHARE are trademarks
of Micro Focus Ltd
CP/M® and CP/M-86® are registered trademarks of Digital Research Inc
Z80® is a registered trademark of Zilog Inc
ADM-3A™ is a trademark of Lear Siegler Inc
8080® is a registered trademark of Intel Corp
CIS COBOL
LANGUAG~ REFERENCE
MANUAL
Version 4 . 5
r
r
r
~
!
r
r
~j
CONTENTS
r The Nucleus
Table handling
63
134
Sequential input and output 140
Relative input and output 162
Indexed input and output 188
Segmentation 214
Library 219
Debug and interactive debugging 221
Interprogram communication 227
Programming techniques, useful hints and program sizing 234
Index 286
(detailed contents list on page 6)
r
r
,_,
_!
~
J
COBOL is an industry language and is not the property of any company or
group of companies, or of any organization or group of organizations.
r
r
PREFACE
This manual describes the Compact Interactive Standard COBOL (CIS COBOL)
language for programming microcomputers. CIS COBOL is based on the ANSI
COBOL standard X3.23 (1974) (see Acknowledgement). It also describes the
additional CIS COBOL features that exploit the capabilities of
microprocessors.
AUDIENCE
This manual is intended for programmers already familiar with COBOL on other
equipment.
MANUAL ORGANIZATION
Chapters 1 through 4 of the manual apply to all users and describe basic
features of the language. Chapters 5 through 7 describe language features
for programming the three file organization formats supported: sequential,
relative and indexed.
"Chapter 3. Nucleus", which describes the nucleus of all COBOL programs and
the layout of each program division in the nucleus.
2
"Chapter 7. Indexed Input and Output", which describes the programming of
input and output of data in files with indexed format.
"Chapter 10. Debug and Interactive Debugging", which describes the basic and
interactive debugging features available in CIS COBOL.
"Chapter 12. Programming Techniques and Sizing", which describes the means
available for CIS COBOL programmers to estimate object program size and
includes programming techniques in CIS COBOL.
"Appendix A. Reserved Word Table", which lists words reserved for CIS COBOL
functions within a program.
"Appendix D. Compile - Time Errors", which lists all errors that can be
~ signalled during program compilation.
I
"Appendix E. Run-Time Errors", which lists all errors that can be signalled
during program execution.
"Appendix F. Syntax Summary", which summarizes the syntax used in CIS COBOL
programming.
RELATED PUBLICATIONS
3
NOTATION IN THIS MANUAL
1. All words printed in capital letters which are underlined must always
bP present whPn thP functions of which they are a part are used. An
error printout will occur during compilation if the underlined words
are absent or incorrectly spelled. The underlining is not necessary
when writing a COBOL source program.
2. All words printed in capital letters which are not underlined are used
for readability only. They may be written, or not, as the programmer
wishes.
J, All ~ords printed in small letters are generic terms representing names
which will be devised by the programmer.
7. Language features that are shaded in the text are language extensions
which exceed the ANSI standard.
data-name-1 [ !data-name-21
literal-1 ]
data-name-2 or literal-1 must be a positive integer in the range 1
to the number of elements in the table.
4
Readings are presented in this manual in the following order of importance:
CIIAPTER N t
~ Chapter Haading
TITLE
Numbers one (1) to nine (9) are written in text as letters, e.g. one.
Numbers ten (10) upwards ar~ •Jritten in text as numbers, e.g. 12.
The phrase "For documentation purposes only" in the text of this manual
means that the associated coding is accepted syntactically by the Compiler,
but is ignored when producing the object program.
5
TABLE OF CONTENTS
PREFACE
CHAPTER 1
INTRODUCTION
PROGRAM STRUCTURE 31
GENERAL FORMAT 32
SYNTAX RULES 32
GENERAL RULES 33
ELEMENTS 33
SOURCE FORMAT 34 ~
SEQUENCE NUMBER 34
INDICATOR AREA 34
CHAPTER 2
COBOL CONCEPTS
LANGUAGE CONCEPTS 36
CHARACTER SET 36
36
LANGUAGE STRUCTURE ~
Separators 36
Character-strings 38
COBOL Words 38
User-Defined Words 38
Condition-Name 39
Mnemonic-Name 39
Paragraph-Name 39
Section-Name 39
Other User-Defined Names 39
System-Names 39
Reserved Words 40
~
CHAPTER 3
THE NUCLEUS
GENERAL DESCRIPTION 63
ORGANIZATION 63
Structure 63
General Format 63
Sy_nt_a~ Rules 64
THE PROGRAM-ID PARAGRAPH 64
Function 64
General Format 64
Syntax Rules 64
General Rules 64
THE DATE-COMPILED PARAGRAPH 64
Function 64
General Format 64
Syntax Rule 64
General Rule 65
CONFIGURATION SECTION 65
Function 65
General Format 66
Syntax Rules 66
General Rules 66
The SPECIAL-NAMES Paragraph 67
Function 67
General Format 67
General Rules 67
~
I
9
r-
!
-,
DATA DIVISION IN THE NUCLEUS 70
WORKING-STORAGE SECTION 70
Noncontiguous Working-Storage
Working-Storage Records
Initial Values
70
70
70 ..,
THE DATA DESCRIPTION - COMPLETE ENTRY SKELETON 70
Function 70
General Format lilifA.
71
Svn tax R11 1 P.~ 71
General Rule 71
THE Bi.ANK WHEN ZERO CLAUSE 72 ......
Function 72
General Format 72
S:t:ntax Rule 72
General Rules 72 ~
THE DATA-NAME OR FILLER CLAUSE 72
Function 72 ..._,
General Format 72
SJ::ntax Rule 72
General Rule 72
.........,
THE JUSTIFIED CLAUSE 73
Function 73
General Format 73
73
S:t:ntax Rules
73 ~
General Rules
LEVEL-NUMBER 74
Function 74 ~
General Format 74
S:t:ntax Rules ·74
General Rules 74
THE PICTURE CLAUSE 75
-.
Function 75
General Format 75
~
10
Key Words 40
Optional Words 40
Connectives 40
Figurative Constants ·40
Literals ·40
Nonnumeric Literals 41
Numeric Literals ·41
Figurative Constant Values 42
PICTURE Character-Strings 43
Comment-Entries 43
Concept of Levels
Level-Numbers 44
Subscripting 48
Indexing 48
Identifier 49
Condition-Name ·30
PROGRAM STRUCTURE 50
IDENTIFICATION DIVISION 51
GENERAL DESCRIPTION 51
ORGANIZATION 51
STRUCTURE 51
General Format 51
ENVIRONMENT DIVISION 52
GENERAL DESCRIPTION 52
ORGANIZATION 52
STRUCTURE 52
General Format
7
DATA DIVISION 53
OVERALL APPROACH 53
PHYSICAL AND LOGICAL ASPECTS OF DATA DESCRIPTION 53
PROCEDURE DIVISION 55
GENERAL DESCRIPTION 55
Declarations 55
Procedures 55
Execution 56
General Format
Conditional Statement 57
Conditional Sentence 57
Compiler Directing Statement 57
Compiler Directing Sentence 57
Imperative Statement 58
Imperative Sentence 58
REFERENCE FORMAT 59
GENERAL DESCRIPTION 59
REFERENCE FORMAT REPRESENTATION 59
Sequence Numbers 60
Continuation of Lines 60
Blank Lines 60
Division Header 60
Section Header 60
Paragraph Header, Paragraph-Name and Paragraph ·60
RESERVED WORDS 62
8
Syntax Rules 75
General Rules 75
Editing Rules 79
79
Simple Insertion Editing 79
Special Insertion Editing
80
Fixed Insertion Editing
80
Floating Insertion Editing
Zero Suppression Editing 81
Precedence Rules 82
Function 85
General Format ·85
Syntax Rules 85
General Rules ·85
,.._
I
THE SIGN CLAUSE 87
87
Function
General Format 87
Syntax Rules 87
General Rules 87
Function 89
General Format 89
Syntax Rules 89
General Rules 89
Function 91
General Format ·91
Syntax Rules 91
General Rules 91
11
THE VALUE CLAUSE 92
Function 92
General Format 92
Syntax Rules 92
General Rules 92
Data Description Entries 93
CONDITIONAL EXPRESSIONS 94
Simple Conditions 94
Comparison of Numeric 94
Operands
Comparison of Nonnumeric 94
Operands
Class Condition 96
Switch-Status Condition 97
Arithmetic Statements 99
Overlapping Operands 99
Incompatible Data 99
CRT Devices 99
Function 100
General Formats 100
Syntax Rule 100
General Rules 100
Function 103
General Format 103 ~.
Syntax Rules 104
General Rules 104
12
~
r-
THE ALTER STATEMENT 105
106
THE DISPLAY STATEMENT
,.. Function
General Format
Syntax Rules
General Rules
106
106
106
101i
110
THE ENTER STATEMENT
110
r- Function
General
Syntax Rule
110
110
General Rule 110
Function 111
General Format 111
Syntax Rules 111
r-"' General Rules 111
~ Function 112
112
General Format
Syntax Rules 112
General Rules 112
r- THE IF STATEMENT 113
Function 113
General Format 113
~ Syntax Rules 113
113
General Rules
r-
r-
13
r-
THE INSPECT STATEMENT 115
Function 115
General Format 115
Syntax Rules 116
General Rules 116
Function 122
General Format 122 ~
Syntax Rules 122
General Rules 122
Function 125
General Format 125
Syntax Rules 126
~
General Rules 126
Function 127
General Format 127
Syntax Rules
General Rules
131
... \
Function 131
General Format 131
Syntax Rules 131
General Rules 131
Function 132
General Format 132
Syntax Rules 132
General Rules 133
1811\
-1
ttlllllil\
14
CHAPTER 4
TABLE HANDLING
INTRODUCTION TO THE TABLE HANDLING MODULE 134
DATA DIVISION IN THE TABLE HANDLING MODULE 134
r.-
1
THE OCCURS CLAUSE 134
Function 134
General Fomat 134
Syntax Rules 134
General Rules 135
Function 136
General Format 136
Syntax Rules 136
General Rules 136
Function 137
General Fomat 137
Syntax Rules 137
General Rules 138
r CHAPTER 5
Organization 140
Access Mode 140
15
Current Record Pointer 140
I-0 Status 140
Function 145
General Format 145
Syntax Rules 145
General Rules 145
DA~'A DIVISION IN THE SEQUENTIAL I-0 MODULE 146
FILE SECTION 146
RECORD DESCRIPTION STRUCTURE 146
THE FILE DESCRIPTION-COMPLETE ENTRY SKELETON 147
Function 147
General Format 14 7
Syntax Rules 147
Function 148
General Format 148
General Rule 148
16
THE CODE-SET CLAUSE 148
Function 148
General Format 148
Syntax Rules 148
General Rule 148
Function 148
General Format 148
Syntax Rule 149
General Rule 149
Function 149
General Format 149
Syntax Rules 149
General Rules 149
Function 149
General Format 149
General Rule 149
Function 150
General Format 151
General Rules 151
Function 151
General Format 151
Syntax Rule 151
General Rules 151
Function 152
General Format 152
Syntax Rules 152
General Rules i52
17
....
\
Function 155
General Format 155
Syntax Rules 155
General Rules 155
Function 157
General Format 157
Syntax Rules 157
General Rules 157
Function 156
General Format 156
Syntax Rules 156
General Rules 156
Function 159
General Format 159
Syntax Rules 159
General Rules 159
CHAPTER 6
Organization 162
Access Modes 162
Current Record Pointer 162
I-0 Status 162
16
ENVIRONMENT DIVISION IN THE RELATIVE I-0 HODULE 166
Function 166
General Format 166
Function 166
General Format 166
Syntax Rules 166
General Rules 167
Function 168
General Format 168
Syntax Rules 168
General Rules 168
Function 169
General Format 169
Syntax Rules 170
Function 170
General Format 170
General Rules 170
Function 170
~ General Format 170
I Syntax Rule 170
General Rule 170
19
~
Function 171
Format 171
S~ntax Rul~ 171
General Rule 171
Function 171
Format- 171
General P.ules 171
Function 174
General Format 174 ~
S~ntax Rules 174
General Rules 174
Function 177
General Format 177 ~
S~ntax Rules 177
General Rules 177
~.
...
20
r-·
THE REWRITE STATEMENT 181
Function 181
General Format 18\
~tax Rules \81
General Rules 181
Function 183
General Format 183
Svntax Rules 183
General Rules 183
THE USE STATEMENT Hl5
Function 185
General Format 185
Syntax Rules 185
General Rules 185
Function 186
General Format 186
Syntax Rules 186
General Rules 186
CHAPTER 7
Organization 188
Access Modes 188
Current Record Pointer 188
I-0 Status 189
21
p-.
\
ENVIRONMENT DIVISION IN THE INDEXED I-Q MODULE 192
Function 192
General Format 192
The File ~ontrol Entry 192
Function 192
General Format 192
Synt:ax Ru.ies 192
Gen<!ral Rules 193
Function 194
General Format 194
Syntax Rules 194
General Rules 194
Function 195
General Format 195
Syntax Rules 195
Function 196
General Format 196
General Rule 196
THE DATA RECORDS CLAUSE 196
Function 196
General Format 196
Syntax Rules 196
General Rules 196
22
·r-
r-
................
Function 197
General Format 197
~ General Rule 197
Function
r-' General Format
197
197
,. General Rules
PROCEDURE DIVISION IN THE INDEXED I-0 MODULE
198
Function 198
General Format 198
L S:t:ntax Rule
General Rules
198
198
Function 200
r-' General Format
S:t:ntax Rules
200
200
General Rules 200
r
r-
i,.,-~
23
~
THE REWRITE STATEMENT 206
~
Ful"ction ~06
General Format 206
S~ntax Rules 206
General Rules 206
~'
THE START STATEMENT 208
Function 208
General Format 208
208 ~
S~ntax Rules
General Rules 208
Functi on 210
General Format 210
S~ntax Rule's 210
General Rules 210
SEGMENTATION
fillr,ij
'
INTRODUCTION TO THE SEGMENTATION MODULE 214
GENERAL DESCRIPTION OF SEGMENTATION 214
ORGANIZATION 214 ~
24
STRUCTURE OF PROGRAM SEGMENTS 216
CHAPTER 9
LIBRARY
FUNCTION 220
GENERAL FORMAT 220
SYNTAX RULES 220
GENERAL RULES 220
CHAPTER 10
INTRODUCTION 221
CIS COBOL RUN-TIME DEBUG EXTENSION 221
STANDARD ANSI COBOL DEBUG 221
Function 222
General Format 222
General Rules 222
25
PROCEDURE DIVISION IN COBOL DEBUG 223
Function 223
General Format 223
Syntax Rules 223
General Rules 223
CHAPTER 11
INTERPROGRAM COMMUNICATION
INTRODUCTION TO THE INTER-PROGRAM COMMUNICATION MODULE 227 fM!li,
DATA DIVISION IN THE INTER-PROGRAM COMMUNICATION MODULE 227
Function 230
General Format 230
Syntax Rules 230
General Rules 230
Function 232
General Format 232
Syntax Rules 232
General Rules 232
THE EXIT PROGRAM STATEMENT 233
Function 233
General Format 233
Syntax Rules 233
General Rule 233
26
CHAPTER 12
27
APPENDIX A
RESERVED WORD LIST
APPENDIX B
CHARACTER SETS AND COLLATING SEQUENCE
APPENDIX C
GLOSSARY
APPENDIX D
COMPILE-TIME ERRORS
APPENDIX E
RUN-TIME ERRORS
APPENDIX F
SYNTAX SUMMARY
APPENDIX G
SUMMARY OF EXTENSIONS TO ANSI COBOL
APPENDIX H
SYSTEM DEPENDENT LANGUAGE FEATURES
APPENDIX I
LANGUAGE SPECIFICATION
ALPHABETIC INDEX
28
TABLES
Table
ILLUSTRATIONS
29
CHAPTER 1
INTRODUCTION
Nucleus
Table Handling
Sequential Input and Output
Relative Input and Output
Indexed Input and Output
Segmentation
Library
Inter-Program Communication
Debug .
The package has been proved to meet and exceed the COBOL ANSI standard
X3.23 and has been certified by the Federal Compiler Testing Center (FCTC)
under the direction of the General Services Administration (GSA) as
validated at Federal Low Intermediate Level. The GSA Validation Summary
Report is available under the reference CCVS74-VSR685.
Along with the ANSI implementation CIS COBOL also contains several
language extensions specifically oriented to the small computer environment,
These enable a CIS COBOL program to format CRT screens for data input and
output (DISPLAY and ACCEPT), READ and WRITE text files efficiently and
define external file names at run time.
The CIS COBOL System also contains a powerful utility called FORMS-2
that enables the Operator to define screen layouts from a screen "module"
and produce automatically the data description for direct inclusion in a
CIS COBOL program. This is described in the CIS COBOL Operating Guide
CIS COBOL programs are created using a conventional- text editor, The
Compiler compiles the programs and the Run-Time system links with the
compiled output to form a running user program. A listing of the CIS COBOL
program is provided by the Compiler during compilation. Error messages are
inserted in the listing. Interactive Debugging facilities are provided for
run-time use, and these are described in the CIS COBOL Operating Guide.
PROGRAM STRUCTURE
Each division is divided into sections which are further divided into
paragraphs which in turn are made up of sentences.
31
FORMATS AND RULES
GENERAL FORMAT
SYNTAX RULES
Syntax rules are those rules that define or clarify the order in which
words or elements are arranged to form larger elements such as phrases,
clauses, or statements. Syntax rules also impose restrictions on individual
words or elements,
These rules are used to define or clarify how the statement must be
written, i.e,, the order of the elements of the statement and restrictions
on what each element may represent,
GENERAL RULES
ELEMENTS
32
SOURCE FORMAT
The COBOL source format divides each COBOL source record into 72
columns. These columns are used in the following way:
SEQUENCE NUMBER
INDICATOR AREA
Section names and paragraph names begin in Area A and are followed by a
period and a space. Level indications FD, 01 and 77 begin in Area A and are
followed in Area B by the appropriate file and record description.
Note that TAB characters are not permitted in CIS COBOL source.
33
•• Cts COIOL V4.5 ~.CIL PACt: 0001
•• OPTtOIS ftL!crt.D :
P01Ut( 12)
-
000300 02 FtLLU PIC l(l6 ), OIDC 00
000310 02 CJ.T-STOcr.- CODE PIC 1{4) . ou:c 10
000320 02 PILLE'- tlC 1(76). 0"0 l l
000330 02 CllT•PROD-D!SC PIC I U D) . Ol)COO
.. "
000340 02 nLLI:~ Pte lHO) . 0250 74
000]50 02 CllT-UifiT-SI2E PIC 9(4) . o2sc eo ;
000360 02 FtLUR PIC l .
000310 PROC!OOI.E DniStOM . 0000
000)80 9J.l. OOlC 00
0003,0 DISPU.t SfACI. 0010
ooo'oo
000410
OPD t-o STOCII:-nu.
DtsPU.t SCI.£EM-'READ1NCS. ..,,,
0020
........ .....
000510
000520
000530
~V! CllT·STOCt-toD! TO STOCK-CODE.
WRITE S'f'Ocr.-ll"DDI liV.U.lD GO TO CORUCT-tRJDI .
CO to IOIUW.-II'Pt.'T.
..,
ooer
00A1
ooo5•o ~IT.
ooo5~ a.oa noa....nu;. OOA>
00ti60 DISPLAY SPACE,
000) 10 DUPUY ~ or PIOCINf. • OOAC
000580 STOP IWN.
•• Cl5 COIOL '14.S lEVtstOM 4 1JU1 WOOOO/AA
•• COHPILR COP!IlCJn' (C) l'78,Ue2 KI.CI.O f'OC'D'S LTD
--\
•• !IIORJ-00000 DAfAe00161 Cot>l.002S6 Dla-<10'09:20662/Zl01l ~SA IUGJ- OPT
r.~·-
1-6
\
Cols.
12-72
Inserted
by
Sequence Area B Compiler
Number
Col. 7
Indicator
Area
Cols. 8-11
Area A
34
Cfu\PTER 2
COBOL CONCEPTS
LANGUAGE CONCEPTS
CHARACTER SET
The most basic and indivisible unit of the language is the character.
The set of characters used to form CIS COBOL character-strings and
separators includes the letters of the alphabet, digits and special
characters . The character set consists of the characters defined below:
0 to 9
Space
+ Plus sign
Hinus sign or hyphen
* Asterisk
Oblique Stroke/Slash
Foual sign
Dollar sign
Full stop or decimal po int
Comma or decimal point
Semicolon
Quotation mark
Left Parenthesis
Right Parenthesis
> Greater than symbo l
Less than symbol
The CIS COBOL language is restricted to the above charac t er set , but
the conten t of non- numeric literals, comme nt lines and data may include any
of the characters from the ASCII character set . See Append i x B.
LANGUAGE STRUCTURE
Separators
36
may appear in a COBOL source program only where explicitly permitted by
37
Character-Strings
COBOL Words
alphabet-name
condition-name
data-name
Ill! i IBa!l.ii!Btlim~.IIIBII
file- name
. l\1
index-name
level-number
mnemonic-name
paragraph-name
program-name
record-name
section-name
segment-number
text-name
alphabet-names
condition-names, data-names, and record-names
file-names
index-names
mnemonic-names
paragraph-names
program-names
section-names
text-names
38
With the exception of paragraph-name, section-name, level-number and
segment-number, all user-defined words mus·t contain at least one alphabetic
character. Segment-numbers and level-numbers need not be unique; a given
specification of a segment-number or level-number may be ir!entical to any
other segment-number or level-number and may even be identical to a
paragraph-name or section-name.
Other User-Defined
Names: See the glossary in Appendix C for definitions of all
other types of user-defined words.
1. computer-name
2. implementor-name
3. language-name
39
Within a given implementation these three types of
system-names form disjoint seta; a given system-name may
belong to one and only one of them.
-
semicolon).
Figurative
Constants: Certain reserved words are used to name and reference
specific constant values. These reserved words are
specified under Figurative Constant Values in this
chapter.
Literals
40
,.., 1
Nonnumeric
Literals: A nonnumeric lit e r al is a character- string delimited on
both ends by quotation marks and consisting of any
allowable cha r acter in th e computer's character set.
Allowed are nonnume ric lit e rals of 1 t hrough 128
c haracters in l e ng th. To repr es<> nt a sing l e quo t a t ion
mark character wi thin a nonnumeric literal, two
cant i guous quo t a tion marks must be us ed . The value of a
nonnumeric literal in the object program is the string
of c harac t e rs itself, exce pt:
41
Figurative Constant
Values
The figurative constant values and the reserved words used to reference them
are shown in Table 2-1.
CONSTANT REPRESENTATION
ALL literal
.
n.onnumer:!i: 'u te l:li:l or a fig·1rative constant
other than ALL literal. When a figurative
constant is used, the word ALL is redundant
and is used for readability only.
42
item, the string of characters specified by the figurative constant is
~ .. repeated character by character on the right until the size of the
resultant string is equal to the size in characters of the associated
data item. This is done prior to and independent of the application of
any JUSTIFIED clause that may be associated with the data item.
t·!h~n the £i6ur<i·.n:: con3tants HIGH--\YALUE(::;) CoL LOW-VALU::{S) aLt: IJat:tl l.n
the source program, the artual character associated with each figurative
constant depends upon the program collating sequence specified. (See
THE OBJECT-COMPUTER PARAGRAPH, and THE SPECIAL-NAMES PARAGRAPH in Chapter
3).
PICTURE Character-Strings
Comment-Entries
·~
I _ A comment-entry is an entry in the Identification Division that may be
any combination of characters from the computer's character set.
Concept of Levels
43
concept arises from the need to specify subdivisions of a record for the
purpose of data reference. Once a subdivision has been specified, it may be
further subdivided to permit more detailed data referral.
The most basic subdivisions of a record, that is, those not further
subdivided, are called elementary items; consequently, a record is said to
consist of a sequence of elementary items, or the record itself may be an
elementary item.
Level-Numbers
Two types of entries exist for which there is no true concept o£ level.
These are:
The five categories of data items (see THE PICTURE CLAUSE in Chapter 3)
are grouped into three classes : alphabetic, numeric, and alphanumeric. For
alphabetic and numeric, the classes and . categories are synonymous. The
alphanumeric class includes the categories of alphanumeric edited, numeric
edited and alphanumeric (without editing). Every elementary item except for
an index data item belongs to one of the classes and to one of the
categories. The class of a group item is treated at object time as
alphanumeric regardless of the class of elementary items subnrdinate to that
group item. Table 2-2 depicts the relationship of the class and categories
of data items.
44
r-
1
45
Table 2-3. Numeric Data Storage for the COMP(UTATIONAL) PICTURE
Clause.
Number of Characters
Bytes Required Signed Unsigned
1 1-2 1-2
2 3-4 3-4
3 5-6 5-7
4 7-9 8-9
5 10-11 10-12
'> 12-14 12-14
7 15-16 15-16
8 17-IR l?-18
EXAMPLE:
0 2 3 4 F
byte
46
Table 2-4 shows the storage requirements for each COMP-3 clause.
-
Ta bl e 2 4 Numeric Data Storage. f or t he COMPUTATION-3 PICTURE Clause.
Number of Digits
Bvtes Required (Signed or Unsi2ned)
1 1
2 2-3
3 4-5
4 6-7
5 8-9
6 10-11
7 12-13
8 14-15
9 16-17
10 18
Algebraic Signs
Algebraic signs fall into two categories: operational signs, which are
associated with signed numeric data items and signed numeric literals to
indicate their algebraic properties; and editing signs, which appear on
edited reports to identify the sign of the item.
Editing signs are inserted into a data item through the use of the sign
control symbols of THE PICTURE CLAUSE.
2. If the receiving data item is a numeric edited data item, the data
moved to the edited item is aligned by decimal point with zero fill or
truncation at either end as required within the receiving character
positions of the data item, except where editing requirements cause
replacement of the leading zer0s.
47
3. If the receiving data item is alphanumeric (other than a numeric edited
data i tern), alphanumeric edited or alphabetic, the sending data is
moved to the receiving character positions and aligned at the leftmost
character position in the data item with space fill or truncation to
the right, as required.
Uniqueness of Reference
Subscripting
48
fiR
c --
parenthesis following the table element data-name. The occurrence number
resulting from relative indexing is determined by incrementing (where the
operator+ is used) or decrementing (when the operator- is used), by the
value of the literal, the occurrence number represented by the value of the
index. When more than one index-name is required, they are written in the
order of successively less inclusive dimensions of the data organization .
hndex-name-2
)literal-1
Identifier
Format 1:
Format 2:
( j index-name-11 [{+t literal- 2]
data-name-1
) literal-1 r
-r
[. jindex-name-2/[{+\
)literal-3 r - literal-4] [ • ) literal-5 r
jindex-name-31[{ .±rliteral-6
t J]] )
Restrictions on subscripting and in~exing are:
49
4. Literal-!, literal-3, literal-S, in the above format must be positive
numeric integers. Literal-2, literal-4 , literal-6 mus t be unsigned
numeric integerti.
Condition- Name
PROGRAM STRUCTURE
Each division, is divided into sections which are further divided into
paragraphs, which in turn are made up of sentences .
I f the operator enters the FLAG direc tbe at compile time ANSI1 requ irements
imp l emented in CIS COBOL are mandatory depending . on ••their· leve l ' as -. s pecified·
by the Federal Compiler Testing Center under the direction of the Gener al
Ser-Vic e s Administration (GSA) . See the description of the C0111pil.er FLAG
directive in the CIS COBOL Operating Guide. -w= .
50
IDENTIFICATION DIVISION
ORGANISATIO~
STRUCTURt:
General tormat
fiDE:NTIFlCATION DIVISION.t
tPROGRAN-10. program-name.t
51
ENVIRONMENT DIVISION
GENERAL DESCRIPTION
ORGANIZATION
STRUCTURE
General Format
f ENVIRONMENT DIVISION. f
f CONFIGURATION SECTION. f
f SOURCE-COMPUTER. source-computer-entry f
f OBJECT-COMPUTER. object-computer-entry f
[ SPECIAL-NAMES. special-names-entry ]
f INPUT-OUTPUT SECTION. f
f FILE-CONTROL.} !tile-control-entry/
[ 1-0-CONTROL. input-output-control-en!ry
52
DATA DIVISION
OVERALL APPROACH
The Data Division describes the data that the object program is to
accept as input, to manipulate, to create, or to produce as output, Data to
be processed falls into three categories:
The FILE SECTION defines the structure of data files. Each file is
defined by a file description entry and one or more record descriptions, or
by a file description entry and one or more report description entries.
Record descriptions are written immediately following the file description
entry. The WORKING-STORAGE SECTION describes records and noncontiguous data
items which are not part of external data files but are developed and
processed internally, It also describes data items whose values are
assigned in the source program and do not change during the execution of the
object program. The LINKAGE SECTION appears in the called program and
describes data items that are to be referred to by the calling program and
the called .. program. Its structure is the same as the WORKING-STORAGE
SECTION.
r-'1
\
r-
r- 53
r-'
i...t:lll.· ral FonT&dt
The following gives the general fonnat of the sections in the Data
Division, and defines the order of their presentation in the source program.
[FILE~.
[file-description-entry [record-description-entry],~.] ••• ]
[WORKING-STORAGE SECTION.
l! 7/-levdeld-desciri~tion-entry 1 J .. ·]
recor - escr pt1on-entry I
[~SECTION.
ion-entry! J
[! 77-level-descript
record-description-entry ... J
Blf!
I
54
PROCEDURE DIVISION
GENERAL DESCRIPTION
Declaratives
Procedures
The end of the Procedure Divis i on and the physical end of the program
is that physical position in a COBOL source program after which no further
procedures appear.
55
Execution
General Format
The body of the Procedure Division must conform to one of the following
formats:
Format 1:
[DECLARATIVE$.
J ... !
[£paragraph-name-}
Format 2 :
)£paragraph-name.}
[sentence]
[sentence]
.• .
... ! ...
..,
STATEMENTS AND SENTENCES
1. Conditional statements,
2. Compiler directing statements ,
3. Imperative statements.
l. Conditional sentences,
2. Compiler directing sentences,
3. Imperative sentences.
56
Conditional Statement
* An IF statement.
Conditional Sentence
57
Imperative Statement
ACCEPT GO SET
ADD
1
INSPECT START
2
CLOSE PERFORM
2 READ4
DELETE
RDIRITE
2
DISPLAY
1
DIVIDE
EXIT
1
2
3
4
-
-
-
-
5 -
Without
Without
Without
Without
Without
the
the
the
the
the
optional
optional
optional
optional
optional
SIZE ERROR phrase.
INVALID KEY phrase.
ON OVERFLOW phrase.
AT END phrase or INVALID KEY phrase.
INVALID KEY phrase or END-DF-PAGE phrase.
-
;
Imperative Sentence
58
REFERENCE FORMAT
GENERAL DESCRIPTION
The reference format, which provides a standard method for describing
COBOL source programs, is described in terms of character positions in a
line on an input-output medium. The CIS COBOL compiler accepts source
programs written in reference format and produces an output listing of the
source program input in reference fonnat.
The rules for spacing given in the discussion of the reference format
take precedence over all other rules for spacing.
_:l ~ ~1 ~
3 _4_ _ s__
Area A
3
Area B
Indicator Area
The sequence number area occupies six character positions (1-6), and is
between Margin L and Margin C.
r 59
r
Sequence Numbers
Continuation of Lines
Blank Lines
Division Header
Section Header
60
r
The first sentence or entry in a paragraph begins either on the same
line as the paragraph header or paragraph-name or in area B of the next
nonblank line that is not a comment line. Successive sentences or entries
either begin in area B of the same line as the preceding sentence or entry
or in area B of the next no~blank line that is not a comment line.
When the sentences or entries of a paragraph require more than one line
they may be continued as described in CONTINUATION OF LINES in this Chapter.
There are two types of Data Division entries: those which begin with a
level indicator and those which begin wiL:. a level-number.
In those Data Division entries that begin with a level indicator, the
level indicator begins in area A followe' by a space and followed in area B
with its associated name and appropriate descriptive information.
Those Data Division entries that begin with level-numbers are called
data description entries.
A level-number has a value taken from the set of values 1 through 49,
77. Level-numbers in the range 1 through 9 may be written either as a
single digit or as a zero followed by a significant digit. At least one
space must separate a level-number from the word following the level-number.
Successive data description entries may have the same format as the
first or may be indented according to level-number. The entries in the
output listing need ~e indented only if the input is indented. Indentation
does not affect the magnitude of .a level-number.
61
DECLARATIVES
-
The key word DECLARATIVES and the key words END DECLARATIVES that
precede and follow, respectively, the declaratives portion of the Procedure
Division must each appear on a line by themselves, Each must begin in area
A and be followed by a period and a space (see Figure 2-1).
COMMENT LINES
RESERVED WORDS
62
r
CHAPTER 3
THE NUCLEUS
GENERAL DESCRIPTION
ORGANIZATION
Structure
General Format
{ IDENTIFICATION DIVISION }
f PROGRAM-ID. program-name. }
[ AUTHOR. [comment-entry] ]
[ INSTALLATION. [comment-entry] ]
[ DATE-WRITTEN. [ comment-entry] ]
r [ DATE-COMPILED. [comment-entry] ]
[ SECURITY. [comment-entry] ]
63
Syntax Rules
General Format
PR0GRAH-ID. program-name.
Syntax Rules
General Rules
l. The PROGRAH-ID paragraph must contain the name of the program and must
be present -in every program ·~~~1tr
·i1Jfi
Function
General Format
DATE-COMPILED. comment-entry
Syntax Rule
64
General Rule
CONFIGURATION SECTION
Function
General Forma t
Syntax Rule
General Rules
Function
65
General Format
~]
OBJECT-COMPUTER. computer-name [ MEMORY SIZE integer
[,SEGMENT-LIMIT Ji segment-number)
Syntax Rules
General Rules
66
The SPECIAL- NAMES Paragraph
Func tion
General Format
SPECIAL- NAMES.
I· SYSIN l IS
[ /. SYSOUT ~
,TAB IS mnemonic - name]
[. alphabet-name IS
STANDARD-!}]
{ NATIVE
Genera l Ru l es
67
clause specifies a collating sequence. When alphabet - name is
referenced in a CODE-SET clause in a file description entry (see The
File Description Complete Entry Skeleton in Chapter 5), the
alphabet - name clause specifies a character code set.
4. The character that has the highest ordinal position in the program
collating sequence specified is associated with the figurative constant
HIGH- VALUE . If more than one character has the highest position in the
program collating sequence, the last character specified .
5. The character that has the lowest ordinal position in the program
co l lating sequence specified is associated with the figurative constant
LOW- VALUE . If more than one character has the lowest position in the
program collating sequence, the first character specified is associated
with the figurative constant LOW-VALUE.
* digits 0 ~hru 9;
* alphabetic characters A, B, C, D, L, P, R, S, V, X, Z, or the
space;
* special characters ' * ' '+'' ';'' '(', I) I '
' I' or '='.
If this clause is not present, only the currency sign is used in the
PICTURE clause .
7. The clause QECIMAL - POINT IS COMMA means that the fun c tion of comma and
period are exchanged in the character- string of the PICTURE clause and
in numeric literals .
8.
9.
68
clause
of the
at ' start
facility when programming
operator need then only.,; move the
'"'t '"""''n:, px;lss RETURN or jhst press
contains the, name qt;jf:'a PlC< 999.9 , field vhich:;., the most
99 represen.t s a liiie · .count ' in , thef range to the maximum
lines OD thE\ , user'S screeD, and die significant 99
the· maximum ·
output
as for
be used ,
only·
69
DATA DIVISION IN THE NUCLEUS
Noncontiguous Working-Storage
* Level-number 77
* Data-name
* The PICTURE clause or the USAGE IS INDEX clause
Other data description clauses are optional and can be used to complete
the description of the item if necessary.
Working-Storage Records
Initial Values
Function
70
General Format
level-number { data-name-1}
FILLER
[; REDEFINES data-name-2]
~ {:i~URE} IS character-string]
COMPUTATIONAL ]
[ ( COMP
lS )?CoMPUTATlONAL-3
COMP-3
DISPLAY
LEADING }
(SIGN IS] { TRAI'i:ING [SEPARATE CHARACTER)]
SYNCHRONIZED} { LEFT } ]
{ SYNC RIGHT
JUSTIFIED }
{ JUST RIGHT]
[; VALUE IS literal]
Syntax Rules
2. The clauses may be written in any order with two exceptions: the
data-name-1 or FILLER clause must immediately follow the level-number;
the REDEFINES clause, when used, must immediately follow the
data-name-1 clause.
3. The PICTURE clause must be specified for every elementary item except
an index data item, in which case use of this clause is prohibited.
General Rule
The clauses SYNCHRONIZED, PICTURE, JUSTIFIED, and BLANK WHEN ZERO, must
not be specified except for an elementary data item.
71
THE BLANK WHEN ZERO CLAUSE
Function
The BLANK WHEN ZERO clause permits the blanking of an item when its
value is zero.
General Fonnat
Syntax Rule
The BLANK WHEN ZERO clause can be used only for an elementary item
wh:~sePICTURE is specified as numeric with implicit or explicit USAGE IS
DISPLAY, or numeric edited. (See THE PICTURE CLAUSE later in this Chapter).
General Rules
1. When the BLANK WHEN ZERO clause is used, the item will con<:.'i.n nothing
but spaces if the value of the item is zero .
2. When the BLANK WHEN ZERO clause is used for an item whose PICTURE is
numeric, the category of the item is considered to be numeric edited.
Function
A data-name specifies the name of the data being described. The word
FILLER specifies an elementary item of the logical record that cannot be
referred to explicitly.
General Fonnat
data-name}
{ FILLER
Syntax Rule
General Rule
1. The key word FILLER may be used to name an e:cementary item in a record.
Under no circumstances can a FILLER item be referred to explicitly.
72
THE JUSTIFIED CLAUSE
Function
General Format
JUSTIFIED} RIGHT
{ JUST
Syntax Rules
3. The JUSTIFIED clause cannot be specified for any data item described as
numeric or for which editing is specified.
General Rules
1. When a receiving data item is described with the JUSTIFIED clause and
the sending data item is larger than the receiving data item, the
leftmost characters are truncated. When the receiving data item is
described with the JUSTIFIED clause and it is larger than the sending
data item, the data is aligned at the rightmost character position in
the data item with space fill for the leftmost character positions.
2. When the JUSTIFIED clause is omitted, the standard rules for aligning
~ data withir. an elementary item apply. (See Standard Alignment Rules.)
I
r-'
I
r
73
LEVEL NUMBER
Function
General Format
level-number
Syntax Rules
General Rules
74
THE PICTURE CLAUSE
Function
General Format
{ PICTURE
PIC
} IS character-string
Syntax Rules
4. The PICTURE clause must be specified for every elementary item except
an index data item, in which case use of this clause is prohibited.
6. The asterisk when used as the zero suppression symbol and the clause
BLANK WHEN ZERO may not appear in the same entry.
General Rules
There are five categories of data that can be described with a PICTURE
clause: alphabetic, numeric, alphanumeric, alphanumeric edited, and numeric
edited. General rules within these categories are given below:
1. Its PICTURE character-string can only contain the symbols 'A', 'B'; and
75
'9'; if signed, the item may also contain a '+', '-' or other
representation of an operational sign. (see THE SIGN CLAUSE later in
this Chapter).
b. The character-string must contain at least one 'O', 'B', '/', 'Z',
'*', '+', ',', '.', '-', 1 CR', 'DB', or currency symbol.
2. The contents of the character positions of these symbols that are
allowed to represent a digit in standard data format, must be one of
the numerals.
76
positions. An integer which is enclosed in parentheses following the sybols
'A', ',', 'X', '9', 'P', 'Z', '*', 'B', '/', 'O', '+', '-', or the currency
symbol indicates the number of consecutive occurrences of the symbol. Note
that the following symbols may appear only once in a given PICTURE: 'S',
'V', ' . ' , 'CR', and 'DB'.
Symbols Used
77
X- Each 'X' in the character-string is used to represent a character
position which contains any allowable character from the computer's
character set.
Each (comma)
position into which the character ...
in the character-string represents a character
will be inserted. This character
...
position is counted
must not be the
in the size of the item. The insertion character
last character in the PICTURE character-string.
+, -, CR, DB - These symbols are used as editing sign control symbols. When
used, they represent the character position into which the
editing sign control symbol will be placed. The symbols are
mutually exclusive in any one character-string and each
character used in the symbol is counted in determining the
size of the data item.
78
Editing Rules
NOTE:
Floating insertion editing ahd editing by zero suppression and
replacement are mutually exclusive in a PICTURE clause. Only one type
of replacement may be used with zero suppression in a PICTURE clause.
Simple Insertion Editing . The ',' (comma), 'B' (space), 'O' (zero) ,
and 'I' (stroke) are used as the insertion characters. The insertion
characte,s are counted in the size of the item and represent the position in
the item into which the character will be inserted.
79
character-string is disallowed. The result of spP.cial insertion editing is
the appearnace of the insertion character in the item in the same position
as shown in the character-string.
Fixed Insertion Editing. The currency symbol and the editing sign
control symbols,'+','-', 'CR', 'DB', are the insertion characters. Only
one currency symbol and only one of the editing sign control symbols can be
used in a given PICTURE character-string. When the symbols 'CR' or 'DB' are
used they represent two character positions in det~rmining the size of the
item and they must represent the rightmost character positions that are
counted in the size vf the item. The symbol '+' or 1
-
1
~ when used~ mnc::t he
either the leftmost or rightmost character position to be counted in the
size of the item. The currency symbol must be the leftmost character
RESULT
EDITING SYMBOL IN
PICTURE CHARACTER-STRING DATA ITEM DATA ITEM
POSITIVE OR ZERO NEGATIVE
+ + -
- space -
CR 2 spaces CR
DB 2 spaces DB
The currency symbol and editing sign control symbols '+' or '-' are the
floating insertion characters and as such are mutually exclusive in a given
PICTURE character-string.
The second floating character from the left represents the leftmost
limit of the numeric data that can be stored in the data item. Non-zero
numeric data may replace all the characters at or to the right of this
limit.
80
In a PICTURE character-string, there are only two ways of representing
floating insertion editing. One way is to represent any or all of the
leading numeric character positions on the left of the decimal point by the
insertion character. The other way is to represent all of the numeric
character positions in the PICTURE character-string by the insertion
character.
If the insertion characters are only to the left of the decimal point
in the PICTURE character-string, the result is that a single floating
insertion character will be placed into the character position immediately
preceding either the decimal point or the first non-zero digit in the data
represented by the insertion symbol string, whichever is farther to the left
in the PICTURE character-string. The character positions preceding the
1nsert1on cnaracter are replaced with spaces.
81
the first non-zero digit in the data represented by the suppression symbo;
string or at the decimal point, whichever is encountered first.
The symbols '+', '-', '*' 'Z', and the currency symbol, when used as
floet~ng replacement characters, are mutuallv exrJusive within a given
character-string.
Precedence Rules
82
At least one of the symbols 'A', 'X', 'Z', '9' or'*', or at least two
of the symbols 1 + 1 , ' - ' or 'cs' must be present in a PICIURE string.
~~ . .
Nonftoating Floa1ing Other Symbols
I lnsenion Symbols Insertion Symbols
v p p
d B 0 I
1~1 1:1 lg:l "' 1~1 l~lj!:l'l:l <> 0 9 A 5
I
. . .. . . . .. X
. .
. • .• . .• . . . . .• I· .• . . .
B
. . .• . . . . • ... .
0 l l
I
..• . . . . ... . .
l l l l
.J!.
. . • .• . . . .
l l l
.§ l l
~~
!j 1:1' I
1:)' . l . l
• .• l .. l . l l
1~:1· l
• . l
• . l . l l
.I· .
cs l
1~1' • . l
• l l
•
.l . . . . . . .
{Zll l l l l
j
!:I' • . . . •
,.e
.g Ji' l
• c
£.g
!:I' . • . .. . .
j l l
•
• .• .
..• .. • .• . .
cs' l
cs' •
• 9 • • • l l . l
• . • . l l l
]
.
A
X • l . l
I· . . . .
.:; 5
u
v
. . .• .• .
l l
6 l l l
•
p'
. . .I
l l l l l l
P' l l
-
83
In Table 3-3, non-floating insertion symbols '+' and '-', floating
insertion symbolu 'Z', '*'• '+', '-',and 'cs', and other symbol 'P' appear
twice in the PICTURE character precedence chart. The leftmos~ column and
uppermost row for each symbol represents its use to the left of the decimal
point position. The second appearance of symbol in the row and column
represents its use to the right of the decimal point position.
84
THE REDEFINES CLAUSE
Function
General Format
Syntax Rules
3. This clause must not be used in level 01 entries in the File Section.
(See General Rule 2 of THE DATA RECORDS CLAUSE in Chapter 5).
5. The data description entry for data-name-2 cannot contain -an OCCURS
clause. Neither the original definition nor the redefinition can
include an item whose size is variable as defined in the OCCURS clause.
(See THE OCCURS CLAUSE in Chapter 4).
General Rules
85
3. Multiple redefinitions of the same character positions are permitted.
The entries giving the new descriptions of the character positions must
follow the entries defining the area being redefined, without
intervening entries that define new character positions. Multiple
redefinitions of the same character positions must all use tne
data-name of the entry that originally defined the area.
4. The entries giving the new description of the character positions must
not contain any VALUE clauses.
86
THE SIGN CLAUSE
Function
The SIGN clause specifies the position and the mode of representation
of the operational sign when it is necessary to describe these properties
explicitly.
General Format
LEADING } [SEPARATE CHARACTER]
[SIGN.!.§_] { TRAil.ING
:;yntax Rules
l. The SIGN clause may be specified only for a numeric data description
entry whose PICTURE contains the character 1 S 1 , or a group item
containing at least one such numeric data description entry.
2. The numeric data description entries to which the SIGN clause applies
must be described as USAGE IS DISPLAY.
3. At most one SIGN ~lause may apply to any given numeric data description
entry.
General Rules
l. The optional SIGN clause, if present, specifies the position and the
mode of representation of the operational sign for the numeric data
description entry to which it applies, or for each numeric data
description entry subordinate to the group to which it applies. Tlu,
SIGN clause applies only to numeric data description entries whose
PICTURE contains the character 1 5 1 ; the 1 S 1 indicates the presence of,
but neither the representation nor, necessarily, the position of the
operational sign.
87
3. If the optional SEPARATE CHARACTER phrase is not present, then:
c. The operational signs for positive and negative are the standard
data format characters 1 + 1 and 1 - 1 , respectively.
88
-r
I
THE SYNCHRONIZED CLAUSE
Function
General Format
SYNCHRONIZED} [{LEFT }]
{ SYNC RIGHT
Syntax Rules
General Rules
1. .~~,':~~i~::~i~~#i;-7,~?~~~~~i,~~:~Ji~~~;~!~~~~~~;~ik~~m!~i~ll;
2. This clause specifies that the subject data item is to be aligned in
the computer such that no other data item occupies any of the character
positions between the leftmost and rightmost natural boundaries
delimiting this data item. If the number of character positions
required to store this data item is less than the number of character
positions between those natural boundaries, the unused character
positions (or portions thereof) must not be used for any other data
item. Such unused character positions, however, are included in:
89
7. If the data description of an item contains the SYNCHRONIZED clause and
an operational sign, the sign of the item appears in the normal
operational sign position, regardless of whether the item is
SYNCHRONIZED LEFT or SYNCHRONIZED RIGHT.
b. Any implicit FILLER generated for other data items within that
same taole are generated tor each occurrence of those data items.
90
[lfiiiill
I
Function
The USAGE clause specifiE,s the format of a data item in the computer
storage.
General Format
COMPUTATIONAL
I
[USAGE IS) COMP
DISPLAY
CDMPiiTATIONAL-3
COHF-3
Syntax Rules
General Rules
l. The USAGE clause can be written at any level. If the USAGE clause is
written at group level, it applies to each elementary item in the
group. The USAGE clause of an elementary item cannot contradict the
USAGE clause of a group to which the item belongs.
4. The USAGE IS DISPLAY clause indicates that the format of the data is a
standard data format.
5. If the USAGE clause is not specified for an elementary item, or for any
group to which the item belongs, the usage is implicitly DISPLAY.
6. Space requirements for the various USAGE storage options are given
under Selection of Character Representation and Radix in Chapter· 2 .
91
THE VALUE CLAUSE
Function
The VALUE clause dafines the value of constants, the initial value of
working storage items, the initial value of data items in the Communication
Section.
General Format
VALUE is literal
Syntax Rules
1. The VALUE clause cannot be stated for any items whose size is variatle.
(See THE OCCURS CLAUSE in Chapter 4).
General Rules
l. The VALUE clause must not conflict with other clauses in the data
description of the item or in the data description within the hierarchy
of the item. The following rules apply:
92
Data Description Entries
Rules governing the use of the VALUE clause differ with the respective
sections of the Data Division:
4. The VALUE clause must not be stated in a data description entry that
contains an OCCURS clause, or in an entry that is subordinate to an
entry containing an OCCURS clause . (See THE OCCURS CLAUSE in Chapter
4).
5. The VALIJE clause must not be stated in a data description entry that
contains a REDEFINES clause, or in an entry that is subordinate to an
entry containing a REDEFINES clause.
6. If the VALUE clause is used in an entry at the group level, the literal
must be a figurative constant or a nonnumeric literal, and the group
area is initialized without consideration for the individual elementary
or group items contained within this group. The VALUE clause cannot be
stated at the subordinate levels within this group.
7. The VALUE clause must not be written for a group containing items with
descriptions, including JUSTIFIED, SYNCHRONIZED, or USAGE (other than
USAGE IS DISPLAY).
93
PROCEDURE DIVISION IN THE NUCLEUS
CONDITIONAL EXPRESSIONS
Simple Conditions
Rel~tion Condition
NOTE : The required relational characters I ( I t I ) I ' and '-=' are not
underlined to avoid confusion with other symbols such as I ) I
(Greater than or equal to)
94
Comparison 1 NOT GREATER 1 is a truth tes~ for an 1 equal 1 or 1 less 1
fl\llllll
I
comparison. The meaning of the relational operators is as shown in Table
3-4.
95
The size of an operand is the total number of standard data format
characters in the operand. Numeric and nonnumeric operands may be compared
only when their usage is the same.
Class Condition
The class condition determines whether the operand is numeric, that is,
consists entirely of the characters 'O', '1', '2', '3', ... , '9', with or
without the operational sign, or alphabetic, that is, consists entirely of
the characters 'A', 'B', 'C', ••• , 'Z 1 , space. The general format for the
class condition is as follows:
The NUMERIC test cannot be used with an item whose deta description
describes the item as alphabetic or as a group item composed of elementary
items whose data description indicates the presence of operational sign(s).
If the data description of the item being tested does not indicate the
presence of an operational sign, the item being tested is determined to be
numeric only if the contents are numeric and an operational sign is not
present. If the data description of the item does indicate the presence of
an operational sign, the item being tested is determined to be numeric only
if the contents are numeric and a valid operational sign is present. Valid
operational signs for data items described with the SIGN IS SEPARATE clause
are the standard data format characters, '+' and '-'
96
_,
I
I~
____
The ALPHABETIC test cannot be used with an item whose data description
describes the item as numeric. The item being tested is determined to be
alphabetic only if the contents consist of any combination of the alphabetic
characters 'A' thru 'Z' and the space.
Switch-Status Condition
condition-name
The result of the test is true if the switch is set to the specified
position corresponding to the condition-name.
r
r
97
COMMON PHRASES AND GENF.RAL RULES FOR STATEMENT FORMATS
If, after decimal point alignment, the number of places in the fraction
of the result of an ari.r.hJIIetic operation is greater tha!! the :m.nber of
places pr ovided for the fraction of the resultant-identifier, truncation is
relative to the size provided for the resultant-identifier. When rounding
is requested the abso:ute value of the resultant-identifier is increased by
one whenever the most significant digit of the the excess is greater than or
equal to five.
l!iliiOI!I
I
98
Arithmetic Statements
The arithmetic statements are the ADD, DIVIDE, MULTIPLY, and SUBTRACT
-
statements. Common features are as follows:
l. The data descriptions of the operands need not be the same; any
necessary conversion and decimal point alignment are supplied
L- throughout the calculation.
Overlapping Operands
Incompatible Data
Except for the class condition (See Class Condition in this Chapter),
when the contents of a data item are referenced in the Procedure Division
and the contents of that data item are not compatible with the class
specified for that data item by its PICTURE clause, then the result of such
a reference is undefined. If a numeric display field contains one or more
spaces the spaces are usually treated as if they were zero. This may
present problems in portability if relied upon.
CRT Devices
The CRT is driven directly by ~he run time system via a buffer. The
COBOL programmer moves data into and out of this buffer by means of ACCEPT
and DISPLAY statements. Each ACCEPT or DISPLAY action is relative to the
start of the CRT buffer unless POSITION is specified. The syntax is limited
to inputting to or outputting from a single data name. The data name may be
a group item and several such group items may redefine the same area of
storage .
The use of FILLER data items in record descriptions used for input or
output to a CRT device is subject to special rules. On output, any FILLER
item in a record results in suppression of output for the character
positions it defines. On input, any FILLER item suppresses operator keying
into the character positions it defines.
99
THE ACCEPT STATEHENT
Function
The ACCEPT statement causes data keyed at the CRT console to be made
available to the program in a specified data item
General Formats
Format l
ACCEPT identifier [FROH CONSOLE]
~--:<
Format 2
ACCEPT data-name- 1 1 data -name-2 ~
IHteral-1
J\i'
:.s
l FROM CRT"
.~:::::;,;·~,.
..
,,~~ ~~
Syntax Rule
General Rules
assumes
spec i f CRT
becomes default, This
above . Note: Specifying the AT 2, even
CRT,l;!l omitted :~
Format l
2. The ACCEPT statement reads one line of input data from the system
console device. This input data replaces the contents of th e data item
named by the identifier.
4. If the input line is of the same size as the rece1v1ng data it em, the
transferred data is stored in the receiving data item .
5. If the input line is not of the same size as the receiving data item,
then:
a. If the size of the receiving data item exceeds the size of the
input line, the transferred data is stored aligned to the left in
the receiving data item and the data item is filled with trailing
spaces .
100
b. If the size of the transferred data exceeds 120 bytes, only the
first 120 characters of the input line are stored in the receiving
data i t em . The rema1n1ng characters of the input line which do
not fi t into the receiving data item are igno r ed.
6.
7.
8.
numeri
integ
fields
~:..,."
9.
field.
10.
11.
' 12.
101
102
THE ADD STATEMENT
Function
The ADD statement causes two or more numeric operands to be summed and
the result t o be stored.
General Format
Format 1
103
Format 2
Syntax Rules
3. The composite of operands must not contain more than 18 digits (see The
Arithmetic Statements in this Chapter).
General Rul!'.!!.
1. See The Rounded Phrase, The Size Error Phrase, The Arithmetic
Statements, Overlapping Operands and Incompatible Data in this Chapter.
4. The compiler ensures that enough places are carried so as not to lose
any significant digits during execution. fiiiiOil
!
104
THE ALTER STATEMENT
Function
General Format
Svnt;,nc RttlP~
General Rule
105
THE DISPLAY STATEMENT
Function
General Formats
Format 1
DISPLAY lid e ntifi er-11 • lidentifier-21] [UPON CONSOLE ]
llit eral -1 I [ I h t e ral-2 I
Syntax Rules
Forma t
1. Each literal may be any figura tiv e constant, excep t ALL.
but it
Fo r ma t 1
106
5. If the CRT is capable of d.csplaying data of the same size as the data
it em being output , th e data item is transferred .
(a) If the size of the dat a item being displayed ex c eeds the size of
the data that the CRT is capable of r ece 1v1ng in a single
transf e r, the data beginning with the l e ftmo st character is sto r ed
a ligned to th e l eft in the rece i v ing CRT.
(b) If the size of the data item that th e CRT is ca pabl P of rece1v1ng
exceeris th e s1ze ot the data being transf er r e d, th e transferred
da ta is s t o r ed al i g ned t o the left in the receiving CRT.
Forma t 2
8. The DISPLAY statement is used to' output 'd ata to the CRT in the screen
positions specified.
12. data-name-1 may refer to a record, group or elementary item, but it may
not be subscripted. REDEFINES may be used, in which case the first
description of the data is used and subsequent descriptions are
ignored. OCCURS and nested OCCURS may also be used with the effect that
the repeated data-item is expanded into the full number of time s it
occurs and one definition is thus automatically repeated for many
fielda.
13. DISPLAY SPACE has the effect of clearing the screen at run time (i.e .
filling the -whole screen with spaces). DISPLAY " (one space
character). however, displays only · onespace character.
14. The·i CRT-UNDER phcase · causes the, eiementary 'i£ems moved to the CRT to be
displayed with the underline feat-ure _, present, This fea:.ure is
dependent on the CRT hardware functio.n s '·and is not available on all
makes of CRT ,, (see the CIS COBOj:,_Qperating< quide).
107
~
'·
THE DIVIDE STATEMENT
Function
The DIVIDE statement divides one numeric data item into others and sets
the values of data items equal to the quotient.
General Format
Format 1
Iidentifier-1!
literal-1 INTO identifier-2 [~)
[. identifier-3
Format 2
(ROUNDED)] [;ON SIZE ERROR imperative-statement]
-
identifier-11
lliteral-1 INTO
Iidentifier-21
literal-2
Format 3
identifier-21
lidentifier-11
literal-1 I
BY
lliteral-2 I
Syntax Rules
General Rules
1. See The Roun~ed Phrase, The Size Error Phrase, The Arithmetic
Statements, Overlapping Operands and Incompatible Data in this Chapter
for a description of these functions.
108
~
'
·'
r
fiR1
... __ _ --'
~
I
~
_____.
:
109
THE ENTER STATEMENT
Function
The ENTER statement provides a means of allowing the use of more t~an
one language in the same program.
General Format
l.
General Rule
110
.,
THE EXIT STATEMENT
Function
General Format
EXIT
Syntax Rules
General Rule
111
THE GO TO STATEMENT
Function
General Format
Format 1
c:c !0
Format-2
DEPENDING ON identifier
Syntax Rules
General Rules
112
THE IF STATEMENT
Function
General Format
Syntax Rules
General Rules
113
d. If the condition is false, and the ELSE NEXT SENTENCE phrase is
specified, statement-1 is ignored, if specified, and control
passes to the next executable sentence.
..,
..,
114
r
THE INSPECT STATEMENT
Function
The INSPECT statement provides the ability to tally (Format 1), replace
(Format 2), or tally and replace (Format 3) occurrences of single characters
in a data item.
General Format
Format l
Format 2
CHARACTERS BY ~i~entifier-61
- hteral-4 I
Format 3
REPLACING
CHARACTERS y lidentifier-61
B literal-4 I
~ .I~~ING I •
identifier-51
!literal-3 I BY !1dentifier-61l
I~
? IFIRST I literal-4
115
Syntax Rules
All Formats
S.
6.
identifier-S, identifier-6, and identifier-7 must be one character in
length.
General Rules
All Formats
116
_,
I
~
I
2. For use in the INSPECT statement, the contents of the data item
referenced by identifier-!, identifier-3, identifier-4, idomtifier-S,
identifier-6 or identifier-7 will be treated as follows:
117
no next successive literal-1, literal-3, the character position in
the data item referenced by identifier-! immediately to the right
of the leftmost character position considered in the last
comparison cycle is considered as the leftmost character position,
and the comparison cycle begins again with the first literal-!,
literal-3.
118
referenced by identifier-1, its associated literal-1, literal-3,
or the implied operand of the CHARACTERS phrase participates in
the comparison operation as though the BEFORE phrase had not been
specified.
Format 1
r- 119
Format 2
d.
Format 3
When the adjective FIRST is specified, the leftmost occurrence of
literal-3 matched within the contents of the data item referenced
by identifier-! is replaced by literal-4.
-.
11. A Format 3 INSPECT statement is interpreted and executed as though two
successive INSPECT statements specifying the same identifier-! had been
written with one statement being a Format 1 statement with TALLYING
phrases identical to those specified in the Format 3 statement, and the
other statement being a Format 2 statement with REPLACING phrases
identical to those specified in the Format 3 statement. The general
rules given for matching and counting apply to the Format 1 statement
and the general rules given for matching and replacing apply to the
Format 2 statement.
EXAMPLES
INSPECT word TALLYING count FOR ALL "L", REPLACING LEADING "A" BY "E" AFTER
INITIAL "L".
120
~
I
INSPECT word REPLACING ALL "A" RY "G" BEFORE INITIAL "X".
INSPECT word TALLYING count FOR CHARACTERS AFTER INITIAL "J" REPLACING ALL
11
A11 BY 11 B11
word before: 1 2 X Z A B C D
word after: BBBB B A B C D
121
THE MOVE STATEMENT
Function
General Format
Format l
Syntax Rules
General Rules
is equivalent to:
122
2. Any MOVE in which the sending and rece1v1ng items are both elementary
items is an elementary move . Every elementary item belr:-ngs to one of
the following categories: numeric, a lphab e ti c , a lphanumeric, numeric
edited, alphanumeric ed ited. These catego ri es are described in the
PICTURE clause . Numeric lit erals belong to the category numeric, and
nonnumeric litera ls belongs to the category a lphanumeric. The
figurative co nstant ZERO belongs to the ca tegory numeric. The
figur a ti•Te constant SPACE belongs to the category alphabe tic. All
other fig urative constants belong to the category alphanumeric.
b. A numeric literal , the fig urative cons t ant ZERO, a numeric data
item or a numeric edited data item must not be moved to an
alphabetic data item .
A move from
provided}
L the
ii. the
123
and the size of the sending item will be considered to be one less
than its actual size (in terms of standard data format
characters).
s. Data in Table 3-6 summarizes the legality of the various types of MOVE
statements. The general rule reference indicates the rule that
prohibits the move or the behavior of a legal move.
124
Table 3-6. MOVE Statement Data Categories.
1
- The relevant rule number is quoted in these columns
Function
Format 1
125
Format 2
Syntax Rules
General Rules
1. See The Rounded Phrase, The Size Error Phrase, The Arithmetic
Statements, Overlapping Operands and Incompatible Data in this Chapter.
126
r
THE PERFORM STATEMENT
Function
General Format
Foi11!at 1
Format 2
J
rs
THROUGH 1
PERFORM procedure-name-!~ TIIRU I procedure-name-2
J! identifier-!! TIMES
integer-! 1
Format 3
Syntax Rules
General Rules
127
b. If procedure-name-! is a section-name and procedure-name-2 is not
specified, then the return is after the last statement of the last
paragraph in procedure-name-!.
b. Format 2 is the PERFORM ••• TIMES. The procedures are performed the
number of times specified by integer-! or by the initial value of
the data item referenced by identifier-! for that execution. If,
at the time of execution of a PERFORM statement, the value of the ~.
data item referenced by identifier-! is equal to zero or is
negative, control passes to the next executable statement
following the PERFORM statement. Following the execution of the
procedures the specified number of times, control is transferred
to the next executable statement following the PERFORM statement.
During execution of the PERFORM statement, references to identi-
fier-! cannot alter the number of times the procedures are to be
executed from that which was indicated by the initial value of
identifier-!.
128
condition is true when the PERFORM statement is entered, no
transfer to procedure-name-1 takes place, and control is passed to
the next executable statement following the PERFORM statement.
r- X
a
PERFORM a THRU 111 X
a
PERFORM a THRU m
.. ) m
r- m f
~ X PERFORM a THRU m
I
r f
m ..
)
J
...
r d PERFORM f THRU j
129
7. A PERFORN statement that appears in an independent segmen t can have
within it s r ange , in add ition t o any decla rative sections whose
execution is ca u sed within that r ange , only one of th e follow ing:
130
THE STOP STATEMENT
Function
General Format
STOP RUN }
{ literal
Syntax Rules
General Rules
1. If the RUN phrase is used, then the operating system ending procedure
is instituted.
r
r-
r--
r--
~
131
r-
THE SUBTRACT STAXFMENT
Function
General Format
Format 1
[; ON ~ ~ imperative-statement]
Format 2
Syntax Rules
3. The composite of operands must not contain more than 18 digits. (See
The Arithmetic Statements in this Chapter).
132
General Rules
1. See The Rounded Phrase, The Size Error Phrase, The Arithmetic
Statement, Overlapping Operands and Incomnatible Data in this Chapter.
,_
I
133
CHAPTER 4
TABLE HANDLING
Function
The OCCURS clause eliminates the need for separate entries for repeated
data items and supplies information required for the application of
subscripts or indices.
General Format
Syntax Rules
134
General Rules
1. The OCCURS clause is used in defining tables and other homogenous sets
of repeated deta items. lfuenever the occms clause is used, the
data-name which is the subject of this entry must be either subscripted
or indexed whenever it is referred to in a statement other than USE FOR
DEBUGGING. Further, i f the subject of this entry is the name of a
group item, then all data-names belonging to the group must be
subscripted or indexed whenever they are used as operands, except as
the object of a REDEFINES clause. (See under headings Subscripting,
Indexing and Identifier in Chapter 2) .
2. Except for the OCCURS clause itself, all data description clauses
associated w1th an item whose description includes an OCCURS clause
apply to each occurrence of the item described. (See restriction in
general rule 2 under Data Description Entries Other Than Condition
~in Chapter 3).
135
THE USAGE CLAUSE
Function
The USAGE clause specifies the format of a data item in the compute~
~,
storage.
General ForJiat
Syntax Rules
2. The SYNCHRONIZED, JUSTIFIED, PICTURE, VALUE and BLANK WHEN ZERO clauses
cannot be used to describe group or elementary items described with the
USAGE IS INDEX clause.
General Rules
l. The USAGE clause can be written at any level. If the USAGE clause is
written at a group level, it applies to each elementary item in the
group. The USAGE clause of an elementary item cannot contradict the
USAGE clause of a group to which the item belongs.
136
,... PROCEDURE DIVISION IN THE TABLE HANDLING MODULE
RELATION CONDITION
* The result of the comparison of an index data item with any data
item or literal not specified above is undefined.
OVERLAPPING OPERANDS
Function
General Format
Format 1
identifier-3~
l
SET jidentifier-l [, identifier-2]
index-name-1 [, index-name-2] '"!TO index-name-3
integer-l
Format 2
137
: .
Syntax Rules
General Rules
..
SET statement must correspond to an occurrence number of an element in the
associated table. The value of the index associated with an index-name
after the execution of a PERFORM statement may be undefined. (See THE
PERFORM STATEMENT in Chapter 3).
'
3. In Format 1, the following action occurs:
r-
1
139
CHAPTER 5
LANGUAGE CONCEPTS
Organization
Sequential files are organized such that each record in the file except
the first has a unique predecessor record, and each record except the last
has a unique successor record. These predecessor-successor relationships
are established by the order of WRITE statements when the file is created.
Once established, the predecessor-successor relationships do not change
except in the case where records are added to the end of the file.
Access Mode
I-<> Status
Status Key 1
The leftmost character position of the FILE STATUS data item is known
as Status Key 1 and is set to indicate one of the following conditions upon
completion of the input-output operation.
101 indicates Successful Completion
I 1I indicates At End
IJI indicates Permanent Error
191 indicates an Operating System Error Message
140
The meaning of the above indications are as follows:
Status Key 2
The rightmost chara~ter position of the FILE STATUS data item is known
as Status Key 2 and is used to further describe the results of the
input-output operation. This character will contain ·a value as follows:
Status Kev 2
No Further
Status Key 1 Information
(~)
Successful Completiort (0~ X
At End (l) X
Permanent Error (3) X
Implementor Defined (9) 0/S Error Number
141
The AT END Condition
142
ENVIRONMENT DIVISION IN THE SEQUENTIAL I-D HODULE
INPUT-DUTPUT SECTION
Function
General Format
FILE-CONTROL. j file-control-entry j
Function
The file control entry names a file and may specify other file-related
information.
General Format
SELECT file-name
ASSIGN TO jexternal-f~le-name-literal![, external-file-name-literal!]
------ file-ident1fier I !file-identifier I
[ ; ORGANIZATION IS ),;•;I:6,L-!]
[; ACCESS MODE IS SEQUENTIAL)
Syntax Rules
l. The SELECT clause must be specified first in the file control entry.
The clauses which follow the SELECT clause may appear in any order.
2. Each file described in the Data Division must be named once and only
once as file-name in the FILE-CONTROL paragraph. Each file specified
in the file control entry must have a file description entry in the
Data Divisiorr.
143
...,
5 • When the ORGANIZATION IS S~UENTIAL clause is not specified, the
ORGANIZATION IS SEQUENTIAL clause is implied.
General Rules
1. The ASSIGN
4. Records in the file are accessed in the sequence dictated by the file
organization, This sequence is specified by predecessor-successor
record relationships established by the execution of WRITE statements
when the file is created or extended.
s. When the FILE STATUS clause is specified, a value will be moved by the
operating system into the data item specified by data-name-1 after the
execution of every statement that references that file either
explicitly or implicitly. This value indicates the status of execution
of the statement (See I-Q STATUS in this Chapter).
144
r
The I-Q-CONTROL Paragraph
Function
General Format
I-0-CONTROL.
[ '. ---E--
RER!JNrON jfile-name-l
implementor-name
!] EVERY
~
END OF] {REEL l
[- - UNITf
integer-1 RECORDS
integer-2 CL0CK=UNITS 0'
condition-name
t
filN--l·
[!;{SAME AREA FOR file-name-3 ), file-name-4! .•• } ... ] .
Syntax Rules
5. More than one RER!JN clause may be specified for a given file-name-2.
6. The files referenced in the SAME AREA clause need not all have the same
organization or access.
General Rules
145
~
I
DATA DIVISION IN THE SEQUENTIAL I-0 NODULE
FILE SECTION
In a CIS COBOL program thO! file description entry (FD) represents the
highest level of organisation in the File Section. The File Section header
is followed by a file description entry consisting of a level indicator
(FD), a file-name and a series of independent clauses. The FD clauses
spt!cify the size of the logical and physical records, the presence or
absence of label records, the value of implementor-defiro'!d label items, the
names of the data records which comprise the file. The entry itself · is
terminated by a period.
...
which describe the characteristics of a particular record. Each data
description entry consists of a level-number followed by a data-name if
required, followed by· a series of independent clauses as required. A record
description has a hierarchical structure and therefore the ~~auses used with
I
an entry may vary considerably, depending upon whether or not it is followed
by subordinate entries. The structure of a record description is defined in
CUNCt:PT OF LEVELS in Chapter 2, while the elements allowed in a record
description are shown in the Data Description - Complete Entry Skeleton in
Chapter 3.
..!
'-1
~\
~
146
~
~
I
Function
General Format
FD file-name
{RECORDS }]
[; BLOCK CONTAINS integer-2 1CHARACTERS
[; RECORD CONTAINS (integer-3 TO J integer-4 CHARACTERS]
·, DATA
--
{~IS
RECORDS ARE
}
data-name-3 [, data-name-4] ••. ]
[
(; CODE-SET IS alphabet-name]
Syntax Rule.,
3. One or more record description entries must follow the file description
entry.
147
THE BLOCK CONTAI NS CLAUSE
Function
The BLOCK CONTAINS clause spec i fies the size of a physical record.
General Forma t
BLOCK CONTAINS .
1nteger {RECORDS
CHARACTERS }
General Rule
Function
The CODE- SET clause specifies the cha r acter code se t used t o represent
data on the external media .
General Forma t
1. When the CODE- SET c l ause is specified for a file , all data in tha t fi l e
mus t be described as usage is DISPLAY and any s i gned numeric data must
be describe d with the SIGN IS SEPARATE clause.
2. The alp habe t - name clause refe r enced by th e CODE- SET clause must not
specify the literal phrase.
3. The CODE- SET clause may only be specif i ed for non-disk files .
only.
Function
The DATA RECORDS clause serves only as documen tati on fo r the names of
data records with t heir associated file.
General Format
RECO RD IS } data - name - ! [, data - name - 2)
DATA { RECORDS ARE
148
Syntax Rule
Data-name-1 and data-name-2 are the names of data records and should
have 01 level-number record descriptions, with the same names,
associated with them.
General Rules
1. The presence of more than one data-name indicates that the file
contains more than one type of data record. These records may be of
differing sizes, different formats, etc. The order in which they are
listed is not significant.
2. Conceptually, all data records within a file share the same area. This
is in no way altered by the presence of more than one type of data
record within the file.
Function
1!11&~\1\~~;S~mt~~~~-~lJim
General Format
RECORD IS } {STANDARD}
{ RECORDS ARE OMITTED
Syntax Rule
This clause
General Rule
Function
The RECORD CONTAINS clause specifies the size of data records.
General Format
General Rule
The size of each data record is within the record
de ther efore th is
149
THE VALUE OF CLAUSE
Function
General Format
General Rules
~I
150
PROCEDURE DIVISION IN TilE SEQUENTIAL I-Q MODULE
Function
General Format
General Rules
2. The action taken if the file is in the open mode when a STOP RUN
statement is executed is to close the file. The action taken for a file
that has been opened in a called program and not closed in that program
prior to the execution of a CANCEL statement for that program is to
leave the file open.
151
THE OPEN STATEMENT
Function
General Format
OPEN
1. can be used
2.
General Rules
152
lliiilil
I
Table 5-1. Permissable Combinations of Statements and O:~EN Modes for
Sequential I/0.
READ X X
WRITE X X
REWRITE X
5. A file may be opened with the INPUT, OUTPUT, EXTEND and I-0 phrases in
the same program. Following the init·ial execution of an OPEN statement
for a file, each subsequent OPEN statement execution for that same file
must be preceded by the execution of a CLOSE statement, for that file.
6. Execution of the OPEN statement does not obtain or release the first
data record.
9. If the storage medium for the file permits rewinding, execution of the
OPEN statement causes the file to be positioned at its beginning.
10. For files being opened with the INPUT or I-0 phrase, the OPEN statement
sets the current record pointer to the first record currently existing
within the file. If no records exist in the file, the current record
pointer is set such that the next executed READ statement for the file
will result in an AT END condition. If the file does not exist, OPEN
INPUT will cause an error status.
11. When the EXTEND phrase is specified, the OPEN statement positions the
file immediately following the last logical record of that file.
Subsequent WRITE statements referencing the file will add records to
the file as though the file had been opened with the OUTPUT phrase. ·
I~!fi&~J!9~~&B~,.-~~,A~~~~f!}7~<t;:-;::s;:4fl,~w~r~~~-~1:;;
153
12. and
13. Upon successful execution of an OPEN statement with the OUTPUT phrase
specified, a file is created. At that time the associated file
cont~ins no data records . ~ il
d1 -=l if~ 1111. g-t.;,l ...'n "
154
THE READ STATEMENT
Function
The READ statement makes available the next logical record from a file,
General Format
-~ Syntax Rules
1. The INTO phrase must not be used when the input file contains logical
records of various sizes as indicated by their record descriptions.
The storage area associated with identifier and the record area
associated with file-name must not be the same storage area.
General Rules
1. The associated file must be open in the INPUT or I-0 mode at the time
this statement is executed. (See THE OPEN STATEMENT in this Chapter).
3. The execution of the READ statement causes the value of the FILE STATUS
data item, if any, associated with file-name to be updated. (See 1-o
STATUS in this Chapter) •
5. When the logical records of a file are described with more than one
record description, these records automatically share the same storage
area; this is equivalent to an implicit redefinition of the area. The
contents of any data items which lie beyond the range of the current
data record are undefined at the completion of the execution of the
READ statement.
155
6. If the INTO phrase is specified, the record being read is moved from
the record area to the area specified by identifier according to the
rules specified for the MOVE statement. The implied MOVE does not
occur if the execution of the READ statement was unsuccessful. Any
subscripting or indexing associated with identifier is evaluated after
the record has been read and immediately before it is moved to the data
item.
7. When the INTO phrase is used, the record being read is available in
both the input record area and the data area associated with
identifier •
"• .u, di. th" time of execut1.on of a READ statement, tne position of
current record pointer for that file is undefined, the execution of
that READ statement is unsuccessful.
11. If, at the time of the execution of a READ statement, no next logical
record exists in the file, the AT END condition occurs, and the
execution of the READ statement is considered unsuccessful. (See I-0
STATUS).
12. When the AT END condition is recognized the following actions are taken
in the specified order:
a. A value is placed into the FILE STATUS data item, if specified for
~
this file, to indicate an AT END condition. (See I-Q STATUS). I
b. If the AT END phrase is specified in the statement causing the
condition, control is transferred to the AT END
imperative-statement. Any USE procedure specified for this file
is not executed.
c. If the AT END phrase is not specified, then a USE procedure must
be specified, either explicitly or implicitly, for this file and
that procedure is executed.
14. When the AT END condition has been recognized, a READ statement for
that file must not be executed without first executing a successful
CLOSE statement followed by the execution of a successful OPEN
statement for that file.
156
THE REWRITE STATEMENT
Function
General Format
Syntax Rules
1. Record-name and identifier must not refer to the same storage area.
General Rules
1. The file associated with record-name must be a disk file and must be
open in the I-0 mode at the time of execution of this statement. (See
THE OPEN STATEMENT in this Chapter),
2. The last input-output statement executed for the associated file prior
to the execution of the REWRITE statement must have been a successfully
executed READ statement. The operating system logically replaces the
record that was accessed by the READ statement.
7. The execution of the REWRITE statement causes the value of the FILI:
STATUS data item, if any, associated with the file to be updated. (See
I-0 STATUS in this Chapter).
157
THE USE STATEMENT
Function
General Format
1ffiEND
Syntax Rules
General Rules
3. Within a USE procedure, there must not be any reference to any non-
declarative procedures. Conversely, in the nondeclarative portion
there must be no reference to procedure-names that appear in the
declarative portion, except that PERFORM statements may refer to a USE
statement or to the procedures associated with such a USE statement.
4. Within a USE procedure, there must not be the execution of any state-
ment that would cause the execution of a USE procedure that had
previously been invoked and had not yet returned control to the
invoking routine.
158
THE WRITE STATEMENT
Function
General Format
-[ integer r l
LINE
LTNES.J
L.
l ~~
AfTER ADVANCING
'fA!;
PAGE
Syntax Rules
1. Record-name and identifier-! must not reference the same storage area.
2. -~~!'·' ~ '
, &~dard -ve.l~t;:t•cal
3. The record-name is the name of a logical record in the File Section c.f
the Data Division.
General Rules
1. The associated file must be open in the OUTPUT mode at the time of the
execution of this statement. (See THE OPEN STATEMENT in this Chapter).
3. The results of the execution of the WRITE statement with the FROM
phrase is equivalent to the execution of:
a. The statement:
159
:... -
After execution of the WRITE statement is complete, the
information in th e area r eferenced by identifier-! is available,
even though the information in the area referenced by r ecord-name
may not be . (See ge nera l rule 2.)
5. The execution of the WR ITE stateme nt causes the value of the FILE
STATUS data item, if any, associated with the fil e to be updated. (See
I-0 STATUS in this Chapter).
6. The maximum record size for a file is established · at the time the file
i s created and must not subsequently be changed.
9. The ADVANCING phrase allows control of the ver tical position ing of each
line on a representation of a printed page.
b.
160
~
L
,- If the ADVANCING phrase is used or the output is directed to a
list device, the resulting fi 1e is restricted in its use. In
general, the file cannot be read to automatically retrieve the
,.
logical records written. In particular, if the BEFORE ADVANCING
and AFTER ADVANCING clauses are both used (implicitly or
explicitly) when writing the file, it may not be opened as an
input file with ORGANIZATION LINE SEQUENTIAL.
-- When an attempt is made to write beyond the externally defined bound-
10.
aries of a sequential file, an exception condition exists and the
contents of the record area are unaffected . The following action takes
r- place:
,.. a.
b.
The value of the FILE STATUS data item, if any, of the associated
file is set to a value indicating a boundary violation. (See I-0
STATUS in this Chapter).
r- c.
then be executed.
r-'
r-'
r-
r-
~
,...- ·-·
L 161
r-
CHAPTER 6
LANGUAGE CONCEPTS
Organization
Access Modes
In the sequential access mode, the sequence in which records are accessed is
the ascending order of the relative record numbers of all records "which
currently exist within the file.
In the random access mode, the sequence in which records are accessed is
controlled by the programmer. The desired record is accessed by placing its
relative record number in a relative key data item.
In the dynamic access mode, the programmer may change at will from
sequential access to random access using appropriate forms of input-output
statements.
I-0 Status
162
applicable USE procedure is executed, to indicate to the COBOL program the
Status Key 1
r The leftmost character position of the FILE STATUS data item is known as
status key 1 and is set to indicate one of the following conditions upon
completion of the input-output operation.
Duplicate Key
* No Record Found
* Boundary Violation
*
'3' - Permanent Error. The input-output statement was unsuccessfully
executed as the reult of an input-output error, such as data
check, parity error or transmission error.
Status Key 2
The rightmost character position of the FILE STATUS data item is known
as status key 2 and is used to further describe the reults of the
input-output operation. This character contains a value as follows:
163
* When status key 1 contains a value of 1 2' indicating an INVALID
KEY condition, status key 2 is used to designate the cause of that
condition by the following values:
At End (1) X
Permanent
Error (3) X
Implementor
Defined (9) Operating System Error Message Number
164
The INVALID KEY Condition
The INVALID KEY condition can occur as a result of the execution of a START,
READ, WRITE, REWRITE or DllLETE statement. For details of the causes of .the
condition, see The START Stat~ent, The READ Statement, The WRITE Statement,
The REWRITE Statement, and The DELETE Statement later in this chapter.
When the INVALID KEY condition is recognised, the Operating System takes
these actions in the following order:
1. A value is placed into the FILE STATUS data item, if specified for this
file, to indicate an INVALID KEY cond1.tlun. (!;PP T-{1 StH\.!!! in thi::
Chapter).
165
ENVIRONMENT DIVISION IN THE RELATIVE I-D MODULE
INPUT-oUTPUT SECTION
Function
Function
The file cuntrol entry names a file and may specify other file-related
information.
General Format
SELECT file-name
; ORGANIZATION IS RELATIVE
l]
[
SEQUENTIAL ,RELATIVE KEY IS data-name
; ACCESS MODE IS
[; FILE~
! I RANDOM 1
DYNAMIC I
IS data-name-2).
,RELATIVE KEY IS data-name-1 ~
Syntax Rules
l. The SELECT clause must be specified first in the file control entry.
The clauses which follow the SELECT clause may appear in any order.
2. Each file described in the Data Division must be named once and only
once as file-name in the FILE-cONTROL paragraph. Each file specified
in the file control entry must have a file description entry in the
Data Division.
166
4. Data-name-2 must be defined in the Data Division as a two-character
data item of the category alphanumeric and must not be defined in the
File Section, the Report Section, or the Communication Section.
r General Rules
3. When the access mode is sequential , records in the file are accessed in
the sequence dictated by the file organ i zation. This sequence is the
order of ascending relative record numbers of existing records in the
file.
4. When the FILE STATUS clause is specified, a value will be moved by the
operating system into the data item specified by data-name-2 after the
execution of every statement that references that file either
explicitly or implicitly. This value indicates the status of execution
of the statement. (See I-0 Status in this Chapter).
5. If the access mode is random, the value of the RELATIVE KEY data item
indicates the record to be accessed.
6. When the access made is dynamic, records in the file may be assessed
sequentially and/or randomly . (See General Rules 3 and 5) .
167
The I-Q-CONTROL Paragraph
Function
General Format
I-0-CONTROL.
~
;RERUN Q! ~ file-name-1 ~ integer-! RECORDS OF file-name-2 ~J
EVERY integer-2 CL~CK-UNITS
[ l implementor-name~ condition-name
1. The
4. More than one RERUN clause may be specified for a given file-name-2,
subject to the following restriction:
6. More than one SAME clause may be included in a program but file-name
must not appear in more than one SAME AREA clause.
7. The files referenced in the SAME AREA clause need not all have the same
organization or access.
General Rules
~
I
168
DATA DIVISION IN THE RELATIVE I-Q MODULE
FILE SECTION
In a CIS COBOL program the file description entry (FD) represents the
highest level or organization in the File Section. The File Section header
is followed by a file description entry consisting of a level indicator
(FD), a file-name and a series of independent clauses. The FD clauses
specify the size of the logical and physical records, the presence or
absence of label records, the value of implementor-defined label items, and
the names of the data records which comprise the file. The entry itself is
terminated by ~ period.
Function
General Format
FD file-name
[; ~ CONTAINS integer-2 ~~
CHARACTERS
!]
[; RECORD CONTAINS (integer-3 ~] integer-4 CHARACTERS)
LABEL~~ IS STANDARD!
RECORDS ARE
!
l~
~ .Q! implementor-name-1 IS literal-1
[, implementor-name-2 IS 11teral-2) ]
RECORD IS !
! RECORDS ARE
data-name-3 [, data-name-4] ; ... ] .
169
Syntax Rules
3. One or more re'c ord description entries must follow the file description
e ntry.
Function
Ge nera l Format
General Rules
Function
The DATA RECORDS clause serves only as documentation for the names of
data records with their associated file.
Genera l Format
Data-name-1 and data-name-2 are the names of data records and should
have 01 level-number record descriptions, wi th the same names,
associated with them.
170
~ General Rules
1 __ _
l. The presence of more than one data-name indicates that the file
contains more than one type of data record. These records may be of
differing sizes, different formats, etc. The order in which they are
listed is not significant.
2. Conceptually, all data records within a file share the same area. This
is in no way altered by the presence of more than one type of data
record within the file .
Function
~ General Format
RECORD IS STANDARD}
{ RECORDS ARE OMITTED
Syntax Rule
1'his clause
General Rule
Function
L ~
RECORD CONTAINS [integer-1 TO] integer-2 CHARACTERS
General Rule
The size of each data record is completely defined within the record
description entry, therefore this clause is never required.
171
THE VALUE OF CLAUSE
Function
General Format
[,data-name-2 IS literal-2]
Syntax Rules
General Rules
1.
172
PROCEDURE DIVISION IN THE RELATIVE I-0 MODULE
Function
f-'1
I
General Format
Syntax Rule
The files referenced in the CLOSE statement need not all have the same
organization or access.
General Rules
2. The action taken i f a file is in the open mode when a STOP RUN
statement is executed is to close the file. The action taken for a
file that has been dpened in a called program and not closed in that
program prior to the execution of a CANCEL statement for the program is
to close the file.
173
THE DELETE STATEMENT
Function
General Format
Syntax Rules
1. The INVALID KEY phrase must not be specified for a DELETE statement
which references a file which is in sequential access mode.
2. The INVALID KEY phrase must be specified for a DELETE statement which
references a file which is not in sequential access mode and for which
an applicable USE procedure is not specified
General Rules
1. The associated file must be open in the 1-0 mode at the time of the
execution of this statement. (See THE OPEN STATEMENT later in this
Chapter)
5. The execution of a DELETE statement does not affect the contents of the
record area associated with file-name.
7. The execution of the DELETE statement causes the value of the specified
FILE STATUS data item, i f any, associated with the file-name to be
updated. See J-0 STATUS in this chapter.
174
THE OPEN STATEMENT
Function
General Format
[ , f ile-name-2 ... )
... ) ~ ...
INPUT file-name-1
[=-
)
OPEN
!
OUTPUT file-name-3
I-0 f ile-name-5
[ , file-name-4
( ,file-name-6 ... )
.r The files referenced in the OPEN statement need not all have the same
organization or access.
General Rules
175
Table 6-1. Permissible Combinations of Statements and Open Modes for
Relative I/O
File Access Open Mode
Mode Statement Input Output Input-Output
Sequential READ X X
~ITE X
REWRITE X
STAAT X X
DELETE -l{
Random READ X X
WRITE X X
RE~ITE X
START
DELETE X
Dynamic READ X X
WRITE X X
RE~ITE X
START X X
DELETE X
5. A file may be opened with the INPliT, OliTPliT, AND r-o phrases in the
same program. Following the initial execution of an OPEN statement for
a file, each subsequent execution for that sane file must be preceded
by the execution of a CLOSE statement, for that file.
6. Execution of the OPEN statement does not obtain or release the first
data record.
8. For files being opened with the INPliT or r-o phrase, the OPEN statement
sets the current record pointer to the first record
currently existing within the file. If no records exist in the file,
the current record pointer is set such that the ne xt executed Format 1
READ statement for the file will result in an AT END condition. If the
file does not exist, INPliT will cause an error status.
176
9. The I-0 ~ !!. and output
operations.
10 .
.___.
177
THE READ STATEMENT
Function
For sequential access, the READ statement makes available the next logical
record from a file. For random access, the READ statement makes available a
specified record from a disk file.
General Foi'1118.t
Format l
READ file-name [NEXT] RECORD [INTO identifier] [; A.T END imperative-statement]
Foi'1118.t 2
READ file-name RECORD [INTO identifier] [;!NVALI.£ KEY imperative-statment]
Syntax Rules
1. The INTO phrase must not be used when the input file contains logical
records of various sizes as indicated by their record descriptions. The
storage area associated with identifier and the record area associated
with file-name must not be the same storage area.
2. Format must be used (without the NEXT phrase) for all files in
sequential access mode.
3. The NEXT phrase must be specified for files in dynamic access mode,
when records are to be retrieved sequentially.
4. Format 2 i.s used for files in .random access :node or for files in
dynamic access mode when records are to be retrieved randomly.
General Rules
1. The associated files must be open in the INPUT or I-Q mode at the time
this statement is executed. See THE OPEN STATEMENT in this Chapter
178
r-
r-
r- 3. The execution of the READ statement causes the value of the FILE STATUS
data item, if any, associated with file~ame to be updated. (See I-<l
Status in this Chapter).
5. When the logical records of a file are described with more than one
record description, these records automatically share the same storage
area; this is equivalant to an implicit redefinition of the area. The
contents of any data items which lie beyond the range of the current
data record are undefined at the completion of the execution of the
READ statement.
6. lf the I~TO phrase is specified, the record being read is :noved from
the record area to the area specified by identifier according to the
rules specified for the ~lOVE statement without the CORRESPONDING
phrase. The implied MOVE does not occur if the execution of the READ
statement was unsuccessful. Any subscripting or indexing associated
with identifier is evaluated after the record has been read and
immediately before it is moved to the data item.
7. When the INTO phrase is used, the record being read is available in
both the input record area and the data area associated with
identifier.
10. When the AT END condition is recognized the following actions are taken
in the specified order:
a. A value is placed into the FILE STATUS data item, if specified for
this file, to indicate an AT END condition. (See I-<l Status in
this Chapter)
179
c. If the AT END phrase is not specified, then a USE procedure must
be .. pecified, either explicitly or implicitly, for this file, and
that procedure is executed.
12. When the AT END condition has been recognised, a Format l READ
statement for that file must not be executed without first executing
one of the following:
13. For a file for which dynanic access mode is specified, a Format 1 READ
statement with the NEXT phrase specified causes the next logical record
to be retrieved from tht> file as described in gt!neral rule 2.
15. Tht! execution of a Format 2 READ statement sets the currt!nt record
pointer to, and makes available, the record whose relative record
number is contained in the data item named in the RELATIVE KEY phrase
for the file. If the file does not contain such a record, the INVALID
KEY condition exists and execution of the READ statement is
unsuccessful. (See The INVALID KEY Condition in this Chapter).
,..,
~
I
180
(
!
f'BIII THE REWRITE STATEMENT
!
Function
General Format
Syntax Rules
1. Record-name and identifier must not refer to the same storage area.
3. The INVALID KEY phrase must be specified in the REWRITE statement for
files in the random 9r dynamic access mode for which an appropriate USE
procedure is not specified.
General Rules
l. The file associated with record-name must be open in the I-0 mode at
the time of execution of this statement. (See THE OPEN STATEMENT in
this Chapter) •
181
6. The current record pointer i.s not affected by the exe.::ution of a
REWRITE statement.
7. The execution of the REWRITE statement causes the value oi the FILE
STATUS data item, i.f any, associated with the file to be updated. (See
I-0 STATUS in this Chapter).
182
THE START STATEl'IENT
Function
General Format
IS EQUAL TO
IS =
IS GUATER
IS_>_ __ THAN
IS NOT LESS THAN
IS NOT-<-
NOTE: The required relational characters '>', and '<' and '='
are not underlined to avoid confusion with other symbols
such as '>' (greater than or equal to).
Syntax Rules
General Rules
1. File-name must be open in the INPUT or I-0 mode at the time that the
START statement is executed. (See THE OPEN STATEHENT in this Chapter).
2. If the KEY phrase is not specified the relational operator 'IS EQUAL
TO' is implied.
r
183
b. If the comparison is not sattsfi.ed by any record in the file, an
INVALID KEY condition exists, the execution of the START statement
is unsuccessful, and the position of the current record pointer is
undefined. (See The INVALID KEY Condition in this Chapter).
4. The execution of the START statement causes the value of the FILE
STATUS data item, if any, associated with file-name to be updated. (See
-
I-o STATUS in this Chapter).
....,
...,
...,
_,
,..,
.....
~
~
184
.,
r
THE USE STATEMENT
Function
The USE statement specifies procedures for input-output error handling that
are in addition to the standard procedures provided by the input-output
control system.
General Format
~ ERROR
OUTPUT
~
S::t:ntax Rules
General Rules
1. If the INVALID KEY or AT END phrases have not been specified in the
input-output statement, the designated procedures are executed by the
input-output system after completing the standard input-output error
routine, or upon recognition of the INVALID KEY or AT END conditions.
r
r
~
I
185
THE WRITE STATEMENT
Function
General Format
Syntax Rules
1. Record-name and identifier m••st not reference the same storage area.
General Rules
1. The associated file must be open in the OUTPUT or I-0 mode at the time
of the execution of this statement. (See THE OPEN STATEMENT Chapter).
3. The results of the execution of. the WRITE statement with the FROM
phrase is equivalent to the execution of
a. The statement:
186
!
!
5. The execution of th:! I./RITE statement causes the value of the FILE
STATUS data item, if any, associated with the file to be updated. (tiee
I-o Status in this Chapter).
6. The maximum record size for a file ts established at the time the file
is created and must not subsequently be changed.
!!. The execution of the \.lUTE statement releases a logical record to the
operating system.
9. When a file is opened in the output mode, records may be placed into
the file by one of the following:
10. When a file is opened in the I-0 mode and the access mode is random or
dynamic, records are to be inserted in the associated file. The value
of the RELATIVE KEY data item must be initialised by the program with
the relative record number to be associated with the record in the
record area. Execution of a WRITE statement then causes the contents
of the record area to be released to the Operating System.
11. The INVALID KEY. condition exists under the following circumstances:
a. When the access mode is random or dynamic, and the RELATIVE KEY
data item specifies a record which already exists in the file, or
12. When the INVALID KEY condition is recog"lised, the executior. of the
WRITE statement is unsuccessful, the contents of the record area are
unaffected, and the FILF. STATUS data item, if any, of the, ~tssociated
file is set to a value indicating th" cause of the condition.
Execution of the program proceeds according to the rules stated in The
INVALID KEY Condition in this Chapter see also I-Q Status tn this
Chapter).
187
CHAPTER 7
LANGUAGE CONCEPTS
Organization
The data item named in the RECORD KEY clause of the file control entry
for a file is the record key for that file. For purposes of inserting,
updating and deleting records in a file, each record is identified solely by
the value of its record key. This value must, therefore, be unique and must
;~~~,i~~~~an::: ~~=n C~~da~~;gL t~;e::~~::· Gt:lf'!ti~~;;P!!!!iJ!~~t!l~{
records in a file.
Access Modes
In the random access mode, the sequence in which records are accessed
is controlled by the programmer. The desired record is accessed by placing
the value of its record key in the record key data item.
In the dynamic access mode, the programmer may change at will from
sequential access to random access using appropriate forms of input-output
statements.
,_.,
I
J
188
I-0 Status
Status Key
The leftmost character position of the FILE STATUS data item is known
as statuo key l cdlu J.S S~L co inciicate one of the tollowing conditions upon
completion of the input-output operation.
Sequence Error
Duplicate Key
No Record Found
Boundary Violation
Status Key 2
The rightmost character position of the FILE STATUS data item is known
as status key 2 and is used to further describe the results of the
input-output operation. This character will contain a value as follows:
189
When status key l contains a value of '2' indicating an INVALID KEY
condition, status key 2 contains values to designate the cause of that
condition as follows:
When status key 1 contains a value of '9' the value of status key 2 is
the operating system error message number (for those operating systems
which designate errors numerically). The CIS COBOL Operating Guide
specific to your operating system contains details of tne status-key-2
representation.
Note that it is not possible to extract this number directly.
190
Status Key 1 Status Key 2
At End (1) X
Permanent
Error (3) X
Implementor
Defined (9) Operating System Error Message Number
(O!Ii!l
!
1. A value is placed into the FILE STATUS data item, if specified for this
file, to indicate an INVALID KEY condition. (See I-0 Status).
191
ENVIRONMENT DIVISION IN THE INDEXED I-0 MODULE
INPUT-oUTPUT SECfiON
Function
General Format
FILE-CONTROL. )file-control-entry!···
Function
The file control entry names a file and may specify other file-related
information.
General Format
SELECT file-name
ASSIGN TO j external-file-name-literal!
f ile-iden t if ie r
external-file-name-literal!]
[! ' file-identifier I
ORGANIZATION IS ~
Syntax Rules
1. The SELEcr clause must be specified first in the file control entry.
The clauses which follow the SELECT clause may appear in any order.
2. Each file described 1:1 the Data Division must be named once and only
once as file-name in the FILE-CONTROL paragraph. Each file specified
in the file control entry must have a file description entry in the
Data Division.
192
4. Data-name-3 must be defined in the Data Division as a two-character
data item of the category alphanumeric and must not be defined in the
File Section.
General Rules
3. When the access mode is sequential, records in the file are accessed in
the sequence dictated by the file organization. For indexed files this
sequence is the order of ascending record key values.
~
I
4. When the FILE STATUS clause is specified, a value will be moved by the
operating system into the data item specified by data-name-3 after the
execution of every statement that references that file either
explicitly or implicitly. This value indicates the status of execution
of the statement. (See I-Q STATUS in this Chapter).
6. If the access mode is random, the value of the record key data item
indicates the record to be accessed.
7. When the access mode is dynamic, records in the file may be accessed
sequentially and/or randomly. (See general rules 4 and 6).
8. The RECORD KEY clause specifies the record key for a file. The values
~ of a record key must be unique among records of the file. This record
key provides an access path to records in an indexed file.
193
The I-0 Control Paragraph
Function
General Format
I-0-cONTROL
[
; ~ ON !file-name-1
lmpl.::w..ntor-n..mt!•
1 ~ERY ( integer-1 RECORDS OF file-name-2)
jinteger-2 l:LOCK-Ul'U'l'S
(condition-name l
IJ1
[; SAME AREA FOR file-name-3 G file-name-4] •• • ] •..
Syntax Rules
4. When multiple integer-1 RECORDS clauses are specif i ed, no two of them
may specify the same file-name-2.
5. Only one RERUN clause contai ning the CLOCK-UNITS clause may be
specified.
6. More than one SAME clause (SAME AREA) may be included in a program but
a file-name must not appear in more than one S~~ AREA clause .
7. The files referenced in the SAME AREA clause need not all have the same
organization or access.
General Rules
L- alb: !!BII
~
2. d~lla!llf,&t"!'AII ~· oldj:·.
194
DATA DIVISION IN THE INDEXED 1-0 MODULE
FILE SECTION
Function
General Format
FD file-name
RECORD IS 1 l STANDARD 1l
l RECORDS ARE I OMITTED IJ
[,data-name-2 IS literal-2]
DATA RECORD IS I data-name-3 [ ,data-name-4]
l RECORDS ARE I
Syntax Rules
195
2. The clauses which follow the name of the file are
cases, and their order of is immaterial.
3. One or more record description entries must follow the file description
entry .
Function
General Format
Function
The DATA RECORDS clause serves only as documentation for the names of
data records with their associated file.
General Format
Syntax Rules
Data-name-1 and data-name-2 are the names of data records and must have
01 level-number record descriptions, with the same names, associated
with them.
General Rules
1. The presence of more than one data-name indicates that the file
contains more than one type of data record. These records may be of
differing sizes, different formats, etc . The order in which they are
listed is not significant.
2. Conceptually, all data records within a file share the same area. This
is in no way altered by the presence of more than one type of data
record within the file.
196
THE LABEL RECORDS CLAUSE
Function
General Format
Function
General Format
General Rule
The size of each data record is completely defined within the record
description entry, therefore this clause is never required. flll~~l
IB!UB!I~BP~~~'!JitrAI·
Function
r The VALUE OF clause specialises the description of an item in the label
recorda associated with a file.
General Format
General Rules
197
-
PROCEDURE DIVISION IN THE INDEXED I-0 MODULE
Function
General Format
The files referenced in the CLOSE statem@nt need not all have the same
organization or access.
General Rules
2. The action taken if a file is in the open mode when a STOP RUN
statement is executed is to close the fil e. The action taken for a file
that has been opened in a called program and not closed in that program
prior to the execution of a CANCEL statement for that program is to
close the file
198
THE DELETE STATEMENT
Function
General Format
Syntax Rules
l. The INVALID KEY phase must not be specified for a DELETE statement
which references a file which is in sequential access mode.
2. The INVALID KEY phrase must be specified for a DELETE statement which
references a file which is not in sequential access mode and for which
an applicable USE procedure is not specified.
General Rules
l. The associated file must be open in I-0 mode at the time of the
execution of this statement. (See THE OPEN STATEMENT later in this
Chapter).
5. The execution of a DELETE statement does not affect the contents of the
record area associated with file-name.
7. The execution of the DELETE statement causes the value of the specified
FILE STATUS data item, if any, associated with file-name to be updated.
(See I-I) STATUS in this Char.ter).
199
THE OPEN STATEMENT
Function
General Format
~ ...
~
INPUT file-name-1 [, file-name-2]
OPEN OUTPUt file-name-3 [ , file-name-4]
~ file-name-S [, file-name-6]
1. The files referenced in the OPEN statement need not all have the same
organization or access.
General Rules
200
Table 7-1 . Permissible Combinations of Statements and Open Modes for
Indexed I/O
Open Mode
File Access
Mode Statement Input Output Input-Output
Sequential READ l\ X
WRITE X
REWRITE X
START X X
DELETE X
Random READ X X
WRITE X X
REWRITE X
I START
DELETE X
Dynamic READ X X
WRITE X X
REWRITE X
START X X
DELETE X
5. A file may be opened with the INPUT, OUTPUT and I-0 phrases in the same
program. Following the i nitial execution of an OPEN statement for a
file, each subsequent OPEN statement execution for that same file must
be preceded by the execution of a CLOSE statement for that file.
6. Execution of the OPEN statement does not obtain or release the first
data record.
9. For files being opened with the INPUT or I-0 phrase, the OPEN statement
sets the current record pointer to the first record currently existing
within the file . If no records exist in the file, the current record
pointer is set such that the next executed Format 1 READ statement for
the file will result in an AT END condit ion. .,. ~), .:: does n.~ t:
,#~)Jt, . JNI'll:l' wil,l c~t;~~~~~J'.ie,..~i¥Fil &tatua ~s\,;.,< ';/ ,. ~:,;-{_;.
201
10. The l - 0 phrase permits the opening of a file for both input and out put
op~~ tio_n~. 'tf '"t~,<! ~f,t_'e~does" n~l);~~ f~"'~iT!i;o;J!t~.:_!~i:~~; ]
ll. Upon successful execution of an OPEN sta t ement wi th the OUTPUT phrase
specified , a file i s crea t ed . At that ti me the associa ted f ile
contain s no data records.
d~!,~~a . ,, :r~:~s~:~21'~~~«1£§ted,
202
,_
I
Function
For sequential access, the READ statement makes available the neJCt
logical record from a file. For random access, the READ statement makes
available a specified record from a mass storage file.
General Format
Format 1
Format
Syntax Rules
1. The INTO phrase must not be used when the input file contains logical
records of various sizes as indicated by their record descriptions.
The storage area associated with identifier and the storage area which
is the record area associated with file-name must not be the same
storage area.
2. Format 1 must be used (without the NEXT phrase) for all files in
sequential access mode.
4. The NEXT. phrase must be specified for files in dynamic access mode,
when records are to be retrieved sequentially.
General Rules
1. The associated file must be open in the INPUT or I-0 mode at the time
this statement is executed. (See THE OPEN STATEMENT in this Chapter).
203
,..
I
by the START or OPEN statement and the record is still accessible
through the path indicated by the current record pointer; if the
record is no longer accessible, which may have been caused by the
deletion of the record, the current record pointer is updated to
point to the next existing record in key sequence and that record
is then made available.
3. The execution of the READ stat~nent causes the value of the FILE STATUS
data item, if any, associated with file-name to be updateJ. (See I-0
~in this Chapter).
5. When the logical records of a file are described with more than one
recor~ description, these records automatically share the same storage
area; this is equivalent to an implicit redefinition of the area. The
contents of any data items which lie beyond the range of the current
data record are undefined at the completion of the execution of the
READ statement.
6. If the INTO phrase is specified, the record being read is moved from
the record area to the area specified by identifier according to the
rules specified for the MOVE statement. The implied MOVE does not
occur if the execution of the READ statement was unsuccessful. Any
subscripting or indexing associated with identifier is evaluated after
the record has been read and immediately before it is moved to the data
item.
When the INTO phrase is used, the record being read is available in
both the input record area and the data area associated with
identifier.
10. When the AT END condition is recognised the following actions are taken
in the specified order:
a. A value is placed into the FILE STATUS data item, if specified for
this file, to indicate an AT END condition. (See I-0 STATUS in
this Chapter).
204
b. If the AT END phrase is specified in the statement causing the
condition, control is transferred to the AT END imperative
statement. Any USE procedure specified for this file is not
executed.
c. If the AT END phrase is not specified, then a USE procedure must
be specified, either explictly or implicitly, for this file, and
that procedure is executed,
12. When the AT END condition has been recognised, a Jormat READ
statement for that file must not be executed without first executing
one of the following:
13. For a file which dynamic access mode is specified, a Format 1 READ
statement with the NEXT phrase specified causes the next logical record
to be retrieved from that file as described in general rule 2 above.
14. Execution of a Format 2 READ statement causes the value of the key that
to be compared with the value contained in the corresponding data item
of the stored records in the file, until the first record has an equal
value is found. The current record pointer is positioned to this
record which is then made available. If no record can be so
identified, the INVALID KEY condition exists and execution of the READ
statement is unsuccessful. (See The INVALID KEY Condition in this
Chapter).
THE REWRITE STATEMENT
Function
General Format
Syntax Rules
.a.. 1\.t::::L.:uu.i-nc«ue anc:i ident1t1.er must not refer to the same storage area.
2.. Record-name is the name of a logical record in the File Section of the
Data Division.
3. The INVALID KEY phrase must be specifj.ed in the REWRITE statement for
files for which an appropriate USE procedure is not specified.
General Rules
l. The file associated with record-name must be open in the I-0 mode at
the t tme of execution of this statement. (See THE ~ STATEMENT in
this Chapter) •
2.. For files in the sequential access mode, the last input-output
statement executed for the associated file prior to the execution of
the REWRITE statement must have been a successfully executed READ
statement. The Operating System logically replaces the record that was
accessed by the ~EAD statement.
2.06
7. The execution of the REWRITE statement causes the value of the. FILE
STATUS data item, if any, associated with the file to be updated. (See
I-0 Status).
b. The value contained in the record key data item does not equal
that of any record stored in the file, or
c. The updating operation does not take place and the data in the
record area is unaffected. (See The INVALID KEY Condition in this
Chapter).
r-
1
~
I
207
THE START STATEMENT
Function
The START statement provides a basis for logical positioning within an
indexed file, for subsequent ~equential retrieval of records.
General Format
IS EQUAL TO
IS-c--
''"' ,,,,_"...['" IS GREATER
IS_>_ __ THAN
IS NOT LESS THAN
IS NoT-<-
i'iO"IE: rne required relational characters '>', '<' and '=' are not
underlined to avoid confusion with other symbols such as '>'
(greater than or equal to).
Syntax Rules
General Rules
l. File-name must be open in the INPUT or I-0 mode at the time that the
START statement is executed, (See THE OPEN STATEMENT in this Chapter).
208
a. The current record pointer is positioned to the first logical
record currently existing in the file whose key satisfies the
comparison.
r- 4. The execution of the START statement causes the value of the FILE
STATUS data item, tf any, associated with file-name to be updated. (See
I-0 Status).
,...
r-
r-"
r-
r-
~
r-
r-
r- 209
~
THE USE STATDIENT
Function
General Format
l
file-name-ll
EXCEPTION 1 INP!IT
USE AFTER STANDARD
----- l ~I PROCEDURE ON ~~Pur
Syntax Rules
General Rules
1. If the INVALID KEY phrase on the AT END phrase have not been specified
in the input-output statements the designated procedures are executed
by the input-output system after completing the standard input-output
routine upon recognition of the INVALID KEY or AT END condition.
210
THE WRITE STATEMENT
Function
General Format
Syntax Rules
l. Record-name and identifier must not reference the same storage area.
General Rules
l. The associated file must be open in the OUTPUT or I-0 mode at the time
of the execution of this statement. (See THE OPEN STATEMENT in this
Chapter).
3. The results of the "xecution of the WRITE statement with the FROM
phrase is equivalent tn the execution of:
a. The statement:
r b.
by:
211
After execution of the WRITE statement is complete, the
information in the area referenced by identifier is available,
~,
even though the information in tne area referenced by record-name
may not be. (See general rule 2 above).
5. The execution of the WRITE statement causes the value of the FILE
STATUS data item, if any, associated with the file to be updated. (See
I-0 Status in this Chapter).
6. The maximum record size for a file is established at the time the file
is created and must not subsequently be changed.
9. Execution of the !~RITE statement causes the contents of the record area
to be released. The Operating System utilizes the content of the
record key in such a way that subsequent access of ~he record may be
made based upon the specified record key.
10. The value of the record key must be unique within the records in the
file.
!1. rhe data item specified as the record key must be set by the program to
the desired value prior to the execution of the WRITE statement.
12. If sequentia~ access mode is specified for the file, records must be
released to the Operating System is ascending order of record key
values.
14. The INVALID KCY condition exists under the following circumstances:
..,,
212
b. When the file is opened in the output or I-0 mode, and the value
of the record key is equal to the value of a record key of a
record already existing in the file, or
15. When the INVALID KEY condition is recognised the execution of the WRITE
statement is unsuccessful, the contents of the record area are
unaffected and the FILE STATUS data item, if any, associated with
file-name of the associated file is set to a value indicating the cause
of the condition. Execution of the program proceeds according to the
rules stated under THE INVALID KEY condition (See also i-0 Status iu
this Chapter).
213
CHAPTER 8
SEQIENTATION
ORGANIZATION
Program Segments
Fixed Portion
The fixed portion is defined as that part of the object program which
is logically treated as if it were always in memory. This portion of the
program is composed of fixed permanent segments.
Ir.dependent Segments
214
1. Control is transferred to that segment as a result of the implicit
transfer of control between consecutive statements from a segment with
a different segment-number.
SEGMENTATION CLASSIFICATION
SEGMENTATION CONTROL
215
STRUCTURE OF PROGRAM SEGMENTS
SEGMENT-NUMBERS
GENERAL FORMAT
SYNTAX RULES
GENERAL RULES
~:
216
REStRICTIONS ON PROGtAM FLOW
217
II '1: e 8 Jie£ and
~ilillili~_.IIID E:ilbE .RiJ "t.l:f;;
'"
218
CHAPTER 9
LIBRARY
219
THE COPY STATEMENT
FUNCTION
The COPY statement incorporates text into a CIS COBOL source program.
GENERAL FORMAT
text-name I
!external-file-name-literal\
SYNTAX RULES
GENERAL RULES
4.
220
CHAPTER 10
INTRODUCTION
Standard ANSI COBOL debugging provides a means by which the user can
describe the conditions under which procedures are to be
monitored during the execution of the object program.
The features of the language that support the COBOL Debug module are:
* Debugging lines.
The reserved word DEBUG-ITEM is the name for a special register generated
automatically by the compiler that supports the debugging facility. Only
one DEBUG-ITEM is allocated per program. The names of the subordinate data
items in DUBUG-ITEM are also reserved words.
221
COMPILE-TIME SWITCH
When DEBUGGING MODE is not specified in a program, all the debugging lines
are compiled as if they were comment lines and their syntax is not checked.
The object time switch has no effect on the execution of the object program
if the WITH DEBUGGING MODE clause was not specified in the source program at
compile time.
Function
The WITH DEBUGGING MODE clause indicates that all debugging sections and all
debugging lines are to be compiled. If this clause is not specified, all
debugging lines and sections are compiled as if they were comment lines.
General Format
General Rules
222
PROCEDURE DIVISION IN COBOL DEBUG
Function
The USE FOR DEBUGGING statement identifies the user items that are to be
monitored by the associated debugging section.
General Format
procedure-name-2]
[ 'ALL PROCEDURES •••
Syntax Rules
4. Except for the USE FOR DEBUGGING statement itself, statements appearing
within a given debugging section may reference procedure-names defined
within a different USE procedure only with a PERFORM statement.
6. Any given procedure-name may appear in only one USE FOR DEBUGGING
statement and may appear only once in that statement.
General Rules
223
2. Automatic execution of a debugging section is not caused by a statem~nt
appearing in a debugging section.
4. The ALL PROCEDURES phrase causes the effects described in gen~ral rule
3 to occur for every procedure-name in the program, except thos~
appearing within a debugging section .
01 DEBUG-ITEM.
02 DEBUG-LINE PICTURE IS X(6).
02 FILLER PICTURE IS X VALUE SPACE.
02 DEBUG-NAME PICTURE IS X(30).
02 FILLER PICTURE IS X(l9) VALUE SPACE.
02 DEBUG-CONTENTS PICTURE IS X(n).
224
8. Prior to each execution of a debugging section, the contents of the
data item referenced by DEBUG-ITEM are space-filled. The contents of
data items subord::.aate to DEBUG-ITEM are then updated, according to the
following general rules, immediately before control is passed to that
debugging section. The contents of any data item not specified in the
following general rules remains spa~es.
10. DEBUG-NAME contains the first 30 characters of the name that caused the
debugging section to be executed.
11. DEBUG-cONTENTS is a data item that is large enough to contain the data
required by the following general rules.
15. If the transfer to control from the control mechanism associated with a
PERFDR!1 statement causes the debugging section associated with
procedure-name-1 to b~ executed, thP following conditions exist:
225
~-
DEBUGGING LINES
A debugging line is any line with a 'D' in the indicator area of the line.
Any debugging line that consists solely of spaces from margin A to margin R
is considered the same as a blank line.
226
CHAPTER 11
INTER!'ROGl.AM CCMMUNICATION
The ability for both programs to have access to the same data
items.
LINKAGE SECTION
The Linkage Section is used for describing data that is available through
the calling program but is to be referred to in both the calling and the
calle<.l program. No space is allocated in the program for data items
referenced by data-names in the Linkage Section of that program. Procedure
Division references to these data items are resolved at object t1.Jne by
equating the reference in the called program to the location used in the
calling program. In the case of index-names, no such correspondence is
established. Index-names in the called and calling program always refer to
separate indices.
Data items defined in the Linkage Section of the called program may be
referenced within the Procedure Division of the called program only if they
are specified as operands of the USING phrase of the Procedure Division
header or are subordinate to such operands, and the object program is under
the control of a CALL statement that specifies a USING phrase.
Each L·'.nkage Section record-name and noncontiguous item name must be unique
within the called program since it cannot be qualified, Data items defined
in the Linkage Section of the called program must not be associated with
da•:a items defined in the Report Section of the calling program.
227
index-names associated with such data-names and/or subordinate data items,
may be referenced in the Procedure Division.
Items 1.n the Lir.kage Section that bear no hierarchic relationsh1.p to one
another need not be grouped into records and are classified and defined as
noncontiguous elementary items. Each of these data items is def1.ned in a
separate data descr1.pt1.on entry which begins w1.th the special level-number
77.
The follow1.ng data clauses are required in each data descript1.on entry:
~ Lev~l-number 77
• Data-name
• The PICTURE clause or the USAGE IS INDEX clause
Other data description clauses are opt1.onal and can be used to complete the
de·scription of the 1.tem 1.f necessary.
228
r-·
The PrccP.dure Division is identified by and must begin with the following
header:
The USING phrase is present 1.f and only 1.f the object program is to function
und€r the control of a CALL statement, and the CALL statement in the calling
program contains a USING phrase.
Each of the operand.; in the USING phrase of the Procedure Division header
must be defined as a data item in the Linkage Section of the program in
which this header occurs, and it must have a 01 or 77 level-number.
Within a called program, Linkage Section data items are processed according
to their data descriptions given in the called program.
229
THE CALL STATEMENT
Function
The CALL statement causes control to be transferred from one object program
to another, within the run unit.
General Format
Format 1
CALL l identifier-1!
literal-1 [~ data-name-1 [, da ta-name-2] ••• )
Format 2
Syntax Rules
4. Each of the operands in the USING phrase must have been defined as a
data item in the File Section , Working-Storage Section, or Linkage
Section, and must have a level-number of 01 or 77.
5.
6. ._ta i;:.. W$-P
..... ta llef.f.'IOiot,
. . .rJ.c. tal _ -
General Rules
230
3. In format l, a called intermediate code module is loaded from disk the
first time it is called within a run-unit and the first time it is
called after a CANCEL to the called program.
On all other entries into the called program, the state of the program
remains unchanged from its state when last executed. This includes all
data fields, the status and positioning of all files, and all alterable
switch settings.
4. ..~ .. is
.. ~ :.
231
THE CANCEL STATEMENT
Function
The CANCEL statement releases the w.amory areas occupied by the referred to
program.
General Format
CANCEL !identifier-!!
literal-! [
·) identifier-21]
literal-2 •.•
Syntax Rules
General Rules
2. A program named in the CANCEL statement must not refer to any program
that has been called and has not yet executed an EXIT PROGRAM ~
I
statement.
l:.oti\i
232
THE EXIT PROGI.AM STATEMENT
-~
Function
The EXIT PROGI.AM stat~ent marks the logical end of a called program.
General Format
Syntax Rules
2. The EXIT PROGRN1 sentence must be the only sentence in the paragraph.
General Rule
Fi!NI
!
-~
233
CHAPTER 12
PROGRAMMING TECHNIQUES
1. Use of the first 256 bytes of working-storage for variables which are
freque;1tly referenced will produce more compact and efficient code.
3. For ACCEPT and DISPLAY the compiler generates one instruction per
elementary item of the data-name being displayed/accepted. Therefore
redefine a group of fields as a single field for DISPLAY whenever
possible a.nd avoid unnecessary numbers of small fields in ACCEPT.
This is an extension to the ANSI COBOL standard X3.23 (1974). (See under
Nonnumeric Literals in Chapter 2).
Note, however, that the rules for moving such a field comply with the ANSI
standard in that the c.ontents will be truncated if over decimal 99.
USEFUL HINTS
3. Remem1>er always to end your CIS COBOL program with a period. Invali.d
intermediate code can result if this final period is missing.
4. Note that the data part of an indexed sequential file may be accessed
relatively. However, the first record (relativ<:ly) is inaccessible.
since relative file access begins at record number l, as specified in
the ANSI COBOL standard X3.23(l974).
r-
r:
r-
r-
r- 235
r-
~.
For a FILLER, n = 1.
e.g. 9 9 9 9 9 = 3 bytes
9 (4) 9 a 3 bytes
Z (2) 9 (4) • 9 (3)= 4 bytes
236
APPENDIX A
This appendix contains a full list of COBOL and CIS COBOL reserved
words. A shaded reserved word is a CIS COBOL extension to ANSI COBOL.
The I symbol denotes that the text up to that point is a reserved word,
as is the whole word.
e.g., In INDEX/ED, INDEX and INDEXED are reserved wqrds i-n SPACE/S,
SPACE and SPACES are reserved words.
~.J
238
r-
~
RESERVED WORD LIST
ACCEPT ENVIRONMENT NEGATIVE SORT
ACCESS EQUAL NEXT SORT-MERGE
~ ADD ERROR NOT SOURCE-COMPUTER
i
ADVANCING EVERY NUMERIC SPACE/S
-
AFTER EXCEPTION SPECIAL-NAMES
ALL EXCESS-3 OBJECT-COMPUTER STANDARD
ALPHABETIC EXCLUSIVE OCCURS STANDARD-I
I ALTER EXIT OF START
AND EXTEND OFF STATUS
ARE OMITTED STOP
AREA FD ON SUBTRACT
r- ASCENDING
ASSIGN
AT
FILE
FILE-CONTROL
FILLER
OPEN
OR
ORGANIZATION
SWITCH
SYNC/HRONIZED
SYSIN
AUTHOR FIRST OUTPUT ~YSOUT ·
AUTOMATIC FOR OVERFLOW
FROM TAB
~ BEFORE
BLANK GIVING
PAGE
PERFORM
TABLE
TALLYING
BLOCK GO PIC/TURE THAN
BY GREATER POSITIVE THEN
r- CALL
CANCEL
HIGH-VALUE/S
PROCEDURE/S
PROCEED
PROGRAM
THROUGH
THRU
TIMES
CHARACTER/S r-oY-CONTROL PROGRAM-ID TO
CLOCK-UNITS IDENTIFICATION TRAILING
r- CLOSE
COBOL
CODE-SET
IF
INDEX/ED
INITIAL
QUOTE/S
RANDOM
TYPE
UNIT
COLLATING INPUT/-OUTPUT RD UNTIL
COMMA INSPECT READ UP
r- COMMIT
COMP/UTATIONAL/-3
INSTALLATION
INTO
RECORD/S
REDEFINES
UPON
USAGE
CONFIGURATION INVALID REEL USE
CONSOLE IS RELATIVE USING
CONTAINS RELEASE
.~ COPY
CRT
JUST/IFIED REMAINDER
REPLACING
VALUE/S
VARYING
CRT-UNDER KEPT RERUN
CURRENCY KEY RETURN WHEN
CURSOR REWRITE WITH
fWII DATA
LABEL RIGHT WORDS
LEADING ROLLBACK WORKING-STORAGE
DATE-COMPILED LEFT ROUNDED WRITE
DATE-WRITTEN LESS RUN
DEBUGGING LIMIT/S ZERO/ES or
~· DECIHAL-POINT LINE/S SAME
DECLARATIVES LINKAGE SD (period)
DELETE LOCK SECTION
DEPENDING LOW-VALUE/S SECURITY
DESCENDING SEGMENT
~ DISPLAY
DIVIDE
MANUAL
MEMORY
SEGMENT-LIMIT
SELECT +
DIVISION MERGE SENTENCE
DOWN MODE SEPARATE <
r- DYNAMIC MODULES
MOVE
SEQUENCE
SEQUENTIAL
,.
ELSE MULTIPLY SET
END SIGN *
ENTER NATIVE SIZE
239
r--
Note that the Level II COBOL product contains the following additional
reserved words. If you wish to e~sure that your CIS COBOL programs are
upward compatible with Level II COBOL do not use these words as
user-narnes.
ALTERNATE TAPE
ALSO TERMINAL
BOTTON TEXT
COHNUNICATION TIME
COMPUTE TOP
CORR/ESPONDING UNSTl!ING
COUNT
DATE
DAY
DEBUG-CONTENTS
DEBUG-ITEM
DEBUG-LINE
DEBUG-NAME
DEBUG-SUB-I
DEI!UG-SUB-2
DELIHITED
DELU!ITER
DESTINATION
DISABLE
DUPLICATES
ENABLE
END-OF-PAGE
EOP
ESI
~ll
EGI
FOOTING
IN
KEPT
LENGTH
LINAGE/-COUNTER
HESSAGE
~IULTIPLE
NO
OPTIONAL
POINTI:R
POSIT"~ON
QUEUE :
RECEIVE
REXOVKL
RENANES
RESERVE
RETURN
REVERSED
RE\HND
SEARCH
SEND
STRING
SUB-QUEUE-I
SVB-QliEUE-2
SUB-QUEUE-3
sntBOLIC
240
lJ 1J (! Lt L ·l, 1J ll LJ LI Lf L~ L! L! l! Lt Ll
APPENDIX B
X
X
5
6
7
35
36
37
d
e
f
64
65 I
66
HT 09 8 38
LF 0A Il X
X
9 39
g
h
67
68
VT 0B I X : 3A X i 69
FF 0C X 3B j 6A
C:<. 0D X <' 3C k 68
su 0E X
"' 3D 1 6C
SI 0F X > 3E m 60
DLC: 10 X ? 3F X n 6E
DCI 11 X @ 40 6F
DC2
DC3
12
13
X A i 41
X 0
p 70
B 42
DC4 14 I
X
c I q 71
NAK 15
I
I
i
X
X D
43
44
r
s
72
73
I
::iYN 16 X E 45 t 74
r~T;) I 17 X F
I 46 u 75
CA'~ 18 X G I 47 v 76
£.'1 19 X H 48 w 77
SUB 1A
E::iC
FS
I
I
1B
1C
X
X
X
I
J
K
49
4A
4B
X
y
z
78
79
7A
I
l
GS
:{S !
j
1D
1E X
X L
M
4C
4D
7B
7C
I X
X
us 1F I
X N 4E 7D
1
X
space 20 0 4F 7E X
! 21 X p
I 50 DEL 7F
II :<
" 22 Q
I 51
il 23 I X R 52
$
i. i
24
25
i
X
s
T
I 53
54
&
j
26 I X u I 55
' 27 v 56
( 28
X
w j 57
) 29 X 58
* I 2A y 59
I 2B2C z
.
+
I sc
SA
SB X
-
I 20ll!: I l 50
X
x
242
~-
r-J
~-
~·~~~-
~-
,.._
,.
f. ..-*'"...
r.-
,.
r
~
-~
~ 243
~
APPE.NDIX C
GLOSSARY
INTRODUCTION
The terms in this Chapter are defined in accon'.ance with their meaning as
used in this document describing CIS COBOL and may not have the same meaning
for other languages.
DEFINITIONS
Access fude. The manner in which records are to be operated upon within a
file
Ascending Key. ~ key upon the values of which data is ordered starting with
the lowest value of key up to thP. highest value of key in
accordance with the rules for comparison of the data items.
244
Assumed Decimal Point. A decimal point position which does not involve the
existence of an actual character in a data item. The assumed
decimal point has logical meaning but no physical representation.
Character Set (CIS COBOL). The complete CIS COBOL character set consists
of all characters listed below:
Character Meaning
0,1, ... ,9 Numeric digit
A,B, ••• ,z Uppercase alphabetic
·a,b~,:~~· -;~;: .· ... : Loa1:.C&81l·: .atphab;e.~ie >
Space (Blank)
+ Plus Sign
Minus Sign
* Asterisk
Stroke (Virgule or Slash)
Equal Sign
$ Currency Sign
Comma
Semicolon
Period (Decimal Point, Fullstop)
Quotation Mark
( Left Parenthesis
) Right Parenthesis
> Greater Than Symbol
< Less Than Symbol
Class Condition. The proposition, for which a truth value can be determined,
that the content of an item is wholly alphabetic or is wholly
numeric.
245
~· A clause is au ordered set of consecutive CIS COBOL character-
strings whose purpose is to specify an attribute of an entry.
Compile Time. The t:lme at which an CIS COBOL I'Ource program is translated
by the compiler to an CIS COBOL intermediate code program.
246
Connective. A reserved word that is used t o :
l. Assoc iate a data-name, paragraph - name, condition- name, or
t ex t - name with it s qualifi e r.
2. Link two o r more ope rands written in a series.
3. Form con~itions (logical connectiv es ). (See Logical
Operator.)
Cou nter. A data i t em used for sto ring numbers or number representations in
a manne r that pe rmit s these numbers t o be increased o r decr eased
Dy c[a~. vaiue of another numbr:r, or t o be cnange d or reset to ze ro
or t o an arbitrary positive or nega tive value.
CUJ;ren cy Sign. The cha r ac t e r " $" (dollar sign) in the CIS COBOL character
set .
Currency Symbol. The character defined by t he CURRENCY SIGN cla use in the
SPECIAL- NAMES paragraph . If no CURRENCY SIGN c laus e is pre sen t in
a CIS COBOL source program, the cur r enc y symbo l i s identical t o
the currency sign .
Curren t Record Po int er . A conceptual entity that is used in the selec tion
of the next r eco rd.
24 7
Debugging Line. A debugging line is any line w1 th "D" in the indicator area
of the line.
nf;~ ~tiB~~~~·~~a.:r~~~
Delimiter. A character (or sequence of contiguous characters) that
identifies the end of a string of characters, and separates that
string of characters from the following string of characters. A
delimiter is not part of the string of characters that it ~
delimits.
Descending Key. A key upon the values of which data is ordered starting
with the highest value of key down to the lowest value of key, in
~
accordance with the ~ules for comparing data items. I
248
r-
r- Character
B
Meaning
Space
0 Zero
r- +
CR
Plus
Minus
Credit
DB Debit
z Zero Suppress
r- $
tlr Check Protect
Currency Sign
Comma
Period (Decimal Point)
I Stroke (Virgule, Slash)
Extend Mode. With the EXTEND phrase specified, the state of a file after
execution of an OPEN statement, and before the execution of a
CLOSE statement for the file.
File Clause. A clause that appears as part of any of the following Data
Division entries:
File Description (FD)
File Description Entry. An entry in the File Section of the Data Division
that is composed of the level indicator FD, followed by a
file-name, and then followed by a set of file clauses as required.
~
~~ .. - 249
File Organization. The permanent logical file structure established at the
time that a file is created.
I-0 Mode. The state of a file after execution of an OPEN statement, with the
I-0 phrase specified for that file, and before the execution of a
CLOSE statement for that file.
Index Data Item. A data item in which the value associated with an
index-name can be stored in a form specified by the implementor.
250
Input File . A file that is opened in the input mode.
Input Mode . The state of a file af ter execu tion of an OPEN stateme nt, with
the INPUT phrase specified, for that file and before the execution
of a CLOSE s t a tement for that file.
Key of Reference. The key currently being used to access records within an
indexed file .
Library - Name. A user- defined word tha t names a CIS COBOL library
source file that is to be u sed by the compiler for a given source
program compilation.
25 1
Library-Text. A sequence of character-strings and/or separators in a
COBOL library.
Line Sequ"S~~~~I:~(~~·==:
Linkage Section. The section in the Data Division of the called progra~r
that describes data items available from the calling program.
These data items may be referred to by both the calling and called
~.:u~L· cl&ll.
Logical Operator. The reserved word 'NOT'. It can be used for logical
negation.
Logical Record. The most inclusive data item. The level-number for a
record is 01.
~ega ted S im.ple Condition. The 'NOT' logical operator immediately followed
by a simple condition.
252
Nonnumeric Literal. A character-string bounded by quotation marks. The
string of characters may include any character in the
canputer's character set. To represent a single quota.:ion mark
character lli.thin a nonnumeric literal, two contiguous quotation
marks Must be used.
Open Mode. The state of a file after execution of an OPEN statement for that
file and before the execution of a CLOSE stateMent for that file.
The particular open mode is specified in the OPEN statement as
either INPtrr, OUTPUT, I-o or ElCl'END.
Output File. A file that is opened in either the output Mode or extend
MOde.
253
Paragraph Header. A reserved word, followed by a period and a space that
indicates the beginning of a paragraph in the Identification and
Environment Divisions. The permissible paragrapt headers are:
PROGRAM-I D.
AUTHOR.
INSTALLATION.
DATE-WRITTEN.
DATE-COMPILED.
SECURITY.
In the Environment Division:
SOURCE-COMPUTER.
OBJECT-COMPUTER.
SPECIAL-NAMES.
FILE-CONTROL.
I-0-CONTROL.
Prime Record Key. A key whose contents uniquely identify a record within an
indexed file.
Character
comma
semicolon
period
quotation mark
left parenthesis
right parenthesis
space
equal sign
254
r
Random Access. An access mode in which the program-specified value of a key
data item identifies the logical record that is obtained from,
deleted from or placed into a relative or indexed file.
Record Key. A key, either the prime record key or an alternate record key,
whose contents identify a record within an indexed file.
Character
255
Relational Operator. A reserved word, a relation character, a group of
consecutive reserved words, or a group of consecutive reserved
words and relation characters used in the construction of a
relation condition. The permissible operators and their meaning
are:
Reserved Word. A COBOL word specified in the list of words which may be
used in COBOL source programs, but which must not appear in the
programs as user-defined words or system-names.
Run Unit. A set of one or more intermediate code programs which function, at
run time, as a unit to provide problem solutions.
256
Section Header. A combination of words followed by a period and a space that
indicates the beginning of a section in the Environment, Data and
Procedure Division.
CONFIGURATION SECTION
INPI!l'-Qt.i'"!PUT SECT ION
Sequential Access. An access mode in which logical records are obtained fr0111
or placed into a file in a consecutive predecessor-to-successor
logical record sequence dete~ined by the order of records in the
file.
Sign Condition. The proposition, for which a truth value can be determined,
that the algebraic value of a data item or an arithmetic
expression is either less than, greater tha~, or equal to zero.
~ 257
!
~-
relation condition
class condition
switch-status condition
sign condition
(simple-condition)
Character
+ plus sign
minus sign
* asterisk
stroke (virgule, slash)
equal sign
currency sign
comma (decimal point)
semicolon
period (decimal point)
quotation mark
( left parenthesis
) right parenthesis
> greater than symbol
< less than symbol
258
Standard Data ForMat. The concept used in describing the characteristics of
data in a COBOL Data Division under which the charactcListics or
properties of the data are expressed in a form oriented to the
appearance of the data on a printed page of infinite length and
breadth, rather than a form oriented to the manner in which the
data is stored internally in the computer, or on a particular
external medium.
Table Element. A data item that belongs to the set of repeated items
comprising a table.
Unary Operator. A plus (+) or a minus (-) sign, which precedes a variable
or a left parenthesis in an arithmetic expression and which has
the effect of multiplying the expression of +1 or -1 respectively.
Variable. A data item whose value may be changed by execution of the object
program. A variable used in an arithmetic expression must be a
numeric elementary item.
259
r-
1
~- A word that expresses an action to be taken by a COBOL compiler or
run time program.
~
i
260
~
r
r,
r.
r
r
r 261
APPENDIX D
COMPILE-TIME ERRORS
ERROR DESCRIPTION
262
so Illegal combination ORGANIZATION/ACCESS/KEY
51 Unrecognised clause in SELECT statement
52 RERU~ clause contains syntax error
53 SAME AREA clause contains syntax error
54 File-name missing or i~legal
55 'DATA DIVISION' missing
56 'PROCEDURE DIVISION' missing or unknown statement
57 * 'EXCLUSIVE', 'AUTOMATIC' or 'MANUAL' missing
58 * Non-exclusive lock mode specified for restricted
file
62 'DIVISION' missing
63 'SECTION' missing
64 File-name not specified in SELECT statement
tiS R~CORD SIZE integer missing
66 Illegal level number or level OL required
67 FD qualification contains syntax error
68 'WORKING-STORAGE' missing
69 'PROCEDURE DIVISION' missing or unknown statement
70 Unrecognized clause in Data Description or
previous'.' missin~
71 Incompatible clauses in Data Description
72 BLANK is illegal with non-numeric data-item
73 PICTURE clause too long
74 VALUE with non-elementary item, wrong data-type or
value truncated
75 VALUE clause in error or illegal for PICTURE type
76 FILLER/SYNCHRONIZED/JUSTIFIED/BLANK clause for
non-elementary item
77 Preceding item at this level has 0 or more than
8192 bytes
78 REDEFINES of different levels or unequal field
lengths.
79 Data Division exceeds 32K and data-item has
address above 7FFF
81 Data Description clause inappropriate or repeated
82 REDEFINES data-name not declared
83 USAGE must be COHP, DISPLAY or INDEX
84 SIGN must be LEADING or TRAILING
85 SYNCHRONIZED must be LEFT or RIGHT
86 JUSTIFIED must be RIGHT
87 BLANK must be ZERO
88 OCCURS must be numeric, non-zero and unsigned
89 VALUE must be a literal, numeric literal or
figurative constant
90 PICTURE string has illegal precedence or illegal
character
91 INDEXEO data-name missing or already declared
92 Numer.lc edited PICTURE string is toe large
263
101 Unrecognised verb
102 IF ••• ELSE mismatch
103 Data-item has wrong data-type or is not declared
104 Procedure name has been declared twice
-
lOS Procedure name is the same as a data-name
106 Name required
107 Wrong combination of data-types
108 I
Conditional statement not allowed; imperative
statement expected
109 Malformed subscript
110 ACCEPT or DISPLAY wrong
111 Illegal syntax used with I-0 verb
112 * LOCK clause specified for file with lock mode
EXCLUSIVE
113 * KEPT specified for uncommittable file
115 * KEPT omitted for comittable file
116 IF statements nested too deep (maximum 8)
117 Structure of Procedure Division wrong (e.g.
DECLARATIVES not first)
118 Reserved Word missing or incorrectly used
119 Too many subscripts in one statement
120 Too many operands in one statement
141 Inter-segment procedure name declared twice
142 IF ••• ELSE mismatch at the end of source input
143 Data-Item has wrong data-type or is not declared -.q_\
144 Procedure name undeclared
145 INDEX name declared twice
146 Cursor address field not declared or not 4 bytes
long
14 7 KEY declaration missing or FD missing
148 STATUS declaration missing
149 FILE STATUS data-item has the wrong format
150 Paragraph to be ALTERed is not declared
151 PROCEDURE DIVISION in error
152 USING parameter is not declared in the linkage
section
153 USING parameter is not level 01 or 77
154 USING parameter is used twice in the parameter
list
157 Structure of Procedure Division wrong (e.g.
DECLARATIVE$ not first).
160 Too many operands in one statement
* The error codes marked by an asterisk apply only when the optional
FILESHARE product is in use.
264
In addition to these numbered error messages, the following message can be
displayed with subsequent termination of the compilation:
Disk overflow
File directory overflow
File full
Impossible I-0 device usage
Other operating system dependent conditions can also cause this error.
NOTE:
You will notice that the numbers of the numbered error messages listed
above are not continuous, i.e., there are gaps in the numbering. The
compiler should never have cause to generate an error message with a
number not listed above. If you ever encounter such a number, consult
your Micro Focus Product Technical Support office.
['11111111
r
~
!
r
r-
'·
fWIR
265
r-
APPENDIX E
RUN-TIME ERRORS
Run-time error messages are preceded by the name and segment number of
the curr~r.tly executing intermediate code file.
All errors except those above are fatal. They ~y come from the operating
system or from the run-time system. Fatal errors cause a message to be
output to the console which includes a 3-digit error code and reference to
the COBOL statement subsequent to that in which the error occurred. These
fall into two classes:
(i) Exceptions
These cover arithmetic overflow, subscript out of
range, too many levels of perform nesting.
Description
266
172 Attt!tnpt to delete I-S record in non I-0 mode
173 Att~mpt to write I-S record in input mode
174 Att~mpt to CALL/CANCEL on active program
176 Illegal inter-sP.gm~nt reference
180 COBOL file mal fanned
181 Fatal file malformation
194 (.::P/M 1.4 only) File size too large (>0.5MB) or
Failure to Open on Extent --
195 DELETE/REWRTTE not preceded by a READ
196 Relative (or Ind~xed) - Record number too large
(>65535)
197 File save f~ilure
198 Program load failur~ (using CHAIN)
199 Ind~xed sequ~ntia1 file name too long ( >20 characters)
200 Insufficient space to load Animator
See also app~ndix D in the CIS COBOL Operating Guide specific to your
operating system.
267
APPENDIX F
SYNTAX SUMMARY
fiDENTIFICATION DIVISION.f
~J
268
GENERAL FORMAT FOR ENVIRONMENT DIVISION
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
OBJECT-COMPUTER. object-computer-entry
l
[,PROGRAM COLLATING SEQUENCE IS alphab~t-name].
r SPECIAL-NAMES.
SWIT~
0 ON STATUS IS condition-name-l
--[OFF STATUS IS condition-name-2]
[ [}i mnemonic-name] OFF-sTATUS IS conditional-name-2
-[ON STATUSIS conditional-name-l]
n{ ,S.YSIN }. ·. is mnemonic-name ] D
V ,SYSOUT -
( • TAB ,ll mnemonic-name l D
(,DECIMAL-POINT }i COMMA}
W-J:~~
E
INPUT-OUTPUT SECTION.
FILE-CONTROL.
r-
1 file-control-entry
r
r 269
[ H)-CONTROL.
, , integer-2 CLOCK-UNITS
eondition-name
Sequential SELECT:
SELECT file-name
[;ORGANIZATION IS
E
Relative Select:
SELECT file-name
ASSIGN TO
ORGANIZATION IS RELATIVE
[ ;ACCESS MODE IS
~ SEgUENTIAL
{RANDOM }
DYNAMIC
270
Indexed Select:
SELECT file-name
j ~~~=~~:!~!~~~:~»me-literal! ?[~-1"~ft1t,~'~\'
ASSIGN TO
;ORGANIZATION IS INDEXED
[;ACCESS MODE IS
lSEQUENTIAL
RANDOM
DYNAMIC
l]
;RECORD KEY IS data-name
r
r 271
GENERAL FORMAT FOR THE DATA DIVISION
D
D
[record-description-entry] .•. ] .
[ WORKING-STORAGE SECTION
77-level-description-entry] ···)
[ record-description-entry
[ LINKAGE SECTION
77-level-description-entry] ···)
[ record-description-entry
level-number {data-name}
FILLER
[;REDEFINES data-name]
PICTURE} . ]
)~~M:~~:~;:~:ringl
[ {
; PIC
[
·US GE IS
, ___A___
~UTATIONAL-3l
COMP-3
DISPLAY
[ ;{ ~~~~IFIED} RIGHT ]
{;BLANK WHEN ZERO]
[;VALUE IS literal] •
272
GENERAL FORMAT FOR PROCEDURE DIVISION
Declarative format:
DECLARATIVES.
{section-name SECTION segment-number. declarative-sentence
[paragraph-name. [sentence] ... J ... }...
END DECLARATIVES.
{ section-name SECTION [segment-number] •
[paragraph-name [sentence] ••• J ... } ...
Non-declarative format:
D D D
~ , file-name
r-
1
DELETE file-name RECORD [; INVALID KEY imperative-statement]
273
E
: . :d;.;:·;~~-~~~·
... ......: · ·.· t~@f.~li~~~·~·~·l.· · ;· .K
:.·: :::-·::.:··:; ,: .•:,..::~·::;
D
EXIT [PROGRAM].
GO TO procedure-name. ~
GO TO procedure-name-! , procedure-name-2
DEPENDING ON identifier
. . { statement-1 } ; ELSE statement-2 }
IF cond 1 t 1on; NEXT SENTENCE { ; ELSE NEXT SENTENCE
· [{BEFORE}
AFTER
CHARACTERS
INITIAL Sidentifier-4l]
lliteral-3 S
I
INSPECT identifier-! REPLACING
CHARACTERS BY
[,)l~~ING ~
FIRST
BEFORE} INITIAL
~
,
Sidentifier-6l
lliteral-4
11teral-3
~
~i~entifier-5 ~ BY
--
S i~entifier-7l]
sidentifier-6l
lliteral-4 S
I
[{ AFTER l l1teral-S ~
274
INSPECT identifier TALLYING tally-clause REPLACING replacing-clause
sidentifier-ll [ROUNDED]
MULTIPLY lliteral-l S BY identifier-2
Sidentifier-ll
PERFORM procedure-name-! { THROUGH}
THRU procedure-name-2 lliteral-1 ~
l Il
Sidentifier-ll S[identifier-2]l identifier-3 ~
TO
UP BY index-name-3
lindex-name-lS l[index-name-2]S
DOWN BY integer-!
275
SUBTRACT ~identifer-ll [• ~identifier-2l] FROM identifier-) [ROUNDED]
lliteral-1 ~ lliteral-2 S ···
file-name
INPUT
USE AFTER STANDARD {EXCEPTION} PROCEDURE ON OUTPUT
--- ERROR
r:o-
EXTEND
276
APPENDIX G
CIS COBOL is oriented to microcomputer users with the system readily accessable
and usually with a CRT. CIS COBOL therefore provides extensions for
interactive working, program control of files, text file handling and rapid
development and testing. These facilities are summarized below.
Ida ta:::•me-2l
ACCEPT dataname-l [ ATiliteral-l 1
277
DISK FILES
Two eALensions are offered by CIS COBOL file processing; these are as
follows:
HEXADECU1AL VALUES
INTERACTIVE DEBUGGING
The Debu3 package is entered as an option by the user and the user
program is then tested line by line, paragraph by paragraph and so on as
required. The commands to the package can reference procedure statements
and data areas by means of a 4-digit hexadecimal code output by the compiler
against each line of the compilation listing. Powerful macros of commands
can be used to give very sophisticated debugging facilities. The precise
details for using the pack~ge vary according to the host operating system
and are described in the app~0priate Operating Guide.
278
r--
1
APPENDIX H
MANDATORY CHANGES
ENVIRONMENT DIVISION
Configuration Section
~ IS data-name-1
The CURSOR IS data-name-1 clause specifies the data-name which will contain
the CRT cursor address as used by ACCEPT statements. Data-name-1 must be
declared in the Working-Storage section as a 4 character item. The
interpretation of the 4 characters is given in the ACCEPT statement
description.
Input-Output Section
ENVIRONMENT DIVISION
I-0-Control Paragraph
The clauses that refer to a real time clock and magnetic tape in this
paragraph are ignored by the compiler during compilation but do not cause
compile times errors. These clauses are as follows:
~ OF ~ R£EL l of f ile-name-2
r l UNIT~
279
(no magnetic tape)
integer-2 ~UNITS (no clock)
The following cauplete statements 1.n the fUe description are ignored
by the compiler during compilation but da not cause compile time errors:
~~ l
i CH.ARACfERS S
CODE-SET IS alphabet~c-name
\~IS l \STANDARD l
l~ARES l~S
CLOSE Statement
The following phrases 1.n the CLOSE statement are ignored by the
compiler during compilation but do not cause compiler-time errors:
,..,,
280
~
I
APPENDIX I
LANGUAGE SPECIFICATION
Nucleus
TR.blP Hanrlline
Sequential Input and Output
Relative Input and Output
Indexed Input and Output
Segmentation
Library
Inter-Program Communication
Debug
This appendix specifies the implementation of Version 4.3 CIS COBOL. The
implementation of each of the eight standard COBOL modules listed above is
given under the following headings as applicable:
Level 1 Implementation
Level 2 Implementation
CIS COBOL Extensions
r
~
I
281
~
!
Level One Implementation
3. Reserved word SPACE can be used to clear the whole CRT screen.
4. ANS switch not set enables omission of certain ANSI required "red tape"
paragraphs and statements.
5. COMPUTATIONAL-3 or COMP-3 can be specified in the USAGE clause to
specify packed internal decimal storage, (BCD).
282
7. DISPLAY sdata-name-1l[AT~data-name-2l] SCRT l
t literal-1 ~ lliteral-2 ~ UPONlCRT-UNDERS
1. The START statement is fully supported for Relative and Indexed files.
sREELl
l UNIT~
5. Dynamic access 1110de and READ NEXT are supported for relative and
indexed files.
r 8.
RERUN and SAME AREA clauses.
The following are treated as documentary only in the FD clause:
BLOCK CONTAINS
CODE-SET
DATA RECORDS
LABEL RECORDS
RECORDS CONTAINS
VALUE OF
283
CIS COBOL. Extensians
3. All File Description (FD) clauses are optional when ANS switch is
unset.
TABLE HANDLING
Level One Implementation
SE(}{ENTAI ION
Level One Implementation
284
CIS COBOL Extensions
r INTER-FROGUM C<MMUNICAIION
285
A c
ACCEPT Statement, CALL Statement,
100 230
Access Mode, CANCEL Statement,
140, 162, 188 ·232
ADD Statement, Character Representation and
103 45
Algebraic Signs, Character Sets,
47 36
Alignment Rules, Standard, Character Strings,
·47 38
Alphabetic Data Rules Character Strings, PICTURE,
75 43
Alphanumeric Data Rules, CIS COBOL, What It Is,
76 30
Alphanumeric Edited Data Rules Class Condition,
76 96
ALTER Statement, Classes of Data, Concepts,
105, 217 44
ANSI (ANS) Compiler Directive, Classification, Segmentation,
50 215
Area, Indicator, Clause, ASSIGN,
34 144, 166, 192
Arithmetic Statements, Clause, BLANK WHEN ZERO,
99 72
ASSIGN Clause, Clause, BLOCK CONTAINS,
144, 166, 192 148, 170, 196
AT END Condition, Clause, CODE-SET,
142, 165, 191 148
Clause, CURSOR IS,
67
Clause, DATA RECORDS,
148, 170, 196
B Clause, DATA-NAME or FILLER,
72
Blank Lines, Clause, FILE STATUS,
60 143, 166, 192
BLANK WHEN ZERO Clause, Clause, JUSTIFIED
72 13
BLOCK CONTAINS Clause, Clause, LABEL RECORDS,
148, 170, 196 149, 170, 197
Body, Procedure Division, Clause, OCCURS,
56 5-134
Clause, ORGANIZATION,
143, 166, ·192
Clause, PICTURE,
15
Clause, RECORD CONTAINS,
149, 170, 197
Clause, RECORD KEY,
192
286
-
I
Clause,
85
Clause,
143,
Clause,
REDEFINES,
SELECT,
166,
SIGN,
192
Condition-Name,
39,
94
50
Conditional Expressions,
Conditions, AT END
87 142, 165, ·191
Clause, SYCHRONISED, Conditions, Class,
89 96
Clause, USAGE Conditions, INVALID KEY
91' 136 165, 191 .
Clause, VALUE OF, Conditions, Relation,
150, 171' 197 ·94, 137
Clause, VALUE, Conditions, Simple
192 ·94
Clause, WITH DEBUGGING MODE, Conditions, Switch-Status
222 97
CLOSE Statement, CONFIGURATION SECTION,
151, 172, 198 -65
COBOL Words, Connectives,
32 40
CODE-SET Clause, Constants, Figurative,
148 40
Comment Entries, Continuation of Lines,
43 ·60
Comment Lines, COPY Sta temen t,
62 ·220
COMP(UTATIONAL) CRT Devices,
44 99
Comparison Involving Index Current Record Pointer,
137 ·140, 162, 188
Comparison of Nonnumeric CURSOR IS Clause,
94 167
Comparison of Numeric
94
Compile Time Debug Switch,
222
Compiler Directive, ANSI, D
50
Computer Independent Data Data Description, Computer
43 43
Concept, Classes of Data, Data Description, Entries
44 93
Concepts, Computer Data Description, Entry
43 70
Concepts, Levels, Data Division Entries,
.43 61
Concepts, Language, Data Division in Indexed I-0
36 195
Condition-Name Rules Data Division in I~terprogram
82 227
287
Data Division in Nucleus, ENTER Statement,
70 110
Data Division in Relative Entries, Comment
169 43
Data Division in Sequential Entry, FILE-CONTROL,
146 143, 166, 192
DATA RECORDS Clause, Environment Division in
148, 170, 196 222
DATA-NAME or FILLER Clause Environment Division in
172 192
DATE-COMPILED Paragraph, Environment Division in
64 65
Debug Environment Division in
.2.21 166
DEBUG, Environment Environment Division in
222 43
DEBUG, Object Time Switch Execution, Procedure Division
222 56
DEBUG, Procedure Division in EXIT PROGRAM Statement,
223 232
Debug, Run Time EXIT Sta temen t
221 111
Declarations, Expressions, Conditional
55 94
Declaratives, Extra Intermediate Code Files,
·62 217
DELETE Statement,
174
DISPLAY Statement,
106
DIVIDE Statement, F
108
Division Format, Figurative Constant Values,
60 42
Division Header, Figurative Constants,
' 60 40
File Description Entry
147, 169, 195
FILE SECTION,
146, 169, 195
E FILE STATUS Clause
143, 166, 192
Editing Symbols, FILE-CONTROL ENTRY,
77 143, 166, 192
Editing Types for Data FILE-CONTROL Paragraph,
75 143, 166, 192
Elementary Item Size Rules, FILLER or DATA-NAME Clause
76 72
Elements Fixed Insertion Editing Rules
32 80
288
r-
,.. Fixed Portion,
214
Identification Division,
51
Formats, Division, Identification Division,
60 63
r- Formats, General,
32
Formats, Paragraph,
I dent ifie r,
49
IF Statement,
60 113
Formats, Reference, Incompatible Data,
r-' 59
Formats, Section,
97
Independent Segments,
,.. 60
Formats, Source,
33
214
Index Data Items,
137
Index-Names,
137
Indexed I-0 Module,
188
r-
- ..
G Indexed I-0 Module,
195
General Formats Indexed I-0 Module,
32 192
r- GO TO Statement,
112
Indexed I-0 Module, Procedure
198
Indexing,
48
Indicator Area
~ 34
Input-Output Section,
H
143, 166, 192
Header, Division Input-Output Status,
r- 60
Header, Paragraph
140, 162, 189
Insertion Editing Rules,
60 30
Header, Procedure Division Insertion Editing Rules,
60
r-
( Header, Section,
79
Insertion Editing• Rules,
60 79
Hexadecimal Characters, Insertion Editing Rules, Fixed,
41 86
r- Hints, Useful,
234
INSPECT Statement,
115
Inter Program Communication
227
r-
·- ·
Inter Program Communication
229
I Intermediate Code Files,
217
I-0 Control Paragraph,
r- 145, 168, 194
INVALID KEY Condition,
165, 191
r- ---
289
r-
M
J Mnemonic-Name
39
JUSTIFIED Clause, Mode, Access,
73 140, 162, 188
MOVE Statement,
122
MULTIPLY Statement,
125
K
Keys, Status,
140, 163, 189
Name, Condition,
39
L Name, Mnemonic,
39
LABEL RECORDS Clause, Name, Paragraph,
149, 171, 197 39
Language Concepts, Name, Section,
36, 150, 162 39
Language Structure, Name, System,
36 39
Levels, Concept of, Name, User-Defined,
43 39
Levels, Number, Nonnumeric Literals,
44, 74 41
Library Module, Nucleus Function,
219 63
Lines, Blank, Nucleus, Data Division in,
60 70
Lines, Comment, Nucleus, Environment Division in,
62 65
Lines, Continuation of, Nucleus, Identification
60 63
Lines, Debugging, Nucleus, Organization,
221 63
Linkage Section, Nucleus, Procedure
227 94
Literals, Nonnumeric, Nucleus, Structure,
41 63
Literals, Numeric, Number, Level,
41 44, 74
Number, Sequence,
34, 60
290
Numeric Data Rules, ORGANIZATION IS SEQUENTIAL,
75 143
Numeric Edited Data Rules Organization, LINE SEQUENTIAL,
75 143
Numeric Literals, Overlapping Operands,
41 99, 137
Numeric Operands,
93
0 Paragraph Format,
60
OBJECT Time DEBUG Switch, Paragraph-Name,
222 39
OBJECT-COMPUTER Paragraph Paragraph,
65 65
OCCURS Clause, Paragraph, DATE-COMPILED,
134 64
OPEN Statement, Paragraph, FILE-CONTROL,
152, 175, 200 143, 166, 192
Operand Comparison, Paragraph, I-0 CONTROL
93 145, 168, 194
Operand, Overlapping, Paragraph, PROGRAM ID,
99, 137 64
Organisation, Data Division, Paragraph, SOURCE-COMPUTER,
53 65
Organisation, Environment Division, Paragraph, SPECIAL-NAMES,
52 67
,_
1
Organisation, Identification Division,
51
PERFORM Statement,
127, 217
Organisation, Indexed Phrase, ROUNDED,
188 98
Organisation, Nucleus, Phrase, SIZE ERROR,
63 98
Organisation, Procedure PICTURE Character Strings,
56 43
Organisation, Relative PICTURE Clause,
162 75
Organisation, Segmentation, Portion, Fixed,
214 214
Organisation; Sequential Precedence Rules,
140 82
ORGANIZATION IS Procedure Division Header,
143 56, 229
ORGANIZATION IS INDEXED, Procedure Division in
192 223
ORGANIZATION IS RELATIVE, Procedure Division in Indexed
166 198
r-
1
291
Procedure Division in the REDEFINES Clause,
229 93
Procedure Division in the Reference, Uniqueness of,
94 48
Procedure Division in the Relation Condition,
173 94
Procedure Division in the Relation Condition, Table
151 137
Procedure Division, Relative Input-Output Module,
55 166
Procedure Division, Relative Input-Output Module,
55 169
Procedure Division, Body, Relative Input-Output Module,
56 173
Procedure Division, Execution, Reserved Words,
56 62
Procedure Division, General REWRITE Statement,
56 157, 181, 206
Procedures, ROUNDED Phrase,
55 98
Program Segments, Rules General,
214 32
Program Structure, Rules Symbols Used,
31, 50, 216 47
PROGRAM-ID Paragraph, Rules, Alignment, Standard,
S4 75
Programming Techniques, Rules, Alphabetic Data,
234 76
Rules, Alphanumeric Data,
76
Rules, Alphanumeric Edited Data
76
Q Rules, Editing,
79
Rules, Editing, Fixed
86
Rules, Editing, Floating
80
R Rules, Editing, Simple
79
READ Sta temen t, Rules, Editing, Special
155, 178, 203 79
RECORD CONTAINS Clause, Rules, Editing, Zero
149. 177. 197 81
Record Description Format, Rules, Elementary Item Size,
59 76
Record Description Structure Rules, Numeric Data,
146, 169, 195 75
Record Pointer, Current, Rules, Numeric Edited Data,
140, 162, 188 76
292
Rules, Precedence, Separators,
B2 36
Rules, Syntax, Sequence Number,
32 34, 60
Run Time Debug, Sequential Input-Output Module,
221 140
Sequential Input-Output Module,
143
Sequential Input-Output Module,
151
s SET Statement,
137
Section Format, SIGN Clause,
6 87
Section Input-Output, Signs, Algebraic,
143, 166, 192 47
Section Name, Simple Conditions,
39 94
SECTION, CONFIGURATION, Simple Insertion Editing Rules,
65 79
SECTION, FILE, SIZE ERROR Phrase,
146, 169, 195 98
~ Section, Linkage, Sizing,
J
227 235
SECTION, WORKING-STORAGE, Source Format,
70 34
Segmentation Classification, SOURCE-cOMPUTER Paragraph,
215 65
Segmentation Control, Special Insertion Editing Rules,
215 79
Segmentation Organisation, SPECIAL-NAMES Paragraph,
214 ·67
-
Segmentation Suppression Editing, Zero,
214 81
Segments, Independent, Standard Alignment Rules,
214 -47
J
Segments, Program START Sta temen t,
214 183, 208
SELECT Clause, Statement, ACCEPT
143, 166, 192 106
Selection of Character Statement, ADD,
45 103
Sentences, Statement, ALTER,
56 105, 217
Sentences, Compiler Directing, Statement, CALL
57 230
Sentences, Conditional, Statement, CANCEL,
57 232
Sentences, Imperative, Statement, CLOSE,
58 151, 172, 198
293
Statement, COPY, Statements, Conditional,
20 57
Statement, DELETE Statements, Imperative,
173, 199 58
Statement, DISPLAY Status Keys
106 140, 163, 189
Statement, DIVIDE, Status, Input-Output,
108 140, 162, 189
Statement, ENTER STOP Statement,
110 131
Statement, EXIT PROGRAM, Structure, Data Division
111 51
Statement, EXIT, Structure, Environment Division
111 50
Statement, GO TO, Structure, Identification Division,
112 49
Statement, IF, Structure, Language,
113 36
Statement, INSPECT, Structure, Nucleus,
115 63
Statement, MOVE, Structure, Procedure Division,
122 56
Statement, MULTIPLY, Structure, Program Segments,
125 216
Statement, OPEN, Structure, Program,
152, 174, 200 31' 50
Statement, PERFORM, Structure, Record Description,
127, 217 146, 169, 195
Statement, READ, Subscripting,
155, 177, 203 46
Statement, REWRITE, SUBTRACT Statement,
157, 180, 206 132
Statement, SET, Switch Status Condition,
137 97
Statement, START, Switch, Compile Time,
182, 208 ·221
Statement, STOP, Symbols Used Rules,
131 175
Statement, SUBTRACT. SYNCHRONISED Clause,
132 89
Statement, USE FOR DEBUGGING, Syntax Rules,
223 32
Statements, USE, Syntax Rules, in Nucleus,
·158, 184, 210 64
Statement, WRITE System-Name,
154, 185, 220 39
Statements, Arithmetic,
99
Statements, Compiler Directing,
57
294
T Words, Key,
40
Table Handling, Words, Optional,
134 40
Table Handling, Data Division in, Words, Reserved,
134 ·40, 62
Table Handling, Procedure Division in, Words, User Defined,
137 38
Techniques, Programming, Working-Storage Noncontiguous,
234 70
Working-Storage Records,
70
WORKING-STORAGE Section,
70
u WRITE Statement,
158, 185, 211
Uniqueness of Reference,
48
USAGE Clause,
·91
USE FOR DEBUGGING Statement, X
·223
USE Statement,
158, 184, 210
Useful Hints,
234 y
User-Defined Words,
38
z
.r- v Zero-Suppression Editing Rules,
81
VALUE Clause,
92
VALUE OF Clause,
150, 171, 197
w
WITH DEBUGGING MODE Clause,
222
Words, COBOL,
·38
295
~
_;
~·
('-'
'- -
,..
~
~
r-'
......~
.,,. ...
..·.i
-1'1
••
•
.1'1
- ,, I
~
~ --··· -