0% found this document useful (0 votes)
167 views308 pages

CIS COBOL Language Reference

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
167 views308 pages

CIS COBOL Language Reference

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 308

!

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

PETERBOROUGH ltEGIONAl COLLEGE


PARK CRESCENT
PETERBOROU~H PEl 4DZ

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.

All correspondence should be addressed to:

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

First published 1984


Published by Acorn Computers Limited
r

CIS COBOL

LANGUAG~ REFERENCE

MANUAL

Version 4 . 5
r
r

r
~
!

Micro Focus Limited Issue 10


November 1982

r
r
~j
CONTENTS

CIS COBOL language reference manual


Introduction 30
COBOL Concepts 36

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.

No warranty, expressed or implied, is made by any contributor or by the


CODASYL Programming Language Committee as to the accuracy and functioning of
the prograrr~ing system and language. Moreover, no responsibility is assumed
by any contributor, or by the committee, in connection herewith .

The authors and copyright holders of the copyrighted material used


herein:

FLOW-MATIC (Trademark for Sperry Rand Corporation) Programming for the


Univac(R) I and II, Data Automation Systems copyrighted 1958, 1959, by
Sperry Rand Corporation; IBM Commercial Translator Form No. F28-8013,
copyrighted 1959 by IBM; FACT, DSI27A5260-2760, copyrighted 1960 by
Minneapolis-Honeywell.

have specifically authorized the use of this material in whole or in part,


in rhe COBOL specifi.cations. Such authorization extends to the reproduction
and use of COBOL specifications in programming manuals or similar
publications.

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.

Each release of CIS COBOL is characterized by a two-digit code in the form


of

"Version number". "Release number within version"

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.

Chapters 8 through 11 apply to all users and describe additional features


and facilities available with the standard language. The appendices supply
reference information pertinent to all systems.

The manual contains the following chapters and appendices:

"Chapter 1. Introduction", which gives a general description of the


language, including a broad outline of ANSI COBOL features included and
omitted and additional features of CIS COBOL.

"Chapter 2. COBOL Concepts", which describes general concepts of the COBOL


language including program structure, and details of statement components
and notation.

"Chapter 3. Nucleus", which describes the nucleus of all COBOL programs and
the layout of each program division in the nucleus.

"Chapter 4. Table Handling", which describes the handling of data tables in


the Data and Procedure divisions of a COBOL program.

"Chapter 5. Sequential Input and Output", which describes the programming of


input and output of data in files with sequential format.

"Chapter 6. Relative Input and Output", which describes the programming of


input and output of data in files with relative format.

2
"Chapter 7. Indexed Input and Output", which describes the programming of
input and output of data in files with indexed format.

"Chapter 8. Segmentation", which describes the facility for specifying


permanent and independent object program segments.

"Chapter 9. Library", which describes the source library maintenance feature


of COBOL.

"Chapter 10. Debug and Interactive Debugging", which describes the basic and
interactive debugging features available in CIS COBOL.

"Chapter 11. Interprogram Communication", which describes the ability of CIS


COBOL programs to interface during running and to access common data,
enabling modular programming.

"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 B. Character Set and Collating Sequence", which lists all


characters available and their collating sequence.

"Appendix C. Glossary", which lists specific terms used in CIS COBOL.

"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.

"Appendix G. Summary of Extensions to ANSI COBOL", which summarizes all


extensions to ANSI COBOL provided by CIS COBOL.

"Appendix H. System Dependent Language Features", which describes the


system dependent CIS COBOL entries for use with microcomputers and those
features not included because of hardware requirements.

"Appendix I. Language Specification", which is an overall specification of


the CIS COBOL language.

RELATED PUBLICATIONS

No discussion of operating the CIS COBOL Compiler or Run-Time system is


incorporated in this manual. Please refer to document:
CIS COBOL Operating Guide
(for use with the relevant Operating System)

3
NOTATION IN THIS MANUAL

Throughout this manual, the following notation is used to describe the


format of COBOL statements:

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.

4. When material is enclosed in braces , a choice must be made from


the options within them.

5. When material is enclosed in square brackets [ ], it is an indication


that the material is an option which may be included or omitted as
required.

6. When material is enclosed in square brackets crossed f f, it is an


indication that the material is mandatory when the ANSI switch is set
(see Chapter 2) but optional otherwise.

7. Language features that are shaded in the text are language extensions
which exceed the ANSI standard.

8. In text, the ellipsis ( •.• ) shows the omission of a portion of a source


program or a sequence. This meaning becomes apparent in context.

In the general formats, the ellipsis represents the position at which


repetition may occur at the user's option. The portion of the format
that may be repeated is determined as follows:

Given • • • in a clause or statement format, scanning right to left,


determine the or [ immediately to the left of the ••• ; continue
scanning right to left and determine the logically matching or]; the
applies to the words between the determined pair of delimiters.

9. The term identifier means either a data-name or a subscripted


data-name. An identifier takes the following form:

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

ORDER ONE READING


ORDER TWO HEADING

Order Three Heading Text two lines down

Order Four Heeding

Order Five Reading: Text on same line

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

WHAT IS CIS COBOL? ·JO

PROGRAM STRUCTURE 31

FORMATS AND RULES 32

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

FUNCTION OF THE NUCLEUS 63


IDENTIFICATION DIVISION IN THE NUCLEUS 63

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

ENVIRONMENT DIVISION IN THE NUCLEUS 65

CONFIGURATION SECTION 65

The SOURCE-COMPUTER Paragraph 65


Function 65
General Format 65
Syntax Rule 65
General Rules 65

The OBJECT-COMPUTER Paragraph 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 COMPUTER INDEPENDENT DATA DESCRIPTION 43

Concept of Levels

Level-Numbers 44

Concept of Classes of Data 44


Selection of Character Representation and Radix 45
Algebraic Signs 47
Standard Alignment Rules 47
Uniqueness of Reference 48

Subscripting 48
Indexing 48
Identifier 49
Condition-Name ·30

PROGRAM STRUCTURE 50

THE "ANSI SWITCH" COMPILER DIRECTIVE 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

Data Division Organization 53


General Format 54

PROCEDURE DIVISION 55
GENERAL DESCRIPTION 55
Declarations 55
Procedures 55
Execution 56
General Format

Procedure Division Header 56


Procedure Division Body 56

STATEMENTS AND SENTENCES 56

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, SECTION, PARAGRAPH FORMATS 60

Division Header 60
Section Header 60
Paragraph Header, Paragraph-Name and Paragraph ·60

DATA DIVISION ENTRIES 61


DECLARATIVE$ 62
COMMENT LINES 62

RESERVED WORDS 62

8
Syntax Rules 75
General Rules 75

Alphabetic Data Rules 75


Numeric Data Rules 75
Alphanumeric Data Rules 76
Alphanumeric Edited Data Rules 76
Numeric Edited D~ta Rules 76
Elementary Item 5ize 76
Symbols Used 77

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

THE REDEFINES CLAUSE 85

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

THE SYNCHRONIZED CLAUSE 89

Function 89
General Format 89
Syntax Rules 89
General Rules 89

THE USAGE CLAUSE 91

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

PROCEDURE DIVISION IN THE NUCLEUS 94

CONDITIONAL EXPRESSIONS 94

Simple Conditions 94

Relation Condition ·94

Comparison of Numeric 94
Operands
Comparison of Nonnumeric 94
Operands
Class Condition 96
Switch-Status Condition 97

COMMON PHRASES AND GENERAL RULES FOR STATEMENT FORMATS 98

The ROUNDED Phrase 98


The SIZE ERROR Phrase 98

SIZE ERROR Phrase Not Specified 98


SIZE ERROR Phrase Specified 98

Arithmetic Statements 99
Overlapping Operands 99
Incompatible Data 99
CRT Devices 99

THE ACCEPT STATEMENT 100

Function 100
General Formats 100
Syntax Rule 100
General Rules 100

THE ADD STATEMENT 103

Function 103
General Format 103 ~.
Syntax Rules 104
General Rules 104

12
~

r-
THE ALTER STATEMENT 105

r-' Function 105


105
General Format
Syntax Rules 105
,.,.. General Rule 105

106
THE DISPLAY STATEMENT

,.. Function
General Format
Syntax Rules
General Rules
106
106
106
101i

THE DIVIDE STATEMENT 108


~
Function 108
General 108
Syntax Rules 108
r- General Rules 108

110
THE ENTER STATEMENT
110
r- Function
General
Syntax Rule
110
110
General Rule 110

~ THE EXIT STATEMENT 111


I

Function 111
General Format 111
Syntax Rules 111
r-"' General Rules 111

THE GO TO STATEMENT 112

~ 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

THE MOVE STATEMENT 122

Function 122
General Format 122 ~
Syntax Rules 122
General Rules 122

THE MULTIPLY STATEMENT 125 ~

Function 125
General Format 125
Syntax Rules 126
~
General Rules 126

THE PERFORM STATEMENT 127

Function 127
General Format 127
Syntax Rules
General Rules

THE STOP STATEMENT


127
127

131
... \

Function 131
General Format 131
Syntax Rules 131
General Rules 131

THE SUBTRACT STATEMENT 132

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

THE USAGE CLAUSE 136

Function 136
General Format 136
Syntax Rules 136
General Rules 136

PROCEDURE DIVISION iN THE TABLE HANDLING MODULE 137

RELATION CONDITION 137

Comparisons Involving Index-names and/or 137


Index Data Items

OVERLAPPING OPERANDS 137


THE SET STATEMENT 137

Function 137
General Fomat 137
Syntax Rules 137
General Rules 138

r CHAPTER 5

SEQUENTIAL INPUT AND OUTPUT


INTRODUCTION TO THE SEQUENTIAL I-0 MODULE 140

LANGUAGE CONCEPTS 140

Organization 140
Access Mode 140

15
Current Record Pointer 140
I-0 Status 140

Status Key I 140


Status Key 2 141
Valid Combinations of Status
1 and 2 141
The AT END Condition 142

ENVIRONMENT DIVISION IN THE SEQUENTIAL I-0 MODULE 143

INPUT-OUTPUT SECTION 143


The FILE-CONTROL paragraph 143
Function 143
General Format 143
The FILE-CONTROL Entry 143
Function 143
General Format 143
Syntax Rules 143
General Rules 144

The I-0 CONTROL Paragraph 145

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

THE BLOCK CONTAINS CLAUSE 148

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

THE DATA RECORDS CLAUSE 148

Function 148
General Format 148
Syntax Rule 149
General Rule 149

THE LABEL RECORDS CLAUSE 149

Function 149
General Format 149
Syntax Rules 149
General Rules 149

THE RECORD CONTAINS CLAUSE 149

Function 149
General Format 149
General Rule 149

THE VALUE OF CLAUSE 150

Function 150
General Format 151
General Rules 151

PROCEDURE DIVISION IN THE SEQUENTIAL I-0 MODULE 151

THE CLOSE STATEMENT 151

Function 151
General Format 151
Syntax Rule 151
General Rules 151

THE OPEN STATEMENT 152

Function 152
General Format 152
Syntax Rules 152
General Rules i52

17
....
\

THE READ STATEMENT 155

Function 155
General Format 155
Syntax Rules 155
General Rules 155

THE REWRITE STATEMENT 157

Function 157
General Format 157
Syntax Rules 157
General Rules 157

THE USE STATEMENT 156

Function 156
General Format 156
Syntax Rules 156
General Rules 156

THE WRITE STATEMENT 159

Function 159
General Format 159
Syntax Rules 159
General Rules 159

CHAPTER 6

RELATIVE INPUT AND OUTPUT

IN~&C.uUCTION TO THE RELATIVE I-0 MODULE 162

LANGUAGE CONCEPTS 162

Organization 162
Access Modes 162
Current Record Pointer 162
I-0 Status 162

Status Key 1 163


Status Key 2 163
Valid Combination of Status Keys
1 and 2 164
The INVALID KEY Condition 165
The AT END Condition 165

16
ENVIRONMENT DIVISION IN THE RELATIVE I-0 HODULE 166

INPUT-OUTPUT SECTION 166

The File-Control Paragraph 166

Function 166
General Format 166

The File-Control Entry 166

Function 166
General Format 166
Syntax Rules 166
General Rules 167

The I-0 CONTROL Paragraph 168

Function 168
General Format 168
Syntax Rules 168
General Rules 168

DATA DIVISION IN THE RELATIVE I-0 MODULE 169

FILE SECTION 169


RECORD DESCRIPTION STRUCTURE 169
THE FILE DESCRIPTION-COMPLETE ENTRY SKELETON 169

Function 169
General Format 169
Syntax Rules 170

THE BLOCK CONTAINS CLAUSE 170

Function 170
General Format 170
General Rules 170

THE DATA RECORDS CLAUSE 170

Function 170
~ General Format 170
I Syntax Rule 170
General Rule 170

19
~

THE LABEL RECORDS CLAUSE 171

Function 171
Format 171
S~ntax Rul~ 171
General Rule 171

THE RECORD CONTAINS CLAUSE 171

Function 171
Format- 171
General P.ules 171

THE VALUE OF CLAUSE 172


lillllii
Function 172
General Format 172
S~ntax Rules 172
General Rules 172
~
PROCEDURE DIVISION IN THE RELATIVE I-0 MODULE 173

THE CLOSE STATEMENT 173


Function 173
General Format 173
S~ntax Rule 173
General Rules 173
~
THE DELETE STATEMENT 174

Function 174
General Format 174 ~
S~ntax Rules 174
General Rules 174

THE OPEN STATEMENT 175


~
Function 175
General Format 175
S~ntax Rule 175
General Rules 175 ~

THE READ STATEMENT 177

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

THE START STATEMENT 183

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

THE WRITE STATEMENT 186

Function 186
General Format 186
Syntax Rules 186
General Rules 186

CHAPTER 7

INDEXED INPUT AND OUTPUT

INTRODUCTION TO THE INDEXED I-0 MODULE 188

LANGUAGE CONCEPTS 188

Organization 188
Access Modes 188
Current Record Pointer 188
I-0 Status 189

Status Key 1 189


Status Key 2 189
Valid Combination of Status Keys
1 and 2 190
The INVALID KEY Condition 191
The AT END Condition 191

21

p-.
\
ENVIRONMENT DIVISION IN THE INDEXED I-Q MODULE 192

INPUT-OUTPUT SECTION 192

The File Control Paragraph 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

The I-0 Control Paragraph 194

Function 194
General Format 194
Syntax Rules 194
General Rules 194

DATA DIVISION IN THE INDEXED I-0 MODULE 195

FILE SECTION 195


RECORD DESCRIPTION STRUCTURE 195
THE FILE DESCRIPTION-COMPLETE ENTRY SKELETON 195

Function 195
General Format 195
Syntax Rules 195

THE BLOCK CONTAINS CLAUSE 196

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-
................

THE LABEL RECORDS CLAUSE 197


r- Function 197
General Format 197
General Rule 197

r-' THE RECORD CONTAINS CLAUSE 197

Function 197
General Format 197
~ General Rule 197

THE VALUE OF CLAUSE 197

Function
r-' General Format
197
197

,. General Rules
PROCEDURE DIVISION IN THE INDEXED I-0 MODULE

THE CLOSE STATEMENT


197
198

198

Function 198
General Format 198
L S:t:ntax Rule
General Rules
198
198

THE DELETE STATEMENT 199


F-" Function 199
General Format 199
S:t:ntax Rules 199
r- General Rules

THE OPEN STATEMENT


199
200

Function 200
r-' General Format
S:t:ntax Rules
200
200
General Rules 200

r THE READ STATEMENT


Function
203
203
General Format 203
203
,...... S:t:ntax Rules
General Ru 1 es 203

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

THE USE STATEMENT 210 ~

Functi on 210
General Format 210
S~ntax Rule's 210
General Rules 210

THE WRITE STATEMENT 211

Function 211 !iiiiill


General Format 211
S~ntax Rules 211
General Rules 211
~
CHAPTER 8

SEGMENTATION
fillr,ij
'
INTRODUCTION TO THE SEGMENTATION MODULE 214
GENERAL DESCRIPTION OF SEGMENTATION 214

ORGANIZATION 214 ~

Prosram Se~ents 214


Fixed Portion 214
Inde2endent Se~nts 214
-~
SEGMENTATION CLASSIFICATION 215
SEGMENTATION CONTROL 215

24
STRUCTURE OF PROGRAM SEGMENTS 216

SEGMENT NUMBERS 216


GENERAL FORMAT 216
SYNTAX RULES 216
GENERAL RULES 216

RESTRICTIONS ON PROGRAM FLOW 217

THE ALTER STATEMENT 217


THE PERFORM STATEMENT 217

EXTRA INTERMEDIATE CODE FILES 217

CHAPTER 9

LIBRARY

INTRODUCTION TO THE LIBRARY MODULE 219


THE COPY STATEMENT 220

FUNCTION 220
GENERAL FORMAT 220
SYNTAX RULES 220
GENERAL RULES 220

CHAPTER 10

DEBUG AND INTERACTIVE DEBUGGING

INTRODUCTION 221
CIS COBOL RUN-TIME DEBUG EXTENSION 221
STANDARD ANSI COBOL DEBUG 221

COMPILE TIME SWITCH 222


COBOL DEBUG OBJECT TIME SWITCH 222
ENVIRONMENT DIVISION IN COBOL DEBUG 22:!

The WITH DEBUGGING MODE Clause 222

Function 222
General Format 222
General Rules 222

25
PROCEDURE DIVISION IN COBOL DEBUG 223

The USE FOR DEBUGGING Statement 223

Function 223
General Format 223
Syntax Rules 223
General Rules 223

DEBIJGGING LINES 226

CHAPTER 11
INTERPROGRAM COMMUNICATION
INTRODUCTION TO THE INTER-PROGRAM COMMUNICATION MODULE 227 fM!li,
DATA DIVISION IN THE INTER-PROGRAM COMMUNICATION MODULE 227

LINKAGE SECTION 227

Noncontiguous Linkage Storage 228

PROCEDURE DIVISION IN THE INTER-PROGRAM COMMUNICATION MODULE 229


THE PROCEDURE DIVISION HEADER 229

THE CALL STATEMENT 230

Function 230
General Format 230
Syntax Rules 230
General Rules 230

THE CANCEL STATEMENT 232

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

PROGRA}~ING TECHNIQUES, USEFUL HINTS AND PROGRAM SIZING

PROGKAMMING TECHNIQUES 234


USEFUL HINTS 234

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

2-1 Figurative Constants and their Reserved Words 42


2-2 Data Levels Classes and Categories 45
2-3 Numeric Data Storage for the COMP(UTATIONAL) PICTURE
Clause ~6
2-4 Numeric Data Storage for the COMP-3 PICTURE CLAUSE 47

3-1 Editing Types for Data Categories 79


3-2 Editing Symbols in PICTURE Character-Strings 80
j-j PICTURE Character Precedence ChKrt 83
3-4 Relational Operators 95
3-5 Cursor Repositioning Keys 103
3-6 MOVE Statement Data Categories 125

4-1 SET Statement Valid Operand Combinations 139

5-1 Permissible Combinations of Statements and


OPEN Modes for Sequential I-0 153

6-1 Permissible Combinations of Statements and


OPEN Modes for Relative I-0 176

7-1 Permissible Combinations of Statements and


OPEN Modes for Indexed I-0 201

12-1 Data Dictionary Entry Sizing 236

ILLUSTRATIONS

1-1 Sample Program Listing Showing Source .Format 35

2-1 Reference Format for a COBOL Source Line 59

3-1 PERFORM Statements in Sequence 129

29
CHAPTER 1

INTRODUCTION

WHAT IS CIS COBOL?

COBOL (COmmon Business Oriented Language) is the most widely and


extensively used language for the programming of commercial and
administrative data processing.

CIS COBOL is a Compact, Interactive and Standard COBOL Language System


which is designed for use on microprocessor-based computers and intelligent
terminals.

It is based on the ANSI COBOL given in "American National Standard


Programming Language COBOL" (ANSI X3.23 1974). The CIS COBOL implementation
has been selected from both levels of ANSI COBOL. The following modules are
fully implemented at Level 1:

Nucleus
Table Handling
Sequential Input and Output
Relative Input and Output
Indexed Input and Output
Segmentation
Library
Inter-Program Communication
Debug .

In addition many Level 2 features are implemented such as:

Nucleus -Nested IF, PERFORM UNTIL


Relative and Indexed sequential I/0 - START statement
Inter-Program Communication - CANCEL statement

This manual is intended as a reference work for COBOL programmers and


material from the ANSI language standard document is included.

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 programmer wishing to transport an existing COBOL program to run


under CIS COBOL must check that the individual language features he has used
are supported by CIS COBOL. The COBOL SECTION statements in the
Segmentation feature can be performed using the PERFORM statement.
30
A compile time ANSI switch can be set that makes certain COBOL source
mandatory, whereas if not set it is optional. (See Chapter 2).

The CIS COBOL compiler is designed to enable programs to be developed


in a 48K machine. The Compiler supports sequential, relative and indexed
sequential files, as well as interactive communications via the ACCEPT and
DISPLAY verbs.

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.

CIS COBOL is designed to be interfaced easily to any microprocessor


operating system. Detailed operating characteristics are dependent on the
particular host operating system used and are defined in the appropriate
Operating Guide.

PROGRAM STRUCTURE

A COBOL program consists of four divisions:

1. IDENTIFICATION DIVISION - An identification of the program

2. ENVIRONMENT DIVISION - A description of the equipment to be used to


compile and run the program

J, DATA DIVISION - A description of the data to be processed

4. PROCEDURE DIVISION - A set of procedures to specify the operations to


be performed on the data

Each division is divided into sections which are further divided into
paragraphs which in turn are made up of sentences.

Within these subdivisions of a COBOL program, further subdivisions


exist as clauses and statements. A clause is an ordered set of COBOL
elements that specify an attribute of an entry, and a statement is a
combination of elements in the Procedure Division that include a COBOL verb
and constitute a program instruction.

31
FORMATS AND RULES

GENERAL FORMAT

A general format is the specific arrangement of the elements of a


clause or a statement, Throughout this document a format is shown adjacent
to information defining the clause or statement. When more than one
specific arrangement is permitted, the general format is separated into
numbered formats. Clauses must be written in the sequence given in the
general formats. (Clauses that are optional must appear in the sequence
shown if they are used). In certain cases, stated explicitly in the rules
associated with a given format, the clauses may appear in sequences other
than that shown. Applications, requirements or restrictions are shown as
rules.

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

A general rule is a rule that defines or clarifies the meaning or


relationship of meanings of an element or set of elements. It is used to
define or clarify the semantics of the statement and the effect that it has
on either execution or compilation.

ELEMENTS

Elements which make up a clause or a statement consist of uppercase


words, lowercase words, level-numbers, brackets, braces, connectives and
special characters (see Chapter 2),

32
SOURCE FORMAT

The COBOL source format divides each COBOL source record into 72
columns. These columns are used in the following way:

Columns 1 6 Sequence number


Column 7 Indicator area
Columns 8 - 11 Area A
Columns 12 -72 Area B

SEQUENCE NUMBER

A sequence number of six digits may be used to identify each source


program line.

INDICATOR AREA

An asterisk * in this area marks the line as documentary comment only.


Such a comment line can appear anywhere in the program after the
Identification Division header. Any characters from the ASCII character set
can be included in Area A and Area B of the line.

A stroke I, in the indicator area acts as a comment line above but


causes the page to eject before printing the comment.

A "D" in the indicator area represents a debugging line. Areas A and B


may contain any valid COBOL sentence.

A "-" in the indicator area represents a continuation line.

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.

Program sentences may commence anywhere in Area A or Area B. More than


one sentence is permitted in each source record.

Note that TAB characters are not permitted in CIS COBOL source.

Figure 1-1 shows the source format of a typical program.

33
•• Cts COIOL V4.5 ~.CIL PACt: 0001

•• OPTtOIS ftL!crt.D :
P01Ut( 12)

000010 mDn"tna.noM ontstos. 0118


000020 Paei(;IAllt-tD. 51'00:-FILE-Stt~. 0118
000030 ADTBOl. ~c:lO FOO:S LTD. 0118
000040 Dl\'ll.OIDIDT DIV15 tON. 0118
000050 CORn~nOM SICTIO!O. 0118
000060 SOUJ.CI'-<:OMPat!l. 011 11
000070 OBJECT-coKPt!Ttl. 01111
000075 SPECl.U.-NNG:S , COMSOU IS Cll1'. 0118
000080 ISPUT-otiTPt'T S!CTlOt:. ?ll8
000090 F1LE-03fmi.OL. 0118
000100 SELECT !TOCJ.-nU A.SSICN ·noa..n· 01 ..
ooo110 oaC.\Hluno,. t~tll 0186
000120 A.CCISS O'f!WnC 01~6
000130 I!COID I:ET STOa--tODt, 0186
0001'0 DATA Dtvl.SIOJ;. OliE
OOOUO fUl S!crtOJI. Olfl!
ooouo n noa.-nu: ucoJ.D u . OliE
000110 01 STOCt-tTDt. 010[
000180 02 stoat-CODE PIC Ji(4 ) , Olllt
000190 02 PIDDDCT•DESC PIC Ji(20) . 01Cl
000200 CQ UIIT-IIZI PIC 9(' ). 01D6
000210 WUUUCC·S1'0UGI SECTlOlll . 01DC
000220 01 ICI:DM- BUDllfCS .
000230 OZ A.St.-coot PIC l( 21) '1Al.Ot • STOCI. COD[
,. _ OtDC 00
OlDC 00
0002'0 02 nLLU ftC 1(59) , Otrl 15
000250 01 ASI....OtsC PIC 1(16) VALUE ·oESCllPnOt: <• . D22C 50
000260 02 SI-O!SC PIC Ji( U) 'li'Al.Ot • >", 023C 60
000210
00021(1
Ol FtLUR PIC 1(63).
02 ASl-stU PIC Ji(21) 'li'.U.UE •UNIT StU ,._ 02" ,,
OZ 7C IIIJ
000290 01 l!fT!l•lT I£D!FlJIES SCU!H-RlADUIC$ . OlDC 00

-
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

0004 20 fi)IIW.• IIPUT. 0038 00


00000 KD'Vt SPACE TO EJm:R-IT , 0039
OOOUO D1SPLA1 r:tm:l-IT. OOlF
000450 COUlct-GJtOi., 0056 00
000460 A.CC!PT !llftR··lT. 0011
000,10 IF ClT ·STOCJ.-coD£ • SPAC[ GO TO D!D tt. 006t
000480 tr Clt-1.!5tT·SI1E :tOT ~ate GO TO COU!C':'-~UOR , 0078
000490 !'llVl OtT-PIOD-OUC TO PIDDUCT-D!SC. 0081
000500 !«1'11 CIT-tlxtt•SI!! TO tJWIT-SlZE, 0087

........ .....
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

Figure 1 - 1. Sample Program Listing Showing Source Format ,

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

The individual characters of the l anguage are concatenated to form


character- s t rings and separators. A separator may be concatenated with
another separator or with a character- string. A character- string may only
be conca t enated with a separator. The conca tenation of character-strings
and separators forms the text of a sour ce program .

Separators

A separator is a string of one or more punctuation characters. The


rules for formation of separators are:

1. The punctuation character space is a separator. Anywhere a space is


used as a separa t or, more than one space may be used.

2. The punctua ti on characters comma, semicolon and period, when


immedia•ely followed by a space, are separators. These separa t ors

36
may appear in a COBOL source program only where explicitly permitted by

-F-'- the general formats, by format punctuation rules (see


FORMATS AND RULES in Chapter 1), by statement and sentence structure
definitions (see STATEMENTS AND SENTENCES in this Chapter), or
reference format rul~s (see REFERENCE FORMAT in this Chapter).

3. The punctuation characters right and left parenthesis are separators.


Parenthesis may appear only in balanced pairs of left and right
parentheses delimiting subscripts, indices, arithmetic expressions, or
conditions.

4. The punctuation character quotation mark is a separator. An opening


quotation mark ~ust be ~diately preceded by a space or left
parenthesis; a closing quotation mark must be immediately followed by
one of the separators space, comma, semicolon, period, or right
parenthesis.

Quotation marks may appear only in balanced pairs delimiting nonnumeric


literals except when the literal is continued. (See
CONTINUATION OF LIN~a in this Chapter).

5. The separator space may optionally immediately precede all separators


except the following:

a. As specified by reference format rules see REFERENCE FORMAT


in this Chapter.

b. The separator closing quotation mark. In this case, a


preceding space is considered as part of the nonnumeric
literal and not as a separator.

6. The separator space is optional and can immediately follow any


separator except the opening quotation mark. In this case, a following
space is considered as part of the nonnumeric literal and not as a
separator.

Any punctuation character which appears as part of the specification of


a PICTURE character-string (see Chapter 3) or · numeric literal is not
considered as a punctuation character, but rather as a symbol used in the
specification of that PICTURE character-string or numeric literal. PICTURE
character-strings are delimited only by the separators space, comma,
semicolon, or period.
The rules established for the formation of separators do not apply to
the characters ·which comprise the contents of nonnumeric literals,
comment-£ntries, or comment lines.

37
Character-Strings

A character-string is a character or a sequence of contiguous


characters which forms a CIS COBOL word, a literal, a PICTURE
character-string, or a comment-entry. A character-string is delillited by
separators .

COBOL Words

A COBOL word is a character-string of not more than 30 characters which


forms a user defined word, a system-name, or a reserved word. Within a
given source program these classes form disjoint sets; a COBOL word may
belong to one and only one of these classes.

User-Defined Words: A user-defined word is a COBOL word that n.ust be


supplied by the user to satisfy the format of a clause or statement. Each
character of a user-defined word is sel~cted frnm t.he ~Pt nf c~~~~~t~rs
'B', 'C', ... 'Z', lJII111L!iJil\llflllll, 'O', ... '9', and'-' w:·H.... e'Q!t
the '-' DBlf not appear as the first or last character.
fli.ti§': 1!11~ .~: i11l Rtwi t u~
IL'l?~ :4. - ~.

User-defined word types which are implemented are as follows:

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

Within a given source program, ten of these 12 types of user-defined


words are grouped into nine disjoint sets. The disjoint sets are:

alphabet-names
condition-names, data-names, and record-names
file-names
index-names
mnemonic-names
paragraph-names
program-names
section-names
text-names

All user-defined words, except segment-numbers and level-numbers, can


belong to one and only one of these disjoint sets. Further, all
user-defined words within a given disjoint set must be unique. (See
UNIQUENESS OF REFERENCE in this Section).

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.

Condition-Name: A condition-name is a name which is assigned to a


specific value, set of values, or range of values,
within a complete set of values that a data item may
assume. The data item itself is called a conditional
variable.

Condition-names may be defined in the Data Division or


in the SPECIAL-NAMES paragraph within the Environment
Division where a condition-name must be assigned to the
ON STATUS or OFF STATUS, or both, of the run time
switches.

A condition-name is used only in the RERUN clause or in


conditions as an abbreviation for the relation
condition; this relation condition posits that the
associated conditional variable is equal to one of the
set of values to which that condition-name is assigned.

Mnemonic-Name: A mnemonic-name assigns a user-defined word to an


implementor-name. These associations are established in
the SPECIAL-NAMES paragraph of the Environment Division.
(See SPECIAL-NAMES in Chapter 3).

Paragraph-Name: A paragraph-name is a word which names a paragraph in


the Procedure Division. Paragraph-names are equivalent
if, and only if, they are composed of the same sequence
of the same number of digits and/or characters.

Section-Name: A section-name is a word which names a section in the


Procedure Division. Section names are equivalent if, and
only if, they are composed of the same sequence of the
same number of digits and/or characters.

Other User-Defined
Names: See the glossary in Appendix C for definitions of all
other types of user-defined words.

System-Names: A system-name is a COBOL word which is used to

r communicate with the operating environment. Each


character used in the formation of a system-name must be
1 1
selected from the set of characters 'A', 8 , 'C', ...
'Z', IIIf.tWfliil !!!I'D', ... '9' and'-', except that
the '- ' may not appear as the first or last character.
There are three types of system-names:

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.

The system-names listed above are individually defined


in the glossary in Appendix C. fiiililil
Reserved Words: A resPrveod word is a COBOL word that is one of a
specified 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.
Reserved words can only be used as specified in the ~
general formats. (See Appendix A).

There are six types of reserved words:


1. Key words
2. Optional words
3. Connectives
4. Special registers
5. Figurative constants
6. Special-character words
Key Words : A key word is a word whose presence is required when the
format in which the word appears is used in a source
program. Within each format, such words are uppercase
and underlined.

Key words are of three types:


1. Verbs such as ADD, READ, and ENTER.
2. Required words, which appear in statement and entry
formats.
3. Words which have a specific functional meaning such
as NEGATIVE, SECTION, etc.
Optional \Jords: Within each format, uppercase words that are not
underlined are called optional words and may appear at
the user's option. The presence or absence of an
optional word does not alter the semantics of the CO~OL
program in which it appears.
Connectives: Series connectives link two or more consecutive
operands: (separator comma) or (separator

-
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

A literal is a character-string whose value is implied by an ordered


set of characters of which the literal is composed or by specification o~ a
reserved word which references a figurative constant. Every literal belongs
to one of two types, nonnumeric or numeric.

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:

l. The delimiting quotation marks are exc lud ed, and


2. C:a..:il embe<i<iea pa1r at contig uous quotation marks
represents a single quo t ation mark cha racter.

All other punctuation characters are pa rt of the value of the nonnumeric


literal r a th e r th an separators; all nonnum<, ric literal are ca t egory alpha-
numeric. (See The P ICTURE Clause in chapte r 3) . In addition, ''hexadecirii'a.t
binary values can be attributed to non-numeric literals by, express'ing:
literals as: X"nn", where n is a hexadecimal character in the set 0-9 A-F; 1
nn may be r epeated up to 128 times, but the nu.mber of hex digits ,
even .

Numeric Literal s: A numeric literal is a charac t er-string whose charac t e rs


are selected from the digits 'O' throu gh 1 9 1 , th e plus
sig n, the minus sign , and/o r th e decimal point. The
imp l ement a tion allows for numeric lit erals of 1 through
18 digits in length. The rules for the formation of
numeric literals are as follows:

1. A literal must con tain at least one digit .


2. A literal must not contain more than one sign
character. If a sig n i s used, it must appear as
the leftmost charac t er of the lit e r~l. If the
literal is unsigned, the lit e r al i s pos itiv e .
3. A literal must not con tain more than one dP.cimal
point. The decimal point is trea t ed as an assumed
decimal point, and may appear anywhere wi thin the
literal except as the rightmost charac t er . IE th e
literal cont ains no decimal point, the literal is
an in t ege r.
IE a lit eral con forms to th e rul es fo r th e
formation of nume ric literals, but is o>nclosed in
quotation marks, it is a nonnume ric litera l and it
is trea ted as such by the compil e r.
4. The value of a numeric lit e ral is the algeb raic
quality represented by the characters in the
nume ric lit eral. Every numeric lit e ral is ca tegory
numeric. (See THE PICTURE CLAUSE in Chapter 3).
The s iz e of a numer-ic lit e r-al in standard data
format charact ers is eq ual to th e number- of digits
specified by t he user.

41
Figurative Constant
Values

Figurative Constant Values are generated by the compiler and referenced


through the use of the reserved words given below. These words must not be
bounded by quotation marks when used as figurative constants. The singular
and plural forms of figurative constants are equivalent and may be used
interchangeably.

The figurative constant values and the reserved words used to reference them
are shown in Table 2-1.

Table 2-1. Figurative Constants and their Reserved Words

CONSTANT REPRESENTATION

Represents th~ value '0', or one or more


of the cha racter 'O' depending on context.
ZEROS
ZEROES

SPACE Represents one or more of the character


SPACES space from the computer's character set.

HIGH-VALUE Represents one or more of the character


HIGH-VALUES that has the highest ordinal position in
the program collating sequence.

LOW-VALUE Represents one or more of the character that


LOW-VALUES has the lowest ordinal position in the program
collating sequence .

Represents one or more of the character ' " '.


The word QUOTE or QUOTES cannot be used in
place of a quotation mark in a source program
to bound a nonnumeric literal. Thus, QUOTE
ABD QUOTE is incorrect as a way of stating
the nonnumeric literal "ABD" .

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.

When a figurative constant represents a string of one or more characters,


the length of the string i s determined by the compiler from context
according to the following rules:

1. When a figurative constant is associated with another data item, as


when the figurative constant is moved to or compared with another data

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.

2. When a figurative constant is not associated with another data item, as


when the figurative constant appears in a DISPLAY or STOP statement,
the len h of the string is one character.

A figurative constant may be used wherever a literal appears in a


format, except that whenever the literal is restricted to having only
numeric characters in it, the only figurative constant permitted is ZERO
(ZEROS, ZEROES).

t·!h~n the £i6ur&lti·.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).

Each reserved word which is used to reference a figurative constant


value is a distinct character-string with the exception of the construction
'ALL literal' which is composed of two distinct character-strings.

PICTURE Character-Strings

A PICTURE character-string consists of certain combinations of


characters in the COBOL character set used as symbols. See
The PICTURE Clause for the PICTURE character-string and for the rules that
govern their use.

Any punctuation character which appears as part of the specification of


a PICTURE character-string is not considered as a punctuation character, but
rather as a symbol used in the specification of that PICTURE
character-string.

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 COMPUTER INDEPENDENT DATA DESCRIPTION

To make data as computer independent as possible, the characteristics


or properties of the data are described in relation to a standard data
format rather than an equipment-oriented format. This standard data format

r is oriented to general data processing applications and uses the deci'DB.l


system to represent numbers (regardless of the radix used by the compute~)
and the remaining characters in the CIS COBOL character set to describe
nonnumeric data items.

Concept of Levels

A level concept is inherent in the structure of a logical record. This

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.

In order to refer to a set of elementary items, the elementary items


are combined into groups. Each group consists of a named sequence of one or
more elementary items. Groups, in turn, may be combined into groups of two
or more groups, etc. Thus, an elementary item may belong to more than one
group.

Level-Numbers

A system of level-numbers shows the organization of elementary items


and group items. Since records are the most inclusive data items,
level-numbers for records start at 01. Less inclusive data items are
assigned higher (not necessarily successive) level-numbers not greater in
value than 49. A maximum of 49 levels in a record is allowed. There is a
special level-number, 77, which is an exception to this rule (see below).
Separate entries are written in the source program for each level-number
used.

A group includes all group and elementary items following i t until a


level-number less than or equal to the level-number of that group is
encountered. All items which are immediately subordinate to a given group
item must be described using identical level-numbers gr .~r than the
level-number used to describe that 8r'0Ul'! item.
i'idi !'A '~~a· . l~tl,\ . o=<~llo"~""'

Two types of entries exist for which there is no true concept o£ level.
These are:

l. Entries that specify noncontiguous working storage and linkage data


items
2. Entries that specify condition-names .

Entries that specify noncontiguous data items, which are not


._,
•I
subdivisions of other items, and are not themselves subdivided, have been
assigned the special level-number 77.

Concept of Classes of Data

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

Table 2-2 Data Levels, classes and categories

LEVEL OF ITEM CLASS CATEGORY


Alphabetic Alphabetic
Numeric Numeric
Elementary Numeric Edited
Alphanumeric Alphanumeric Edited
Alphanumeric
Alphabetic
Numeric
Non-Elementary Alphanumeric Numeric Edited
Group Alphanumeric Edited
Alphanumeric

Selection of Character Representation and Radix

The value of a numeric item may be represented in either binary or

r decimal form, depending on the equipment. In addition, there are several


ways of expressing decimal. Since these representations are actually
combinations of bits, they are commonly called binary-coded decimal forms.
The four standard formats used for storing numeric data in CIS COBOL are as
follows:

1. As alphanumeric characters stored one per byte in ASCII representation.

2. As numeric characters defined by USAGE IS DISPLAY (See The USAGE Clause


in Chapter 3) one per byte in ASCII representation. If they are signed
and the sign is specified as rNCLUDED, bit 6 of the leading or trailing
byte of the field is set for negative, depending on the field
definition. rf a SEPARATE sign is specified as a one byte ASCII + or
, a sign is added as the leading or trailing byte. If no SIGN clause
is specified, bit 6 of the trailing digit is set to indicate negative
by default.

3. As numeric characters defined by USAGE IS COMP or COMPUTATIONAL in pure


binary form. If the field is signed the number is held in its
twos-complement form. Storage is then dependent on the number of 9's
in the PICTURE clause (see The PICTURE Clause in Chapter 3) and on
whether the field is SIGNed or not (see The SIGN Clause in Chapter 3).

Table 2-3 shows the storage requirements for each COMP(UTATIONAL)


PICTURE Clause.

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

4. As numeric characters defined by USAGE IS COMPUTATIONAL-3 or USAGE IS


COMP-3 in packed internal decimal form. Storage is dependent on the
number of 9's in the PICTURE clause. The decimal numbers are stored as
signed strings of variable length of 1 through 18 digits. The sign of
the packed decimal number is always stored in place of the least
significant quartet of the low order byte. Each byte contains :wo
decimal positions (four bits per digit) and the digits (0 - 9) are
encoded as BCD numbers (0000 - 1001). Numbers are represented in the
field as right-justified values with a + or - sign as shown in the
example below. The maximum number of digits permitted in arithmetic
operands is LB.

EXAMPLE:

a. For COMPUTATIONAL-3 and PICTURE 9999, the number +1234 would be


stored as follows:

0 2 3 4 F

0000 0001 0010 0011 0100 1111

byte

where F represents the non-printing plus sign.

b. For COMPUTATIONAL-3 and PICTURE S9999, the number +1234 would be


stored as follows:

Storage would be as in a above except that the least significant


digit would be replaced by C (1100) representing the plus sign.

c. For COMPUTATIONAL-) and PICTURE S9999, the number -1234 would be


stored as follows:

Storage would be as in a above except that the least significant


byte would be replace~ by D (1101) representing the minus sign.

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.

The SIGN Clause permits the programmer to state explicitly, the


location of the operational sign. The Clause is optional; if it is not used
operational signs will be represented as defined by setting bit 6 of the
trailing digit for ASCII numbers. (see above).

Editing signs are inserted into a data item through the use of the sign
control symbols of THE PICTURE CLAUSE.

Standard Alignment Rules

The standard rules for positioning data within an elementary item


depend on the category of the receiving item. These rules are:

l. If the receiving data item is described as numeric:

a. The data is aligned by decimal point and is moved to the receiving


character positions with zero fill or truncation on either end as
required.

b. When an assumed decimal point is not explicitly specified, the


data item is treated as if it had an assumed decimal point
immediately following its rightmost character and is aligned as in
paragraph a. above.

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.

If the JUSTIFIED Clause is specified for the receiving item, these


standard rules are modified as described in THE JUSTIFIED CLAUSE in
Chapter 3.

Uniqueness of Reference

Subscripting

Subscripts can be used only when reference is made to an individual


element within a list or table of like elements that have not been assigned
individual data-names (see THE OCCURS CLAUSE in Chapter 4). The subscript
can be represented either by a numeric literal that is an integer or by a
data-name, The data-name must be a numeric elementary item that represents
an integer. The subscript may be signed and, if signed, it must be
positive. The lowest possible subscript value is 1. This value points to
the first element of the table. The next sequential elements of the table
are pointed to by subscripts whose values are 2, 3, The highest
permissible subscript value, in any particular case, is the maximum number
of occurrences of the item as specified in the OCCURS clause.

The subscript, or set of subscripts, that identifies the table element


is delimited by the balanced pair of separators left parenthesis and right
parenthesis following the table element data-name. The table element
data-name appended with a subscript is called a subscripted data-name or an
identifier. When more than one subscript is required, they are written in
the order of successively less inclusive dimensions of the data
organization.

The format is:


data-name (subscript-1 [, subscript-2 [, subscript-3 ]])
-
,-
Indexing

References can be made to individual elements within a table of like


elements by specifying indexing for that reference. An index is assigned to
that level of the table by using the INDEXED BY phrase in the definition of
a table. A name given in the INDEXED BY phrase is known as an index-name
and is used to refer to the assigned index. The value of an index
corresponds to the occurrence number of an element in the associated table.
An index-name must be initialized before it is used as a table reference.
An index-name can be given an initial value by a SET statement.

Direct indexing is specified by using an index-name in the form of a


subscript. Relative indexing is specified when the index-name is followed
by the operator + or -, followed by an unsigned integer numeric literal all
delimited by the balanced pair of separators left parenthesis and right

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 .

At the time of execution of a statement which refers to an indexed


table element, the value contained in the index referenced by the index-name
associated with the table element must neither correspond to a value less
than one nor to a value greater than the highest permissible occurrence
number of an element of the associated table. This restriction also applies
to the value resultant from relative indexing.

The general format for indexing is:

jdata-name I jindex-name-1 [{~} literal-2] f


r. )condition-namer (

hndex-name-2
)literal-1

[ {~} literal-4 ]I [• j index-name-3 [{~} literal-6]}~>


)literal-3 r )literal-5

Identifier

An identifier is a term used to reflect that a data-name, if not unique


in a program, must be followed by a syntactically correct combination of
subscripts or indices necessary to ensure uniqueness .

The general formats for identifiers are:

Format 1:

data-name-1 [ (subscript - 1 [, subscript-2 [, subscript-3]] >]

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:

l. A data-name must not itself be subscripted nor indexed when that


data-name is being used as an index, or subscript.

2. Indexing is not permitted where subscripting is not permitted.

3. An index may be modified only by the SET, SEARCH, and PERFORM


statements. Data items described by the USAGE IS INDEX clause permit
storage of the values associated with index-names as data in a form
specified by the implementor. Such data items are called index data
items.

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

Each condition- name must be unique .

PROGRAM STRUCTURE

A CIS COBOL program consists of four divisions:

l. IDENTIFICATION DIVISION - An identification of the program.

2. ENVI RONHENT DIVISION - A description of the equipment to be used to


compile and run the program.

3. DATA DIVISION - A description of the data to be processed .

4. PROCEDURE DIVISION - A set of procedures to specify the operat ions t o


be performed on the da ta.

Each division, is divided into sections which are further divided into
paragraphs, which in turn are made up of sentences .

:;;;'· . ,,, _.:.- <:::rx,:::'+- :_ "" _ __,, <v


-i /+!;:::' '?\
Some4 of the. 'red-tape ' statementsi f re<tuit'ed By a s ifrict 'ANsi
are ,optional under CIS COBOL. '·It is possible to ' force
insist on a strict ANSI interpre.tation by using ' the "FLAG" direc tive.
the remainder of this Chapter these statements are marked f +• Elsewhere
this manual a reference is made to the ANSI switch when this applies.

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

' - -' GENERAL DE:SOUPTION

The Ider.tification Division must be included in every ANSI COBOL source


program, This division identifies both the source program and the resultant
output listing. In addition, the user may include the date the program is
written, the date the compilation of the source program is accomplished and
such other information as desired under the paragraphs in the general format
shown b.~low.

ORGANISATIO~

Paragraph headers identify the type of information contained in the


paragraph. The name of the program must be given in the first paragraph,
which is the PROCRAM-ID paragraph. The other paragraphs are optional and
may be included in this division at the user's choice, in order of
presentation shown by the format below.

STRUCTURt:

The following is the general format of the paragraphs in the


Identification Division and it defines the order of presentation in the
source program.

General tormat

fiDE:NTIFlCATION DIVISION.t

tPROGRAN-10. program-name.t

[~· [comment-entry) ... ]

[INSTALLATION. [comment-entry) ... ]


[ DATE-I.RITTEN. [comment-entry] ... ]
[ DATE-CCMPILED. [comment-entry] ... ]
[ S E:CUR ITY. [comment-entry) ... ]

51
ENVIRONMENT DIVISION

GENERAL DESCRIPTION

The Environment Division specifies a standard method of expressing


those aspects of a data processing problem that are dependent upon the
physical characteristics of a specific computer. This division allows
specification of the configuration of the compiling computer and the object
computer. In addition, information relating to input-output control,
special hardware characteristics and control techniques can be given.

The Environment Division must be included in every COBOL source


program.

ORGANIZATION

Two sections make up the Environment ~ivision: the Configuration


Section and the Input-Output Section.

The Configuration Section deals with the characteristics of the source


computer and the object computer. This section is divided into three
paragraphs: the SOURCE-COMPUTER paragraph, which describes the computer
configuration on which the source program is compiled; the OBJECT-COMPUTER
paragraph, which describes the computer configuration on which the object
program produced by the compiler is to be run; and the SPECIAL-NAMES
paragraph, which relates the implementation-names used by the compiler to
the mnemonic-names used in the source program.

The Input-Output Section deals with the information needed to control


transmission and handling of data between external media and the object
program. This section is divided into two paragraphs: the FILE-CONTROL para
graph which names and associates the files with external media; and the
I-0-CONTROL paragraph which defines special control techniques to be used in
the object program.

STRUCTURE

The following is the general format of the sections and paragraphs in


the Environment Division, and defines the order of presentation in the
source program.

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:

1. That which is contained in files and enters or leaves the internal


memory of the computer from a specified area or areas.

2. That which is developed internally and placed into intermediate or


working storage, or placed into specific format for output reporting
purposes.

r 3. Constants which are defined by the user.

PHYSICAL AND LOGICAL ASPECTS OF DATA DESCRIPTION

Data Division Organization

The DATA DIVISION which is one of the required divisions in a program,


is subdivided into sections. These are the File, Working-Storage and
Linkage sections.

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.

f DATA DIVIS ION. f

[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

The Procedure Division must be included in every COBOL source program.


This division may contain declarative procedures.

Declaratives

Declarative sections must be grouped at the beginning of the Procedure


Division preceded by the key word DECLARATIVES and followed by the key words
END DECLARATIVES. (See descriptions of the USE statement in Chapters 5, 6
and 7 and the Debug Chapter 10).

Procedures

A pro;.~,'~"'"""'»'~'~4 .. ~s>~~~.;,~~ ~,}',.~~~~0.f>p,:,~(- or group . of successive


paragraphs ~~! £fx:se; J,ar~~ll!.t:~~~Jt~~!(~ , or a sect~on, or a group
of successive sections within the Procedure Division . If one paragraph is in
a section, then all paragraphs must be in sections . A procedure-name is a
word used to refer to a paragraph or section in the source program in which
it occurs . It consists of a paragraph-name (which may be qualified), or a
section-name.

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.

A section consists of a section header followed by zero, one, or more


successive paragraphs. A section ends immediately before the next section
or at the end of the Procedure Division or, in the declaratives portion of
the Procedure Division, at the key words END DECLARATIVES .

A paragraph consists of a paragraph-name followed by a period and a


space and by zero, one, or more successiv e sentences. A paragraph ends
immediately before the next paragraph-name or section-name or at the end of
the Procedure Division or, in the declaratives portion of the Procedure
Division, at the key words END DECLARATIVES.

A sentence c onsists of one or mor e s t a tements and is terminated by a


period followed by a space.

A statement is a syntactically valid combination of words and symbols


beginning with a COBOL verb.

The term 'identifier' is defined as the word or words necessary to make


unique reference to a data item.

55
Execution

Execution begins with the first statement of the Procedure Division,


excluding declaratives . Statements are then executed in the order in which
they are presented for compilation, except where the rules indicate some
other order .

General Format

Procedure Division Header

The Procedure Division is identified by and must begin with the


following header:

PROCEDURE DIVISION (USING data-name-! [, data-name-2) ... ]


Procedure Division Body

The body of the Procedure Division must conform to one of the following
formats:

Format 1:

[DECLARATIVE$.

) section-name SECTION [segment-number). declarative-sentence

[paragraph-name. [sentence] .. • ] ! ...


END DECLARATIVE$.]

){section-name SECTION [segment-number]}. ....


I

J ... !
[£paragraph-name-}

Format 2 :

)£paragraph-name.}
[sentence]

[sentence]
.• .

... ! ...
..,
STATEMENTS AND SENTENCES

There are three types of statements:

1. Conditional statements,
2. Compiler directing statements ,
3. Imperative statements.

There are three types of sentences:

l. Conditional sentences,
2. Compiler directing sentences,
3. Imperative sentences.

56
Conditional Statement

A conditional statement specifies that the truth value of a condition


is to be determined and that the subsequent action of the object program is
dependent on this truth value.

A conditional statement is one of the following:

* An IF statement.

* A READ statement that specifies the AT END or INVALID KEY phrase.

* A WRITE statement that specifies the INVALID KEY phrase

* A START, REWRITE or DELETE statement that specifies the INVALID


KEY phrase.

* Ar. arithmetic statement (ADD, DIVIDE, MULTIPLY, SUBTRACT) that


specifies the SIZE ERROR phrase.

* A CALL statement that specifies the ON OVERFLOW phrase.

Conditional Sentence

A conditional sentence is a conditional statement, optionally preceded


by an imperative statement, terminated by a period followed by a space.

Compiler Directing Statement

A compiler directing statement consists of a compiler directing verb


and its operands. The compiler directing verbs are COPY, ENTER and USE (see
THE COPY STATEMENT in Chapter 9, THE ENTER STATEMENT in Chapter 3, and THE
USE STATEMENT in Chapters 5, 6 and 7). A compiler directing statement
causes the compiler to take a specified action during compilation.

Compiler Directing Sentence

A compiler directing sentence ts a single compiler directing statement


terminated by a period followed by a space.

57
Imperative Statement

An· ~sperative statement indicates a specific unconditional action to be


taken by the object program. An imperative statement is any stat~mPnt that
is neither a conditional statement, nor a compiler directing statement. An
imperative statement may consist of a sequence of imperative statements,
each possibly separated from the next by a separator.

The imperative verbs are:

ACCEPT GO SET

ADD
1
INSPECT START
2

ALTER !llVE STOP


3 1 1
CALL HIJLTIPLY SUBTRACT

CANCEL OPEN WRITE S

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.
-
;

When 'imperative-statement 1 appears in the general format of


statements, 'imperative-statement' refers to that sequence of consecutive
imperative statements that m1111t be ended by a period or an ELSE phrase
associated with a previous IF statement.

Imperative Sentence

An imperative sentence is an imperative statement terminated by a


period followed by a space.

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.

The divisions of a source program must be ordered as follows: the


Identification Division, then the Environment Divisi<·n, then the Data
Division, then the Procedure Division. Each division must be written
according to the rules for the reference format.

REFERENCE FORMAT REPRESENTATION


The reference format for a line is represented as in Figure 2-1.
I I
MargiJ Margin Margin Margi~
c A B R

_:l ~ ~1 ~
3 _4_ _ s__

Sequence Number Area


---------
+
1a I 9

Area A
3

Area B

Indicator Area

Margin L is immediately to the left of the leftmost character position


of a line.

Margin C is between the 6th and 7th character positions of a line.

Margin A is between the 7th and 8th character positions of a line.

Margin 8 is between the 11th and 12th character positions of a line.

Margin R is ~mmediately to the right of the rightmost character


position of a line.

The sequence number area occupies six character positions (1-6), and is
between Margin L and Margin C.

The indicator area is the 7th character position of a line.

Area A occupies character positions 8, 9, 10 and 11, and is lie tween


margin A and margin 8.

~ Area 8 occupies character positions 12 through 72 inclusive; it begins


immediately to the right of Margin 8 and terminates immediately to the left
of Margin R.

~ Figure 2-1. Reference Format for a COBOL Source Line.

r 59

r
Sequence Numbers

A sequence number, consisting of six digits in the sequence area, may


be used to label a source program line.

Continuation of Lines

Whenever a sentence, entry, phrase, or clause requires more than one


line, it may be continued by starting subsequent line(s) in area B. These
subsequent lines are called the continuation line(s). The line being
continued is called the continued line. Any word or literal may be broken
in such a way that part of it appears on a continuation line.

A hyphen in the indicator area of a line indicates that the first


nonblank character in area B of the current line is the successor of the
last nonblank character of the preceding line without any intervening space.
However, if the continued line contains a nonnumeric literal without closing
quotation mark, the first nonblank character in area B on the continuation
line must be a quotation mark, and the continuation starts with the
character immediately after that quotation mark. All spaces at the end of
the continued line are considered part of the literal. Area A of a
continuation line must be blank.

If there is no hyphen in the indicator area of a line, it is assumed


that the last character in the preceding line is followed by a space.

Blank Lines

A blank line is one that is blank from margin C to margin R, inclusive.


A blank line can appear anywhere in the source program, except immediately
preceding a continuation line. (See Figure 2-1).

DIVISION, SECTION, PARAGRAPH FORMATS

Division Header

The division header must start in area A. (See Figure 2-1).

Section Header

The section header must start in area A. (See Figure 2-1).

A section consists of paragraphs in the Environment and Procedure


Divisions and Data Division entries in the Data Division.

Paragraph Header, Paragraph-Name and Paragraph

A paragraph consists of a paragraph-name followed by a period and a


space and by zero, one or more sentences, or a paragraph header followed by
one or more entries. Comment entries may be included within a paragraph.
The paragraph header or paragraph-name starts in area A of any line
following the first line of a division or a section.

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.

DATA DIVISION ENTRIES

Each Data Division entry begins with a level indicator or a


level-number, followed by a space, follo~ed by its associated name (except
in the Report Section), followed by a sequence of independent descriptive
clauses. Each clause, except the last clause of an entry, may be terminated
by either the separator semicolon or the separator comma. The last clause
is always terminated by a period followed by a space.

There are two types of Data Division entries: those which begin with a
level indicator and those which begin wiL:. a level-number.

A level indicator is the indicator: FD (see THE FILE DESCRIPTION


-COMPLETE ENTRY SKELETON in Chapters 5, 6 and 7)

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.

In those data description entries that begin with level-number 01 or


77, the level-number begins in area A followed by a space and followed in
area B by its associated record-name or item-name and appropriate
descriptive information.

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.

When level-numbers are to be indented, each new level-number may begin


any number of spaces to tile right of margin A. The extent of indentation to
the right is determined only by the width of the physical medium.

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

A comment line is any line with an asterisk in the continuation


indicator area of the line. A comment line can appear as any line in a
source program after the Identification Division header. Any combination of
characters from the computer's character set may be included in area A and
area B of that line (see Figure 2-1). The asterisk and the characters in
area A and area B will be produced on the listing but serve as documentation
only. A special form of comment line represented by a stroke in the
indicator area of the line causes page ejection prior to printing the
comment.

Successive comment lines are allowed. Continuation of comment lines is


permitted, except that each continuation line must contain an '*' in the
indicator area.

RESERVED WORDS

A full list of reserved words is given in Appendix A.

62
r

CHAPTER 3

THE NUCLEUS

FUNCTION OF THE NUCLEUS

The Nucleus provides a basic language capability for the internal


processing of data within the basic structure of the four divisions of a
program.

IDENTIFICATION DIVISION IN THE NUCLEUS

GENERAL DESCRIPTION

The Identification Division must be included in every COBOL source


program. This division identifies the source progr.am and the re!iultant
output listing. In addition, the user may include the date the program is
written and such other information as desired under the paragraphs in the
general format =~own below.

ORGANIZATION

Paragraph headers identify the type of information contained in the


paragraph. The name of the program must be given in the first paragraph,
which is the PROGRAM-ID paragraph. The other paragraphs are optional and
may be included in this division at the user's choice, in the order of
presentation shown by the general format below.

Structure

The general format of the paragraphs in the Identification Division is


given below and shows the order of presentation in the source program.

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

1. The Identification Division must begin with the reserved words


IDENTIFICATION DIVISION followed by a period and a space.

2. The comment-entry may be any combination of the characters from the


computer's character set and may be written in area S on one or more
lines. The continuation of the comment-entry by the use of the hyphen
in the indicator area is not permitted.

THE PROGRAH-ID PARAGRAPH

The PROGRAH-ID paragraph gives the name by which a program is


identified.

General Format

PR0GRAH-ID. program-name.

Syntax Rules

1. The program-name must conform to the rules for formation of a


user-defined word •

General Rules

l. The PROGRAH-ID paragraph must contain the name of the program and must
be present -in every program ·~~~1tr
·i1Jfi

2. The program-name identifies the source program and all listings


pertaining to a particular program.

THE DATE-COMPILED PARAGRAPH

Function

The DATE-COMPILED paragraph provides the compilation date in the


Identification Division source program listing.

General Format

DATE-COMPILED. comment-entry

Syntax Rule

The comment-entry may be any combination of the characters from the


computer's character set. The continuation of the comment entry by use of
the hyphen is not permitted; however, the comment entry may be contained on
one or more lines.

64
General Rule

The paragraph- name DATE- COMPILED causes a date s tring to be inserted


during program compilation. If a DATE-COMPILED the
comment - entry is replaced in its entire t y by the
COBOL Ope rating ;i"Guide for details ot the de
re.placement st;;Y:gf for your implemenl;!Eio;: ~£

ENVIRONMENT DIVISION IN THE NUCLEUS

CONFIGURATION SECTION

The SOURCE- COHPUTER Paragraph

Function

The SOURCE - COMPUTER paragraph identifies th e computer upon which the


orogram is to be compiled.

General Forma t

SOURCE - COMPUTER. computer- name .

Syntax Rule

Computer- name must be one COBOL word defined by the us er.

General Rules

The computer - name provides a means fo r identifying equipment


configuration, in which case the computer- name and its implied configuration
are specified by the user. The SOURCE-COHPUTER paragraph is treated for;;; as '
docume~ta tion purposes only.

The OBJECT- Cm!PUTER Paragraph

Function

The OBJECT- COMPUTER Paragraph identifies the compu te r on which the


program is to be executed .

65
General Format
~]
OBJECT-COMPUTER. computer-name [ MEMORY SIZE integer

[,PROGRAM COLLATING SEQUENCE IS alphabet-name)


l
WORDS
CHARACTERS
MODULES

[,SEGMENT-LIMIT Ji segment-number)

Syntax Rules

1. Computer-name must be one COBOL word defined by the user.

2. Segment-number must be an integer in the range 1 through 49.

General Rules

l. The computer-name provides a means for identifying equipment


configuration, in which case the computer-name and its implied
configurations are specified by the user. The configuration definition
contains information the size.

2. If the PROGRAM COL):..ATING SEQUENCE Clause is specified, the collating


sequence associated with alphabet-name is used to determine the truth
value of any nonnumeric comparisons:

Explicitly ·specified i~ relation conditions (see Relation Condition


later in this Chapter).

3. If the PROG.RAM COLLATING SEQUENCE Clause is not specified, the native


collating sequence is used. Appendix B lists the full ASCII collating
sequence (native) and those characters used in COBOL

4. If the PROGRAM COLLATING SEQUENCE Clause is specified, the program


collating sequence is the collating sequence associated with the
alphabet-name specified in that Clause.

5. The PROGRAM COLLATING SEQUENCE Clause is also applied to any nonnumeric


merge or sort keys.

66
The SPECIAL- NAMES Paragraph

Func tion

The SPECIAL-NAMES paragraph provides a means of rela ting


implementor - name s to user-specified mnemonic-names and of relating
alphabe t-names t o character sets and/or co llating sequences.

General Format

SPECIAL- NAMES.

SWITCH mnemonic-name] ,ON STATUS IS condition- name - !


~OFF STATUS ~ condition- name - 2]
,OFF STATUS IS condition- name- 2
~ON STATUs-Is condition- name-!]

I· SYSIN l IS
[ /. SYSOUT ~
,TAB IS mnemonic - name]

[. alphabet-name IS
STANDARD-!}]
{ NATIVE

[, CURRENCY SIGN~ literal-9]

Genera l Ru l es

1. The status of the switch is specified by condition- names and


interrogated by testing the condition- names (see Switch- Sta t us
Condition later i n this Chapter).

2. The alphabet - name clause provides a means for relating a name to a


specified character code set and/ or colla ting sequence. When
alphabet - name is referenced in the PROGRAH COLLATING SEQUENCE clause
(see THE OBJECT-COMPUTER PARAGRAPH in this Chapter). The alphabet -name

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.

a. If the STANDARD-! phrase is specified, the character code set or


collating sequence identified is that defined in American National
Standard Code for Information Interchange, X3.4-1968 . Appendix B
defines the correspondence between the characters of the standard
character set and the characters of the native character set.
b. If the NATIVE phrase is specified, the native character code set
or native collating sequence is used. The native collating
sequence is as in ANSI publication X3. 4-1968 (see Appendix B) .

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.

6. The literal which appe a rs in the CURRENCY SIGN IS literal clause is


used in the PICTURE clause to represent the currency symbol. The
li t eral is limited to a single character and must not be one of the
following characters .

* 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

WORKING STORAGE SECTION

The Working-Storage Section is composed of the section header, followed


by data description entries for noncontiguous data items and/or record
description entries. Each Working-Storage Section record name and
noncontiguous item name must be unique.

Noncontiguous Working-Storage

Items and constants in Working-Storage which bear no hierarchical


relationship to one another need not be grouped into records, provided they
do not need to be further subdivided. Instead, they are classified and
defined in a separate data description entry which begins with the special
level-number, 77.

The following data clauses are required in each data descriptions


entry: ~

* 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

Data elements and constants in Working-Storage which bear a definite


hierarchic relationship to one another must be grouped into records
according to the rules for formation of record descriptions. All clauses
which are used in record descriptions in the File Section can be used in
record descriptions in the Working-Storage Section.

Initial Values

The initial value of any item in the Working-Storage Section except an


index data item is specified by using the VALUE clause with the data item.
The initial value of any index data item is unpredictable.

THE DATA DESCRIPTION - COMPLETi ENTRY SKELETON

Function

A data description entry specifies the characteristics of a particular


item of data.

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]

(; BLANK WHEN ZERO]

[; VALUE IS literal]

Syntax Rules

1. The level-number may be any number from 01-49 or 77.

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

BLANK WHEN ZERO

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.

THE DATA-NAME OR FILLER CLAUSE

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

1. In the File, Workhlg-Storage, Communication and Linkage Sections, a


data-name or the key word FILLER must be the first word following the
level-number in each data description entry.

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

The JUSTIFIED clause specifies non-standard positioning of data within


a receiving data item.

General Format

JUSTIFIED} RIGHT
{ JUST

Syntax Rules

1. The JUSTIFIED clause can be specified only at the elementary item


level.

2. JUST is an abbreviation for JUSTIFIED.

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

The level-number shows the hierarchy of data within a logical record.


In addition, it is used to identify entries for working storage items,
linkage items.

General Format

level-number

Syntax Rules

1. A level-number is required as the first element in each data


description entry.

2. Data description entries subordinate to a File Description entry must


have level-numbers with the values 01-49. (See THE FILE DESCRIPTION in
Chapter 5).

3. Data description entries in the Working-Storage Section and Linkage


Section must have level-numbers with the values 01-49.

General Rules

1. The level-number 01 identifies the first entry in each record


description or a report group.

2. The level-number 77 is assigned to identify noncontiguous working


storage data items, noncontiguous linkage data items, and can be used
only as described by Format 1 of the data description skeleton. (See
THE DATA DESCRIPTION- COMPLETE ENTRY SKELETON in this Chapter).

3. Multiple level 01 entries subordinate to any given level indicator,


represent implicit redefinitions of the same area.

74
THE PICTURE CLAUSE

Function

The PICTURE clause describes the general characteristics and editing


requirements of an elementary item.

General Format

{ PICTURE
PIC
} IS character-string

Syntax Rules

1. A PICTURE clause can be specified only at the elementary item level.

2. A character-string consists of certain allowable combinations of


characters in the COBOL character set used as symbols. The allowable
combinations determine the category of the elementary item.

3. The maximum number of characters allowed in the character-string is 30.

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.

5. PIC is an abbreviation for PICTURE

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:

Alphabetic Data Rules

1. Its PICTURE character-string can only contain the symbols 'A', 'B'; and

2. Its contents when represented in standard data format must be any


combination of the twenty-six (26) upper-case letters of the Roman
alphabet and the space from the COBOL character set.

Numeric Data Rules

1. The PICTURE character-string can only contain the symbols 1 9 1 , 'P',


'S', and 'V'. The number of digit positions that can be described by
the PICTURE character-string must range from 1 to 18 inclusive.

2. If unsigned, the data in standard data format must be a combination of


the ArabiC num~ralS I QI t I 11 , I 2I J I JI J I 4I J I 5I J t 6I J I 7I J I 8I J 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).

Alphanumeric Data Rules

I. The PICTURE character-string is restricted to certain combinations of


the symbols 'A', 'X', '9', and the item is treated as if the
character-string contained all X's. A PICTURE character-string which
contains all A's or all 9's does not define an alphanumeric item; and

2. The contents when represented in standard data format can consist of


any characters in the computer's character set.

Alphanumeric Edited Data Rules

l. Its PICTURE character-string is restricted to certain combinations of


the following symbols: 'A', 'X', '9', 'B', '0', and'/' as follows:

a. The character-strinc must contain at least one 'B' and at least


one 'X' or at least one 'O' (zero) and at least one 'X' or at
least one '/' (stroke) and at least one 'X'; or

b. The character-string must contain at least one 'O' (zero) and at


least one 'A' or at least one 'I' (stroke) and at least one 'A'.

2. The contents when represented in standard data format are allowable


characters in the computer's set.

Numeric Edited Data Rules

I. Its PICTURE character-string is restricted to certain combinations of


the symbols 'B', '/', 'P', 'V', 'Z', '0', '9', ',', '.', '*', '+', '-',
'CR', 'DB', and the currency symbol. The allowable combinations are
determined from the order of precedence of symbols and the editing
rules as follows:

a. The number of digit positions that can be represented in the


PICTURE character-string must range from I to 18 inclusive.

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.

Elementary Item Size

The size of an elementary item, where size means the number of


character positions occupied by· the elementary item in standard data format,
is determined by the number of allowable symbols that represent character

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

The functions of the symbols used to describe an elementary item are


explained as follows:

A- Each 'A' in the character-string represents a character position which


can contain only a letter of the alphabet or a space.

B- Each 'B' in the character-string represents a character position into


which the space character will be inserted.

P - Each 'P' indicates an assumed decimal scaling position and is used to


specify the location of an assumed decimal point when the point is not
within the numbe= that appears in the data item. The scaling position
character 'P' is not counted in the size of the data item. Scaling
position charactElrs are counted in determining the maximum number of
digit positions (18) in numeric edited items or numeric items. The
r-
1
scaling position character 'P' can appear only to the left or right as
a continuous string of 'P' s within a PICTURE description; since the
scaling position :haracter 'P' implies an assumed decimal point (to the
left of 'P's if 'P's are leftmost PICTURE characters and to the right
if 'P's are rightmost PICTURE characters), the assumed decimal point
symbol 'V' is redundant as either the leftmost or rightmost character
within such a PICTURE description. The character 'P' and the insertion
character ' ' (period) cannot both occur in the sal!le PICTURE
character-string. If, in any operation involving conversion of data
from one form of internal representation to another, the data item
being converted is described with the PICTURE character 'P', each digit
position described by a 'P' is considered to contain the value zero,
and the size of the data item is considered to include the d.igit
positions so described.

S - The letter 'S' is used in a character-string to indicate the presence,


but neither the representation nor, necessarily, the position of an
operational sign; it must be written as the leftmost character in the
PICTURE. The •s• is not counted in determining the size (in terms of
standard data format characters) of the elementary item unless the
entry is subject to a SIGN clause which specifies the optional_ SEPARATE
CHARACTER phrase. (See the SIGN Clause in this Chapter.)

V- The 'V' is used in a character-string to indicate the location of the


assumed decimal point and may only appear once in a character-string.
The 'V' does not represent a character position and therefore is not
counted in the size of the elementary item. When the assumed decimal
point is to the right of the rightmost symbol in the string the 'V' is
redundant.

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.

Z - Each 'Z' in a character-string may only be used to represent the


leftmost num~ric character positions which will be replaced by a space
character when the contents of that character position is zero. Each
'Z' is counted in the size of the item.

9 - Each '9' in the character-string represents a character position which


contains a numeral and is counted in the size of the item.

0 - Each 'O' (zero) in the character-s~ring represents a character position


into which the numeral zero will be inserted. The '0' is counted in
the size of the item.

I - Each '/' (stroke) in the character-string represents a character


position into which the stroke character will be inserted. The '/' is
counted in the size of the item.

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.

The character'.' (period) in the character-string is an editing symbol


which represents the decimal point for alignment purposes and in
addition, represents a character position into which the character ' '
will be inserted. The character ' • ' is counted in the size of the
item. For a given program the functions of the period and comma are
exchanged if the clause DECIMAL-POINT IS COMMA is stated in the
SPECIAL-NAMES paragraph. In this exchange the rules for the period
apply to the comma and the rules for the comma apply to the period
wherever they appear in a PICTURE clause. The insertion character ' . '
must not be the 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.

* - Each '*' (asterisk) in the character-string represents a leading


numeric character position into which an asterisk will be placed when
the contents of that position is zero. Each '*' is counted in the size
of the item.

cs - The currency symbol in the character-string represents a character


position into which a currency symbol is to be placed. The currency
symbol in a character-string is represented by either the currency sign
or by the single character specified in the CURRENCY SIGN clause in the
SPECIAL-NAMES paragraph. The currency symbol is counted in the size of
the item.

78
Editing Rules

There are two general methods of performing editing in the PICTURE


clause, either by insertion or by suppression and replacement. There are
four ty~e~ of insertion editing available . They are:
* Simple insertion
* Special insertion
* Fixed insertion
* Floating insertion
There are two types of suppression and replacement edit<.ng:

* Zero suppression and replacement with spaces


• Zero suppression and replacement with asterisks

The type of editing which may be performed upon an item is dependent


upon the category to which the item belongs. Table 3-1 specifies which type
of editing may be performed upon a given category.

Table 3-1. Editing Types for Data Categories

CATEGORY TYPE OF EDITING

Alphabetic Simple insertion 'B' only


Numeric None
Alphanumeric None
Alphanumeric Edited Simple inser t ion 'O', 'B' and 'I'
Numeric Edited All,_ but see NOTE below

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

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.

Special Insertion Editing

Special Insertion Editing. The '.' (period) is used as the insertion


character. In addition to being an insertion character it also represents
the decimal point for -alignment purposes. The insertion character used for
the actual decimal point is counted in the size of the item . The use of the
assumed decimal point, represented by the symbol 'V' and the actual decimal
point, represented by the insertion character, in the same PICTURE

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

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

Table 3-2 Editing Symbols in PICTURE Character-Strings

RESULT
EDITING SYMBOL IN
PICTURE CHARACTER-STRING DATA ITEM DATA ITEM
POSITIVE OR ZERO NEGATIVE

+ + -
- space -
CR 2 spaces CR
DB 2 spaces DB

Floating Insertion Editing

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.

Floating insertion editing is indicated in a PICTURE character-string


by using a string of at least two of the floating insertion characters.
This string of floating insertion characters may contain any of the fixed
insertion symbols or have fixed insertion characters immediately to the
right of this string. These simple insertion characters are part of the
floating string.

The leftmost character of the floating insertion string represents the


leftmost limit of the floating symbol in the data item. The rightmost
character of the floating string represents the rightmost limit of the
floating symbols in the data item.

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.

If all numeric character positions in the PICTURE character-string are


represented by the insertion character, the result depends upon the value of
the data. If the value is zero the entire data item will contain spaces.
If the value is not zero, the result is the same as when the insertion
character is only to the left of the decimal point.

To avoid truncation, the minimum size of the PICTURE character-string


for the receiving data item must be the number of characters in the sending
data item, plus the number of non-floating insertion characters being edited
into the receiving data item, plus one for the floating insertion character.

Zero Suppression Editing

The suppression of leading zeros in numeric character positions is


indicated by the use of the alphabetic character 'Z' or the character '*'
(asterisk) as suppression symbols in a PICTURE character-string. These
symbols are mutually exclusive in a given PICTURE character-string. Each
suppression symbol is counted in determining the size of the item. If 'Z'
is used, the replacement character will be the space and if the asterisk is
used, the replacement character will be '*'·

Zero suppression and replacement is indicated in a PICTURE


character-string by using a string of one or more of the allowable symbols
to represent leading numeric character positions which are to be replaced
when the associated character position in the data contains a zero. Any of
the simple insertion characters embedded in the string of symbols or to the
immediate right of this string are part of the string.

In a PICTURE character-string, there are only two ways of representing


zero suppression. One way is to represent any or all of the leading numeric
character positions to the left of the decimal point by suppression symbols.
The other.way is to represent all of the numeric character positions in the
PICTURE character-string by suppression symbols.

If the suppression symbols appear only to the left of the decimal


point, any leading zero in the data which corresponds to a symbol in the
string is replaced by the replacement character. Suppression terminates at

81
the first non-zero digit in the data represented by the suppression symbo;
string or at the decimal point, whichever is encountered first.

If all numeric character positions in the PICTURE character-string are


represented by suppression symbols and the value of the data is not zero,
the result is the same as if the suppression characters were only to the
left of the decimal point. If the value is zero and the suppression symbol
is 'Z', the entire data item will be spaces. If the value is zero and the
suppression symbol is '*', the data item will be all '*' except for the
actual decimal point.

The symbols '+', '-', '*' 'Z', and the currency symbol, when used as
floet~ng replacement characters, are mutuallv exrJusive within a given
character-string.

Precedence Rules

Table 3-3 shows the order of precedence when using characters as


symbols in a character-string. An 'X' at an intersection indicates that the
symbol(s) at the top of the column may precede, in a given character-string,
the symbol(s) at the left of the row. Arguments appearing in braces
indicate that the symbols are mutually exclusive. The currency symbol is
indicated by the · symbol 'cs'.

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.

Table 3-3. PICTURE Character Precedence Chart.

~~ . .
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

The REDEFINES clause allows the same computer storage 2.rP.a to be


described by different data description entries.

General Format

level-number data-name-1; REDEFINES data-name-2

NOTE: Level-number, data-name-1 are shown in the above format to improve


clarity. Level-number and data-name-1 are not part of the
KEDEF1NES clause.

Syntax Rules

l. The REDEFINES clause, when specified, must immediately follow


data-name-1.

2. The level-numbers of data-name-1 and data-name-2 must be identical.

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).

4. This clause must not be used in level 01 entries in the Communication


Section.

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).

6. No entry having a level-number numerically lower than the level-number


of data-name-2 and data-name-1 may occur between the data description
entries of data-name-2 and data-name-1.

General Rules

l. Redefinition starts at data-name-2 and ends when a level-number less


than or equal to th~. t of data-name-2 is encountered.

2. When the level-number of data-name-1 is other than 01, it must specify


the same number of character positions that the data item referenced by
data-name-2 contains. It is important to observe that the REDEFINES
clause specifies the redefinition of a storage area, not of the data
items occupying the area.

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.

5. Multiple level 01 entries subordinate to any given level inJicator


represent implicit redefinitions of the same area.

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.

4. If the CODE-SET clause is specified, any signed numeric data


description entries associated with that file description entry must be
described with the SIGN IS SEPARATE clause.

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.

2. A numeric data description entry whose picture contains the character


1 1
S , but to which no optional SIGN clause applies, has an operational
sign, but neither the representation nor, necessarily, the position of
the operational sign is specified by the character 1 S 1 • In this
(default) case, general rules 3 through 5 do not apply to such signed
numeric data items. The representation of the default operational sign
is defined in Chapter 2, Selection of Character Representation and
Radix.

87
3. If the optional SEPARATE CHARACTER phrase is not present, then:

a. The operational sign will b.; presumed to be associated with the


leading (or, respectively, trailing) digit position of the
elementary numeric data item.

b. The letter 1 5 1 in a PICTURE character-string is not counted in


determining the size of the item (in terms of standard data format
characters).

4. If the optional SEPARATE CHARACTER phrase is pr~sent, then:

a. The operational sign will be presumed to be the leading (or,


respectively, trailing) character pos1t1on of the elementary
numeric data item; this character position is not a digit
position.

b. The letter 1 5 1 in a PICTURE character-string is counted in


determining the size of the item (in terms of standard data format
characters).

c. The operational signs for positive and negative are the standard
data format characters 1 + 1 and 1 - 1 , respectively.

5. Every numeric data description entry whose PICTURE contains the


character 1 S 1 is a signed numeric data description entry. If a SIGN
clause applies to such an entry and conversion is necessary for
purposes of computation or comparisons, conversion takes place
automatically.

88

-r
I
THE SYNCHRONIZED CLAUSE

Function

The SYNCHRONIZED clause specifies the alignment of an elementary item


on the natural boundaries of the computer memory.

General Format

SYNCHRONIZED} [{LEFT }]
{ SYNC RIGHT

Syntax Rules

1. This clause may only appear with an elementary item.

2. SYNC is an abbreviation for SYNCHRONIZED.

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:

a. The size of any group item(s) to which the elementary item


belongs; and

b. The character positions redefined when this data item is the


object of a REDEFINES clause.

3. SYNCHRONIZED not followed by either RIGHT or LEFT specifies that the


elementary item is to be positioned between natural boundaries in such
a way as to effect efficient utilization of the elementary data item.

4. SYNCHRONIZED LEFT specifies that the elementary item is to be


positioned such that it will begin at the left character position of
the natural boundary in which the elementary item is placed.

5. SYNCHRONIZED RIGHT specifies that the elementary item is to be


positioned such that it will terminate on the right character position
of the natural boundary i.n which the elementary item is placed.

&. Whenever a SYNCHRONIZED item is referenced in the source program, the


original size of the item, as shown in the PICTURE clause, is used in
determining any action that depends on size, such as justification,
truncation or overflow.

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.

8. When the SYNCHRONIZED clause is &p~cified in a data description entry


of a data item that also contains an OCCURS clause, or in a data
description entry of a data item subordinate to a data description
entry that cont2ins an OCCURS clause, then:

a. Each occurrence of the data item is SYNCHRONIZED.

b. Any implicit FILLER generated for other data items within that
same taole are generated tor each occurrence of those data items.

9. This clause is hardware dependent.

90
[lfiiiill
I

THE USAGE CLAUSE

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

l. The PICTURE character-string of a COMPUTATIONAL or COMPUTATIONAL-3 item


can contain only '9's, the operational sign character 'S', the implied
decimal point character '7', one or more 'P's. (See THE PICTURE CLAUSE
earlier in this Chapter).

2. COMP is an abbreviation for COMPUTATIONAL.

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.

2. This clause specifies the manner in which a data item is represented in


the storage of a computer. It does not affect the use of the data
item, although the specifications for some statements in the Procedure
Division may restrict the USAGE clause of the operands referred to.
The USAGE clause may affect the radix or type of character
representation of the item.

3. A COMPUTATIONAL or COMPUTATIONAL-3 item is capable of representing a


value to be used in computations and must be numeric . If a group item
is described as COMPUTATIONAL(-3), the elementary items in the group
are COMPUTATIONAL(-3). The group item itself is not COMPUTATIONAL(-3)
and cannot be us ed in computations.

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).

2. A signed numeric literal must have associated with it a signed numeric


PICTURE character-string.

3. All numeric literal in a VALUE clause of an item must have a value


which is within the range of values indicated by the PICTURE clause,
and must not have a value which would require truncation of nonzero
digits. Nonnumeric literals in a VALUE clause of an item must not
exceed the size indicated by the PICTURE clause.

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:

a. If the category of the item is numeric, all literals in the VALUE


clause must be numeric. If the literal defines the value of a
working storage item, the literal is aligned in the data item
according to the standard alignment rules. (See Standard
Alignment Rules in Chapter 2).

b. If the category of the item is alphabetic, alphanumeric,


alphanumeric edited or numeric edited, all literals in the VALUE
clause must be nonnumeric literals. The literal is aligned in the
data item as if the data item had been described as alphanumeric.
(See STANDARD ALIGNMENT RULES in Chapter 2). Editing characters
in the PICTURE clause are included in determining the size of the
data item (see THE PICTURE CLAUSE earlier in this Chapter) but
have,no effect on initialization of the data item. Therefore, the
VALUE for an edited item is presented in an edited form.

c. Initialization takes place independent of any BLANK WHEN ZERO or


JUSTIFIED clause that may be specified.

92
Data Description Entries

Rules governing the use of the VALUE clause differ with the respective
sections of the Data Division:

1. The VALUe clause cannot be used in the File Section.

2. In the Working-Storage Section, the VALUE clause may be used to specify


the initial value of a data item; in which case the clause causes the
item to assume the specified value at the start of the objer.t program.
If the VALUE clause is not used in an item's description, t~e initial
value is undefined.

3. The VALUE clause cannot be used in the Linkage Section.

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

Ccnditional expressions identify conditions that art, tested to enable


the object program to select between alternate paths of control depending
upon the truth value of the condition. Conditional expressions are
specified in the IF and PERFORM statements. There are two categories of
conditions associated with conditional expressions: simple conditions and
relation conditions. Each may be enclosed within any number of paired
parentheses, in which case its category is not changed.

Simple Conditions

The simple conditions are the relation, cl.iss, switch-status,


conditions. A simple condition has a truth value of 'true' or 'false'. The
inclusion in parentheses of simple conditions does not change the simple
truth value.

Rel~tion Condition

A relation condition causes a comparison of two operands, each of which


may be the data item referenced by an identifier, a literal. ·A relation
condition has a truth value of 'true' if the relation exists between the
operands. Comparison of two numeric operands is permitted regardless of the
formats specified in their respective USAGE clauses. However, for all other
comparisons the operands must have the same usage. If either of the
operands is a group item, the nonnumeric comparison rules apply.

The general format of a relation condition is as follows:

IS [NOT) GREATER THAN


IS [NOT) LESS THAN
j identifier-!! [NOT) EQUAL TO
literal-!
IS
IS [NOT) > l identifier-2
literal-2
1
I
IS [NOT) <
IS [NOT]

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)

The first operand (identifier-! or literal-!) is called the subject of


the condition; the second operand (identifier-2 or literal-2) is called the
object of the condition. The relation condition must contain at least one
reference to a variable.

The relational operator specifies the type of comparison to be made in


a relation condition. a space must precede and follow each reserved word
comprising the relational operator. When used, 'NOT' and the next key word
or relation character are one relational operator that defines the
comparison to be executed for truth value; e.g., 'NOT EQUAL' is a truth test
for an 'unequal'.

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.

Table 3-4 Relational Operators


Meaning Relational Operator
Greater than or not greater than IS !.NO~! GREATER THAN
IS [NOT] >
Less than or not less than IS [NOT] ~ THAN
IS [NOT] <
Equal to or not equal to ts [NOTl EQUAL TO
IS [NOT] ~

The required relational character~ '>'. I (t t and ,;, are not


underlined to avoid confusion with other symbols such as 1)1

(Greater than or equal to). -

Comparison of Numeric Operands: For operands whose class is numeric a


comparison is made with respect to the algebraic value of the operands. The
length of the literal, in terms of number of digits represented, is not
significant. Zero is considered a unique value regardless of the sign.

Comparison of these operands is permitted regardless of the manner in which


their usage is described . Unsigned numeric operands are considered positive
for purposes of comparison.

Comparison of Nonnumeric Operands: For nonnumeric operands, or one numeric


and one nonnumeric operand, a comparison is made with respect to a specified
collating sequence of characters (see The OBJECT-COMPUTER Paragraph in this
Chapter). If one of the operands is specified as numeric, it must be an
integer data item or an integer literal and:

1. If the nonnumeric operand is an elementary data item or a nonnumeric


literal, the numeric operand is treated as though it were moved to an
elementary alphanumeric data item of the same size as the numeric data
item (in terms of standard data format characters), and the contents of
this alphanumeric data item were then compared to the nonnumeric
operand. (See THE MOVE STATEMENT in this Chapter, and the PICTURE
Character 1 P 1 under the heading Symbols Used earlier in this Chapter).

2. If the numeric operand is a group item, the numeric operand is treated


as though it were moved to a group item of the same size as the numeric
data iteur (in terms of standard data format characters), and the
contents of this group item were then compared to the nonnumeric
operand. (See THE MOVE STATEMENT in this Chapter, and the PICTURE
character 1 P 1 under the Heading Symbols Used earlier in this Chapter).

3. A non-integer ru1meric operand cannot be compared to a nonnumeric


operand.

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.

There are two cases to consider:

1. Operands of equal size - If the operands are of equal size, comparison


effectively proceeds by comparing ~haracters in corresponding character
positions starting from the high order end and continuing until either
a pair of unequal characters is encountered or the low order end of the
operand is reached, whichever comes first. The operands are determined
to be equal if all pairs of characters compare equally through the last
pair, when th!! lo>! order end is reached.

The first encountered pair of unequal characters is compared to deter-


mine their relative position in the collating sequence. The operand
that contains the character that is positioned higher in the collating
sequence is considered to be the greater operand.

2. Operands of unequal size - If the operands are of unequal size,


comparison proceeds as though the shorter operand were extended on the
right by sufficient spaces to make the operands of equal size.

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:

identifier IS [NOT] {~TIC }

The usage of the operand being tested must be described as display.


When used, 'NOT' and the next key word specify one class condition that
defines the class test to be executed for truth value; e.g. 'NOT NUMERIC'
is a truth test for determining that an operand is nonnumeric.

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

A switch-status condition determines the 'on' or 'off' status of an


implementor-defined switch. The implementor-name and the 'on' or 'off'
value associated with the condition must be named in the SPECIAL-NAMES
paragraph of the Environment Division. The general format for the
switch-status condition is as follows:

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

In the statement descriptions that follow, several phrases appear


frequently : the ROUNDED phrase, the SIZE ERROR phrase.

These are described below. A resultant-identifier is that identifier


associated with a result of an arithmetic operation.

The Rounded Phrase

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.

When the low-order integer positions in a resultant-identifier are


represented by the character 'P' in the PICTURE for the
resultant-identifier, rounding or truncation occurs relative to the
rightmost integer position for which storage is allocated.

The Size Error Phrase

If, after decimal point alignment, the absolute value of a result


exceeds the largest value that can be contained in the associated fM!IIiiI
resultant-identifier a size error condition exists. Division by zero always
causes a size error condition. The size error condition applies only to the
final results, except in MULTIPLY and DIVIDE statements, in which case the
size error condition applies to the intermediate results as well, If the
ROUNDED phrase is specified rounding takes place before checking for size
error . When such a size error condition occurs, the subsequent action
depends on whether or not the SIZE ERROR phrase is specified as follows:

SIZE ERROR Phrase Not Specified

When a size error condition occurs, the value of those


resultant-identifier(s) affected is undefined. Values of
resultant-identifier(s) for which no size error condition occurs are
unaffected by size errors that occur for other resultant-identifier(s)
during execution of this operation.

SIZE ERROR Phrase Specified

When a size error condition occurs, then the values of


resultant-identifier(s) affected by the size errors are not alte1:ed. After
completion of the execution of this operation, the imperative statement in
the SIZE ERROR phrase is executed.

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.

2. The maximum size of each operand is 18 decimal digits. The composite


of operanc..s, which is a hypothetical data item resulting from the
superimposition of specified operands in a statement aligned on their
decimal pcir..tc (See THE ADD STA.TEXENT, THE CIVIDE :JTATE:·IENT, THE
MULTIPLY STATEMENT and THE SUBTRACT STATEMENT later in this Chapter)
must not contain more than 18 decimal digits.

Overlapping Operands

When a sending and a receiving item in an arithmetic statement or an


INSPECT, MOVE, SET, statement share a part of their storage areas, the
result of the execution of such a statement is undefined.

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

Literal- ! must be numeric.

General Rules

l. Format l the standard ANSI ACCEPT statement


Format 2

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.

3. The line of input is line- edited according to the operating system


rules for line - editing (see Operating Systems User Guide). The line is
terminated by pressing the CR (Carriage Return) key or by exceeding 120
characters in length.

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

ADD li~ent ifier - 1! [,\i~ en ti fier - 2 1] TO identif ier-m ( ROUNDED ]


--- l11t e r a1-1 l1 1tera1- 2 I

[ , identifier- n [ROUNDED] J ... [; ON SIZE ERROR imperative-statement]

103
Format 2

ADD !identifier-11 , )identifier-21 •)identifier-31] •••


--- lliteral-1 literal-2 [ literal-3

GIVING identifier-m [ROUNDED) [, identifier-n [ROUNDED))

[; ON SIZE ERROR imperative-statement)


~
!

Syntax Rules

l. In Formats 1 and 2, each identifier must refer to an elementary numeric


item, except that in Format 2 each identifier following the word GIVING
must refer to either an elementary numeric item or an elementary
numeric edited item.

2. Each literal must be a numeric literal.

3. The composite of operands must not contain more than 18 digits (see The
Arithmetic Statements in this Chapter).

a. In Format 1 the composite of operands is determined by using all


of the operands in a given statement.

b. In Format 2 the composite of operands is determined by using all


of the operands in a given statement excluding the data items that
follow the word GIVING.

General Rul!'.!!.

1. See The Rounded Phrase, The Size Error Phrase, The Arithmetic
Statements, Overlapping Operands and Incompatible Data in this Chapter.

2. If Format 1 is used, the values of the operands preceding the word TO


are added together, then the sum is added to the current value of
identifier-m storing the result immediately into identifier-m.

3. If Format 2 is used, the value of the operands preceding the word


GIVING are added together, then the sum is stored as the new value of
identifier-m, the resultant identifiers.

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

The ALTER statement modifies a predetermined sequence of operations.

General Format

~ procedure-name-! !Q. [PROCEED TO] procedure-name-2

Svnt;,nc RttlP~

1. Procedure-name-! is the name of a paragraph that contains a single


sentence consisting of a GO TO statement without the DEPENDING phrase.

2. Procedure-name-2 is the name of a paragraph or section in the Procedure


Division.

General Rule

Execution of the ALTER statement modifies the GO TO statement in the


paragraph named procedure-name-!, so that subsequent executions of the
modified GO TO statements cause transfer of control to procedure-name-2.
Modified GO TO statements in independent segments may, under some
circumstances, be returned to their initial states (see Independent Segments
in Chapter 8).

105
THE DISPLAY STATEMENT

Function

Th e DISPLAY statement causes data to be transf erred from specified data


items to th e CRT screen .

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.

2. If th e lit era l is numeric, it must be an unsigned integer.

but it

UPON phrases and the default


"""1 ·1'·(i'·;;;;~V"c·c
h"owev'et, be ' changed by
clause so that UPON CRT
iri the syntax
even if the

Fo r ma t 1

2. The DISPLAY statement caus es t he contents of each ope rand to be


transf erred to the CRT in the order listed as one line of output data .

3. The size of the da ta transfer can be up to 132 bytes.

4. If a figu rative constant is specified as one of th e operands, only a


single occurrence of th e figura tive constant is displayed.

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 .

6. If th e CRT is not ca pable of displaying data of th e same size as the


da ta item being transf e rred , one of the following applies .

(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.

7. Wh e n a DISPLAY s t a t eme nt contains more th a n one operand, th e size of


the s e nding it em is th e sum of the sizes associated with the operands ,
and th e values o f th e operands are transf e rr ed in th e sequence in which
the operands a re e ncount e red .

Forma t 2

8. The DISPLAY statement is used to' output 'd ata to the CRT in the screen
positions specified.

9. data-name -1 is taken as a definition of th~ screen area into which data


items that correspond to areas on the screen are moved. FILLER fields
correspond to · areas on the · screen into which data is --not moved.

10. Elementary data items within data-name-1 may be alphanumeric, integer


numeric, numeric or edited .

11. AT data-name,-.2 or l i teral-4 defines the position on the screen of the


leftmost character of the. data. Either form must refer to a PIC 9999
field. The most significant 99 is taken as a line count in the range
one to the maximum number of \}lines on. the user· screen. The least
significant 99 is taken as a character posit:ion in the range one to the
maximum of 'characters per line on .,the ' user l>creen.

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

GIVING identifier-3 [ROUNDED) (,identifier-4 (ROUNDED] ] ...

[;ON SIZE ERROR imperative-statement]

Format 3

identifier-21
lidentifier-11
literal-1 I
BY
lliteral-2 I

identifier-3 (ROUNDED] ( , identifier-4 (ROUNDED] J ...


[;ON SIZE ERROR imperative-statement]

Syntax Rules

1. Each identifier must refer to an elementary numeric item, except that


any identifier associated with the GIVING phrase must refer to either
an elementary numeric item or an elementary numeric edited item.

2. Each literal must be a numeric literal.

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
... __ _ --'

2. When Format is used, the value of identifier-! or literal-1 is


divided into the value of identifier-2. The value of "h" dividend
(identifier-2) is replaced by this quotient.

3. When Format 2 is used, the value of identifier-! or literal-1 is


divided into identifier-2 or literal-2 and the result i s stored in
identifier-3.

4. When Format 3 is used, the value of identifier-! or literal-1 is


d i vided by the value of identifier-2 or literal-2 and the result is
~- stored in ideutifier-3.

~
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

ENTER language-name [routine-name]


J.
Syntax Rule

l.

General Rule

l. Access to other languages can be achieved by means of CALL. J.

110
.,
THE EXIT STATEMENT

Function

The EXIT statement provides a common end point for ~ series of


procedures.

General Format

EXIT

Syntax Rules

1. The EXIT statement must appear in a sentence by itself .

2. The EXIT sentence must be the only sentence in the paragraph.

General Rule

An EXIT statement serves only to enable the user :o assign a


procedure-name to a given point in a program. Such an EXIT statement
has no other effect on the compilation or execution of the program.

111
THE GO TO STATEMENT

Function

The GO TO statement causes control to be transferrer! from one part of


the Procedure Division to another.

General Format

Format 1

c:c !0

Format-2

GO TO procedure-name-! [, procedure-name-2) procedure-name-n

DEPENDING ON identifier

Syntax Rules

1. Identifier is the name of a numeric elementary item described without


any positions to the right of the assumed decimal point.

2. When a paragraph is referenced by an ALTER statement, that paragraph


can consist only of a paragraph header followed by a Format 1 GO TO
statement.

3. If a GO TO statement represented by Format 1 appears in a consecutive


sequence of imperative statements within a sentence, it appears as the
last statement in that sequence.

General Rules

1. When a GO TO statement, represented by Format 1 is executed, control is


transferred to procedure-name-1 or to another procedure-name if the GO
TO stateLlent has been modified by an ALTER statement.

2. When a GO TO statement represented by Format 2 is executed, control is


transferred to procedure-name-1, procedure-name-2, etc., depending on
the value of the identifier being 1, 2, ... , n. If the value of the
identifier is anything other than the positive or unsigned integers 1,
2, ••• , n, then no transfer occ.urs and control passes to the next
statement in the normal sequence :or execution.

112
THE IF STATEMENT

Function

The IF statement causes a condition to be .avaluated (see CONDITIONAL


EXPRESSIONS in this Chapter). The subsequent action of the object program
depends on whether the value of the condition is true or false.

General Format

IF condition; statement-! } J,: ELSE statement-2 }


{ NEXT SENTENCE ) ELSE NEXT SENTENCE.

Syntax Rules

l. Statement-! and statement-2 represent either an imperative statement or


a conditional statement, and either may be followed by a conditional
statement.

2. The ELSE NEXT SENTENCE phrase may be omitted if it immediately precedes


the terminal period of the sentence.

General Rules

1. When an IF statement is executed, the following transfers of control


occur:

a. If the condition is true, statement-! is executed if specified. If


statement-! contains a procedure branching or conditional
statement, control is explicitly transferred in accordance with
the rules of that statement. If statement-! does not contain a
procedure branching or conditional statement, the ELSE phrase, if
specified, is ignored and control passes to the next executable
sen ten~ e.

~ b. If the condition is true and the NEXT SENTENCE phrase is specified


instead of statement-!, the ELSE phrase, if specified, is ignored
and control passes to the next executable sentence.

~ c. If the condition is false, statement-! or its surrogate NEXT


SENTENCE is ignored, and statement-2, if specified, is executed.
If statement-2 contains a procedure branching or conditional
statement, control is explicitly transferred in accordance with

r the rules of that statement . If statement-2 does not contain a


procedure branching or conditional statement, control passes to
the next executable sentence. If the ELSE statement-2 phrase is
not specified, statement-! is ignored and control passes to the
next executable 3entence.
~

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.

2. Statement-1 and/or statement-2 may contain an IF statement. In this


case the IF statement is said to be nested.

IF statements within IF statements may be considered as paired IF and


ELSE combinations, proceeding from left to right. Thus, any ELSE
encountered is considered to apply to the immediately preceding IF that has
not been already pai red with an ELSE.

..,

..,
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

INSPECT identifier-! TALLYING

identifier-2 FOR , \ ~~~ING ~~ identifier-3!


/CHARACTERs! literal-1
BEFORE} INITIAL identifier-71]
[{ AFTER l literal-S I

Format 2

INSPECT identifier-! REPLACING

CHARACTERS BY ~i~entifier-61
- hteral-4 I

.~~~~ING ~ jidentifier-51 BY jidentifier-61


' literal-) I - literal-4 I
\ FIRST

BEFORE} INITIAL identifier-71]


[{ AFTER l literal-S I

Format 3

INSPECT identifier-! TALLYING

identifier- 2 FOR \ LE~~NG jidentifier-3~ [ {BEFORE} INITIAL ~i~entifier-4!]


~CHARACTERS literal-1 AFTER l1tera1-2

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

BEFORE} INITIAL lidentifier-71]


[{ AFTER literal-S I

115
Syntax Rules

All Formats

1. Identifier-! must reference either a group item or any category of


elementary item, described (either implicitly or explicitly) as usage
is DISPLAY.

2. Identifier-3 identifier-n must reference either an elementary


alphabetic, alphanumeric or numeric item described (either implicitly
or explicitly) as usage is DISPLAY.

3. Each literal must be nonnumeric and may be any figurative constant,


except ALL.

4. In Level 1, literal-!, literal-2, literal-3, literal-4, and literal-S,


and the data items referenced by identifier-3, identifier-4,

S.

6.
identifier-S, identifier-6, and identifier-7 must be one character in
length.

Formats 1 and 3 Only


Identifier-2 must reference an elementary numeric data item.

If either literal-! or literal-2 is a figurative constant, the


-I

figurative constant refers to an implicit one character data item.

Formats 2 and 3 Only


7. The size of the data referenced by literal-4 or identifier-6 must be
equal to the size of the data referenced by literal-3 or identifier-S.
When a figurative constant is used as literal-4, the size of the
figurative constant is equal to the size of literal-3 or the size of
the data item referenced by identifier-S.

8. When the CHARACTERS phrase is used, literal-4, literal-S, or the size


of the data item referenced by identifier-6, identifier-7 must be one
character in length.

9. When a figurative constant is used as literal-3, the data referenced by


literal-4 or identifier-6 must be one character in length.

General Rules

All Formats

1. Inspection (which includes the comparison cycle, the establishment of


boundaries for the BEFORE or AFTER phrase, and the mechanism for
tallying and/or replacing) begins at the leftmost character position of
the data item referenced by identifier-!, regardless of its class, and
proceeds from left to right to the rightmost character position as
described in general rules 4 through 6.

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:

a. If an~ of identifier-!, identifier-3, identifier-4, idencifier-S,


identifier-6 or identifier-7 are described as alphanumeric, the
INSPECT statement treats the contents of each such identifier as a
character-string.
b. If any of identifier-!, identifier-3, identifier-4, identifier-S,
identifier-6 or identifier-7 are described as alphanumeric edited,
roumeric edited or unsigned numeric, the data item is in~pected as
though it had been redefined as alphanumeric (see general rule 2a)
and the INSPECT statem~nt had been written to refe~ence the
redetined data item.
c. If any of the identifier-!, identifier-3, identifier-4,
identifier-S, identifier-6 ~r identifier-7 are described as signed
numeric, the data item is inspected as though it had been moved to
an unsigned numeric data item of the same length and then the
rules in general rule 2b had been applied. (See THE MOVE STATEMENT
later in this Chapter).

3. In general rules ~ through 11 all references to literal-!, literal-2,


literal-3, literal-4, and literal-S apply equally to the contents of
the data item referenced by identifier-3, identifier-4, identifier-S,
identifier-6, and identifier-7, respectively.

4. During inspection of the contents of the data item referenced by


identifier-!, each properly matched occurrence of literal-! is tallied
(Formats 1 and 3) and/or each properly matched occurrence of literal-3
is replaced by literal-4 (Formats 2 and 3). Data items to be·
referenced by the INSPECT verb should be placed such that they Lie
within the first 10,000 bytes of intermediate code.

S. The comparison operation to determine the occurrences of literal-! to


be tallied and/or occurrences of literal-3 to be replaced, occurs as
follows:

a. The operands of the TALLYING and REPLACING phrases are considered


in the order they are specified in the INSPECT statement from left
to right . The first literal-!, literal-3 is compared to an equal
number of contiguous characters, starting with the leftmost
character position in the data item referenced by identifier-! .
Literal-!, literal-3 and that portion of the contents of the data
item referenced by identifier-! match if, and only if, they are
equal, character for character.

b. If no match occurs . in the comparison of the first literal-!,


literal-3, the comparison is repeated with each successive
literal-!, literal-3, if any, until either a match is found or
there ls no next successive literal-!, literal-3. When there is

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.

c. Whenever a match occurs, tallying and/or replacing takes place as


described in general rules 8 through 10. The character position
in the data item referenced by identifier-! immediately to the
right of the rightmost character position that participated in the
match is now considered to be the leftmost character position of
the data item referenced by identifier-!, and the comparison cycle
starts again with the first literal-!, literal-3.

d. The comparison operation continues until the rightmost character


position of the data item referenced by identifier-! has
participated in a match or has been considered as the leftmost
character position. When this occurs, inspection is terminated.

e. If the CHARACTERS phrase is specified, an implied one character


operand participates in the cycle described in paragraphs Sa
through Sd above, except that no comparison to the contents of the
data item referenced by identifier-! takes place. This implied
character is considered always to match the leftmost character of
the contents of the data item referenced by identifier-!
participating in the current comparison cycle.

6. The comparison operation defined in general rule 5 is affected by the


BEFORE and AFTER phrases as follows:

a. If the BEFORE or AFTER phrase is not specified, literal-!,


literal-3 or the implied operand of the CHARACTERS phrase
participates in the comparison operation as described in general
rule S.

b. If the BEFORE phrase is specified, the associated literal-!,


literal-3 or the implied operand of the CHARACTERS phrase
participates only in those comparison cycles which involve that
portion of the contents of the data item referenced by
identifier-! from its leftmost character position up to, but not
including, the first occurrence of literal-2, literal-S within the
contents of the data item referenced by identifier-!. The
position of this first occurrence is determined before the first
cycle of the comparison operation described in general rule S is
begun. If, on any comparison cycle, literal-!, literal-3 or the
implied operand of the CHARACTERS phrase is not eligible to
participate, it is considered not to match the contents of the
data item referenced by identifier-!. If there is no occurrence
of literal-2 literal-S within the contents of the data item

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.

c. If the AFTER phrase is specified, the associated literal-1,


literal-3 or the implied operand of the CHARACTERS phrase may
participate only in those comparison cycles which involve that
portion of the contents of the data item referenced by
identifier-1 from the character position immediately to the right
of the rightmost character position of the first occurrence of
literal-2, literal-S within the contents of .the data item
referenced by identifier-1 and the rightmost character position
of the data item referenced by identifier-1. The position of this
first occurrence is determined before the first cycle of the
comparison operation described in general rule S is begun. If, on
any comparison cycle, literal-1, literal-3 or the implied operand
of the CHARACTERS phrase is not eligible to participate, it is
considered not to match the contents of the data item referenced
by identifier-1. If there is no occurrence of literal-2,
literal-S within the contents of the data item referenced by
identifier-1, its associated literal-1, literal-3, or the implied
operand of the CHARACTERS phrase is never eligible to participate
in the comparison operation.

Format 1

7. The contents of the data item referenced by identifier-2 are not


initialized by the execution of the INSPECT statement.

8. The rules for tallying are as follows:

a. If the ALL phrase is specified, the contents of the data item


referenced by identifier-2 is incremented by one for each
occurrence of literal-1 matched within the contents of the data
item referenced by identifier-1.

b. If the LEADING phrase is specified, the contents of the data item


referenced by identifier-2 are incremented by one for each
contiguous occurrence of literal-1 matched within the contents of
the data item referenced by identifier-1, provided that the
I'Wil leftmost such occurrence is at the point where comparison began in
!.
the first comparison cycle in which literal-1 was eligible to
participate.

c. If the CHARACTERS phrase is specified, the contents of the data


r-' item referenced by identifier-2 are incremented by one for each
character matched, in the sense of general rule Se, within the
contents of the data item referenced by identifier-1.
1'-'l
I

r- 119
Format 2

9. The required words ALL, LEADING, and FIRST are adjectives.

10. The rules for replacement are as foll0ws:

a. When the CHARACTERS phrase is specified, each character matched


in the sense of general rule Se in the contents of the data item
referenced by identifier-! is replaced by literal-4.

b. When the adjective ALL is specified, each occurrence of literal-3


matched in the contents of the data item referenced by
identifier-! is replaced by literal-4.

c. When the adjuective LEADIN~ is specified, each contiguous


occurrence of literal-3 matched in the contents of the data item
referenced by identifier-! is replaced by literal-4, provided that
the leftmost occurrence is at che point where comparison began in
the first comparison cycle in which literal-3 was eligible to
participate.

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

Four examples of the use of the INSPECT statement follow:

INSPECT word TALLYING count FOR ALL "L", REPLACING LEADING "A" BY "E" AFTER
INITIAL "L".

Where word = CALLAR, count 2, word = CALLAR.


Where word = SALAMI, count 1, word= SALEMI.
Where word = LATTER, count 1, word LETTER.

120

~
I
INSPECT word REPLACING ALL "A" RY "G" BEFORE INITIAL "X".

Where word c ARXAX, word = GRXAX.


Where word HANDAX, word = HGNDGX.

INSPECT word TALLYING count FOR CHARACTERS AFTER INITIAL "J" REPLACING ALL
11
A11 BY 11 B11

Where word ADJECTIVE, count = 6, word = BDJECTIVE.


Where word JACK, count = J, word = JBCK.
Where word = JUJMAB, count = 5, word = JUJMBB.

INSPECT word REPLACING CHARACTERS BY "B" BEFORE INTTTAI. "A".

word before: 1 2 X Z A B C D
word after: BBBB B A B C D

121
THE MOVE STATEMENT

Function

The MOVE statement transfers data, in accordance with the rules of


editing, to one or more data areas.

General Format

Format l

MOVE j identifier-!! TO identifier-2 [, identifier-3 J ...


literal

Syntax Rules

l. Identifier-! and literal represent the sending area; identifier-2,


identifier-3, represent the receiving area.

2. An index data item cannot appear as an operand of a MOVE statement.


(See THE USAGE CLAUSE in this Chapter).

General Rules

l. The data designated by the literal or identifier-! is moved first to


identifier-2, then to identifier-3, The rules referring to
identifier-2 also apply to the other receiving areas. Any subscripting
or indexing associated with identifier-2, ••• , is evaluated immediately
before the data is moved to the respective data item.

Any subscripting or indexing associated "ii'ith identifier-! is evaluated


only once, immediately before data is moved to the first of the
receiving operands. The result of the statement:

MOVE a (b) TO b, c (b)

is equivalent to:

MOVE a (b) TO temp


MOVE temp TO b
MOVE temp TO c (b)

where 1 temp 1 is an intermediate result item provided by the


implementor.

See Incompatible Data in this Chapter.

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.

The follcwing rules apply to an elementary move between these


categories:

a. The figurative constant SPACE , alphanumeric edited, or alphabetic


data item must not be moved to a numeric or numeric edited data
item.

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 .

c. A non-integer numeric liter al or a non-integer numeric data item


must not be moved to an alphanumeric or alphanumeric edited data
item.

A move from
provided}

L the

ii. the

iii. zero is not used" a·s

e. All other elementary movea are legal and a re performed according


to the rules given in general rule 4.

3. Any necessary conversion of data from one form of internal


representation to another t akes place during legal elementary moves,
along with any editing spec ified for the re ceiving data item:

a. \vhen a n a lphan umeric edited or alpha numeri c item is a receiving


item, alignment and any necessary space filling takes place as
defined under STANDARD ALIGNMENT RULES in this Chapter. If the
size of the se nding item is greater than the size of the receiving
itemy th e excess characters are truncated on the right af t er the
receiving item is f illed. If the sending item is described as
being signed numeric, the operational sign will not be moved; if
the opera ti ona l sign occ upie s a separa t e character position (see
THE SIGN CLAUSE in this C ~apt er) , that charact•r will not be moved

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).

b. When a numeric or numeric edited item is the receiving item,


alignment by decimal point and any necessary zero-filling takes
place as defined under the STANDARD ALIGNMENT RULES in Chapter 2,
except where zeroes are replaced because of editing requirements.
When a signed numeric item is the receiving item, the sign of the
sending item is placed in the receiving item. (See THE
SIGN CLAUSE in this Chapter). Conversion of the representation of
the sign takes place as neces-sary. If the sending item is
unsigned, a positive sign is generated for the receiving item.

When an unsigned numeric item is the receiving item, the absolute


value of the sending item is moved and no operational sign is
generated for the receiving item.

When a data item described as alphanumeric is the sending item,


data is moved as if the sending item were described as an unsigned
numeric integer.

c. When a receiving field is described as alphabetic, justification


and any necessary space-filling takes place as defined under the
STANDARD ALIGNMENT RULES in Chapter 2. If the size of the sending
item is greater than the size of the receiving item, the excess
characters are truncated on the right after the receiving item is
filled.

4. Any move that is not an elementary move is treated exactly as i f it


were an alphanumeric to alphanumeric elementary move, except that there
is no conversion of data from one form of internal representation to
another. In such a move, the receiving area will be filled without
consideration for the individual elementary or group items contained
within either the sending or receiving area.

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.

Category of Sending Category of Receiving Data Item I


Data Item
Numeric
Alphanumeric Integer
Edited Numeric Numeric
Alphabetic Alphanumeric Non-Integer Edited

ALPHABETIC Yes/3c Yes/3a No/2a No/2a


~
I

ALPHANUMERIC Yes/3c Yes/3a Yes/3b Yes/3b

ALPHANUMERIC EDITED Yes/3c Yes/3a No/2a No/2a

INTEGER No/2b Yes/3a Yes/3b Yes/3b


NUMERIC NON-INTEGER Yes/3b
No/2b No/2c Yes/3b

NUMERIC EDITED No/2b ; Yes/3a ;'i~~t4£ No/2a

1
- The relevant rule number is quoted in these columns

THE MULTIPLY STATEMENT

Function

The MULTIPLY statement causes numeric data items to be multiplied and


sets the values of data items equal to the results.
r-'1
I
General Format

Format 1

MULTIPLY !identifier-!! BY identifier-2 (ROUNDED)


literal-! I

[ , identifier-3 (ROUNDED)] [; ON SIZE~ imperative-statement)

125
Format 2

MULTIPLY li?entifier-lt BY lidentifier-2t GIVING identifier-) [ROUNDED]


lHeral-1 I literal-2 I

[• identifier-4 (ROUNDED]] ••• (;ON SIZE ERROR imperative-statement]

Syntax Rules

1. Each identifier must refer to a numeric elementary item, except that in


Format 2 each identifier following the word GIVING must refer to either
an elementary numeric item or an elementary numeric edited item.

2. Each literal must be a numeric literal.

General Rules

1. See The Rounded Phrase, The Size Error Phrase, The Arithmetic
Statements, Overlapping Operands and Incompatible Data in this Chapter.

2. When Format 1 is used, the value of identifier-! or literal-1 is


multiplied by the value of identifier-2. The value of the multiplier
(identifier-2) is replaced by this product; similarly for identifier-!
or literal-1 and identifier-3, etc.

3. When Formaf 2 is used, the value of identifier-! or literal-1 is


multiplied by identifier-2 or literal-2 and the result is stored in
identifier-3, identifier-4, etc.

126
r
THE PERFORM STATEMENT

Function

The PERFORM statement is used to tranHfer control explicitly to one or


more procedures and to return control implicitly whenever execution of the
specified procedure is complete.

General Format

Foi11!at 1

PERFORM procedure-name-! rlL~.


~! procedure-name-2·1

Format 2
J
rs
THROUGH 1
PERFORM procedure-name-!~ TIIRU I procedure-name-2
J! identifier-!! TIMES
integer-! 1

Format 3

~ procedure-name-!~ i:~UGH! procedure-name-2 J UNTIL conditton-1

Syntax Rules

l. Each identifier represents a numeric elementary item described in the


Data Division. In Format 2, identifier-! must be described as a
numeric integer.

2. The words TIIRU and THROUGH are equivalent.

3. Where procedure-name-! and procedure-name-2 are both specified and


either is the name of a procedure in the declarative section of the
program then both must be procedure-names in the same declarative
section.

General Rules

1. When the PERFORM stat,.ent is executed, control is transferred to the


first statement of the procedure named procedure-name-1 (except as
indicated in general rules 4b, 4c, and 4d). This transfer of control
occurs only once for each e:p!cution of a PERFOR:·l statement. For those
cases where a trans fer of control to the named procedure does take
place, an implicit transfer of control to the next executable statement
following the PERFO!Ul statement is established as follows:

a. If procedurt!-name-1 is a paragraph-name and procedure-name-2 is


not specified, then the return is after the last statement of
procadure-name-1.

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-!.

c. If procedure-name-2 is specified and it is a paragraph-name, then


the return is after the last statement of the paragraph.

d. If procedure-name-2 is specified and it is a section-name, then


the return is after the last statement of the last paragraph in
the section.

2. There is no necessary relationship between procedure-name-! and


proce.durP.-l"!!!vte-2 eY.cept that a consecutive scqu~liC.e of opecat.ion::s ls co
be executed beginning at the procedure named procedure-name-! and
ending with the execution of the procedure named procedure-name-2. In
particular, GO TO and PERFORM statements may occur between
procedure-name-! and the end of procedure-name-2. If there are two or
more logical paths to the return point, then procedure-name-2 may be
the name of a paragraph consisting of -the EXIT statement, to which all
of these paths must lead.

3. If control passes to these procedures other than via a PERFORM


statement the procedures are executed right through to the next
executable statement in the main program as if they were just part of
the main program,

4. The PERFORM statements operate as follows with rule 3 above applying to


all formats:

a. Format l is the basic PERFORM statement. A procedure referenced


by this type of PERFORM statement is executed once and then
control passes to the next executable statement following the
PERFORM statement.

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-!.

c. Format 3 is the PERFORM ••. UNTIL. The specified procedures are


performed until the condition specified by the UNTIL phrase is
true. When the condition is true, control is transferred to the
next executable statement after the PERFORM statement. If the

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.

5. If a sequence of statements referred to by a PERFORM statement includes


another PERFORM statement, the sequence of procedures associated with
the included PERFORM must itself either be totally included in, or
totally excluded from, the logical sequence referred to by the first
PERFORM. Thus, an active PERFORM statement, whose execution point
begins within the range of another active PERFOIU-1 statement, must not
allow control to pass to the exit of the other active PERFORM
statement; furthermore, two ~r more such active PERFORM statements may
not have a common exit. See Figure 3-1.

r- X

a
PERFORM a THRU 111 X

a
PERFORM a THRU m

d PERFORM f THRU j d PERFORM f THRU j


~
f h

.. ) m

r- m f

~ X PERFORM a THRU m
I

r f

m ..
)
J
...
r d PERFORM f THRU j

Fig. 3-1. PERFORM Statement in Sequence.


r--
6. A PERFORM statement that appears in a section that is not an
independent segment can have within its range, in addition to any
declarative sections whose execution is caused within that range, only
~ one of the following:

a. Sections and/or paragraphs wholly contained in one or more


non-independent segments.

b. Sections and/or paragraphs wholly contained in a single


independent segment.

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:

a. Sections ·•nd /or paragraphs who lly cont a in ed in one or more


non- independent segments .

b. Sections and/or parag raph s who l ly conta ined in t he same


independent segmen t as that PERFORN statement .

130
THE STOP STATEMENT

Function

The STCP statement causes a permanent or temporary suspension of the


execution of the object program.

General Format

STOP RUN }
{ literal

Syntax Rules

1. The literal may be numeric or non-numeric or may be any figurative


constant, except ALL.

2. If the literal is numeric, then it must be an unsigned integer.

3. If a STOP RUN statement appears in a consecutive sequence of imperative


statements within a sentence, it must appear as the last statement in
that sequence.

General Rules

1. If the RUN phrase is used, then the operating system ending procedure
is instituted.

2. If STOP literal is specified, the literal is communicated to the


~ operator. Continuation of the object program begins with the execution
of the next executable statement in sequence.

r
r-
r--
r--
~
131

r-
THE SUBTRACT STAXFMENT

Function

The SUBTRACT statement is used to subtract one, or the sum of two or


more, numeric data items from one or more items, and set the values of one
or more items equal to the results.

General Format

Format 1

SUBTRACT )identifier-11 •)identifier-21


literal-1 literal-2

identifier-m [ROUNDED] [· identifier-n

[; ON ~ ~ imperative-statement]

Format 2

SUBTRACT lidentifier-11 •)identifier-21 ~ identifier-m


literal-1 I literal-2

~ identifier-n [~] [• identifier-a [ROUNDED] ] •••


[; ON ~ ~ imperative-statement]

Syntax Rules

1. Each identifier must refer to a numeric elementary item except that in


Foi1113t 2, each identifier following the word GIVING must refer to
either an elementary numeric item or an elementary numeric edited item.

2. Each literal must be a numeric literal.

3. The composite of operands must not contain more than 18 digits. (See
The Arithmetic Statements in this Chapter).

a. In Format 1 the composite of operands is determined by using all


of the operands in a given statement.

b. In Format 2 the composite of operands is determined by using all


of the operands in a given statement excluding the data items that
follow the word GIVING.

132
General Rules

1. See The Rounded Phrase, The Size Error Phrase, The Arithmetic
Statement, Overlapping Operands and Incomnatible Data in this Chapter.

2. In Format 1, all literals or identifiers preceding the word FROM are


added together and this total is subtracted from the current value of
identifier-m storing the result imme~iately into identifier-m, and
repeating this process respectively for each operand following the word
,_.
I
FROM.

3. In Format 2, all literals or identifiers preceding the word FROM are


added togethe!:, the su"' is subtracted from literal-m or identifiet'-m
and the result of the subtraction is stored as the new value of
identifier-n, identifier-n, etc.
t-'
I
4. The compiler ensures enough places are carried so as not to lose
significant digits during execution.

,_
I

133
CHAPTER 4

TABLE HANDLING

INTRODUCTION TO THE TABLE HANDLING MODULE

The Table Handling roodul€. provides a capability for defining tables of


contiguous data items and accessing an item relative to its position in the
table. Language facilities are provided for specifying how many times an
item is to be repeated. Each item may be identified through use of a
subscript or an index (see Chapter 2).

Table Handling provides a capability for accessing items in variable


length. tab~. ~~.~' ....
· • g~.. ~. ..Jll..,.~\flJJ~~d.'.'i.,Jile.•. ~.·.s·'. ~~IJ::.
. . . , .. . . ~~
· ~.E.
,.,'1)VJ;~at.i imum number of multiple
rlimensJ.ons i·j~~~• .~;;.~JbAAiill~~'l is restricted to three.

DATA DIVISION IN THE TABLE HANDLING MODULE

THE OCCURS CLAUSE

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

OCCURS integer-2 TIMES

(INDEXED BY index-name-1 (, index-name-2] ... l

Syntax Rules

1. An INDEXED BY phrase is required if the subject of this entry, or an


entry subordinate to this entry, is to be referred to by indexing. The
index-name identified by this clause is not defined elsewhere since its
allocation and format are dependent on the hardware, and not being
data, cannot be associated with any data hier&rchy.

3. Index-name-1, index-name-2, must be unique words within the


program.

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).

3. Th" r.Uillber oi occutr.,nce& of the sui>ject entry is defined as the value


of integer-2 representing the exact number of occurrences.

135
THE USAGE CLAUSE

Function

The USAGE clause specifies the format of a data item in the compute~
~,
storage.

General ForJiat

(USAGE IS] INDEX

Syntax Rules

l. An index data item can be referenced explicitly only in a SET


statement, a relation condition, the USING phrase of a Procedure
Division header, or the USING phrase of a CALL statement.

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.

2. An elementary item described with the USAGE IS INDEX clause is called


an index data item and contains a value which must correspond to an
occurrence number of a table element. The elementary item cannot be a
conditional variable. The compiler will allocate a 2 byte binary field
with an implied picture of 9(4) COMPUTATIONAL. If a group item is
described with the USAGE IS INDEX clause the elementary items in the
group are all index data items. The group itself is not an index data
item and cannot be used :n the SET statement or in a relation
condition.

3. An index data item can be part of a group which is referred to in a


MOVE or input-output statemP.nt, in which case no conversion will take
place.

136
,... PROCEDURE DIVISION IN THE TABLE HANDLING MODULE

RELATION CONDITION

Comparisons Involving Index-Names And/or Index Data Items

Relation tests may be made between the following data items:

* Two index-names. The result is the same as tf the corresponding


occurrence numbers were compared.

* An index-name and a data item (other than an index data item) or


literal. The occurrence number that corresponds to the value of
the index-name is compared to the data item or literal ,

* An index data item and an index-name or another index data item.


The actual values are compared without conversion.

* The result of the comparison of an index data item with any data
item or literal not specified above is undefined.

OVERLAPPING OPERANDS

When a sending and a receiving item in a SET statement share a part of


their storage areas, the result of the execution of such a statement is
undefined.

THE SET STATEMENT

Function

The SET stat~ent establishes reference points for table handling


operations by settinp, index-names associated with table elements.

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

\!!f. .!!_ ! jidentifier-4!


~ index-name-4 [, index-name-5]
··' l DOWN .!!_~ integer-2 I

137

: .
Syntax Rules

All referen~es to index-name-1, identifier-!, and index-name-4 apply


equally to 1ndex-name-2, identifier-2, and index-name- S, respectively.
2. Identifier-1 and identifier-3 must name either index data items, or
elementary items described as an int~ger.

3. Identifier-4 must be described as an elementary numeric integer.

4. Integer-! and integer-2 may be signed. Integer-1 must be positive.

General Rules

1. Index-names are considered related to a given table and are defined by


being specified in the INDEXED BY clause.

2. If index-name-3 is specified, the value of the index before the


execution of the SET statement must correspond to an occurrence number
of an element in the associated table.

If index-name-4, index-name-S is specified, the value of the index both


before and after the execution of the SET statement must correspond to an
occurrence number of an element in the associated tab~"· If index-name-1,
index-name-2 is specified, the value of the index after the execution of the

..
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:

a. Index-name-1 is set to a value causing it to refer to the table


element that corresponds in occurrence number to the table element
referenced by index-name-3, identifier-3, or integer-1. If
identifier-3 is an index data item, or if index-name-3 is related
to the same table as index-name 1, no conversion takes place.

b. If identifier-1 is an index data item, it may be set equal to


either the contents of index-name-3 or identifier-3 where
identifier-3 is also an index item; no conversion takes place in
either case.

c. If identifier-! is not an index data item , it may be set only to


an occurrence number that corresponds to the value of
index-name-3. Neither identifier-3 nor integer-1 can be used in
this case.

d. The process is repeated for index-name-2 , identifier-2, etc., if


specified. Each time the value of index-name-3 or identifier-3 is
used as it was at the beginnin~ of the execution of the statement.
Any subscripting or indexing associated with identifier-1, etc.,
is evaluated immediately before the value of the respective data
item is changed.
4. In Format 2, the contents of index-name-4 are incremented (UP BY) or
decremented (DOWN BY) by a value that corresponds to the number of
occurrences represented by the value of integer-2 or identifier-4;
tnerearter, cne process 1s repeacea tor ina..x-name-5, .. cc. f.ach ewe
the value of identifier-4 is used as i t was at the beginning of the
execut i on of the statement.
138
5. Data in Table 4-1 represents the validity of various operand
combinations in the SET statement. The general rule reference
indicates the applicable general rule.

Table 4-1. SET Statement Valid Operand Combinations.

Sending Item Receiving Item 1


Integer Data Item Index-Name Index Data Item

Integer Literal No/3c Valid/3a No/3b

Integer Data Item No/3c Valid/3a No/3b

Index-Name Valid/3c Valid/3a Valid/3b 2

Index Data Item No/3c 2 2


Valid/3a Valid/3b

1 = Rule numbers under General Rules above are referred to.


2 = No conversion takes place

r-
1

139
CHAPTER 5

SEQUENTIAL INPUT AND OUTPUT

INTRODUCTION TO THE SEqUENTIAL I-<> MODULE

The Sequential I-<> module provides a capability to access records of a


file in established sequence. The sequence is established as a result of
writing the records to the file. It also provides for the specification of
re-run points and the sharing of memory areas among files.

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

In the sequential access mode, the sequence in which records are


accessed is the order in which the records were originally written.

Current Record Pointer ~

The current record pointer is a conceptual entity used in this document


to facilitate specification of the next record to be accessed within a given
file. The concept of the current record pointer has no meaning for a file
opened in the output mode. The setting of the current record pointer is
affected only by the OPEN and READ statements.

I-<> Status

If the FILE STATUS clause is specified in a file control entry, a value


is placed into the specified two-character data item during the execution of
an OPEN, CLOSE, READ, WRITE, or REWRITE statement and before any applicable
USE procedure is executed, to indicate to the COBOL program the status of
that input-output operation.

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:

0 Successful Completion. The input-output statement was


successfully executed .

At End. The sequential READ statement was unsuccessfully


executed as a result of an attempt to read a record when no
next logical record exists in the file

3 Permanent Error. The input-output statement was


unsuccessfully .executed as the result of a boundary violation
for a sequential file or as the result of an input-output
error, such as data check parity error, or transmission
error.

9 Operating System Error Message. The iriput-output statement


was unsuccessfully executed as a resul~ of a condition that
is specified by the Operating System Error Message. This
value is used only to indicate a condition not indicated by
other defined values of status key 1, or by specified
combinations of the values of status key 1 and status key 2.

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:

* If no further information is available concerning the input-output


operation, then status key 2 contains a value of 'O'.
* When status key l contains a value of '3' an irrecoverable error
has occurred. This is treated as a fatal error by the Operating
System.
* When status key l 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 Oper~ting Guide specific to your operating system contains
details of this status-key-2 representation.
Note that it is not possible to extract this number directly.

Valid Combinations of Status Keys 1 and 2

The valid permissible combinations of the values of status key l and


status key 2 are shown in the following table. An 'X' at an intersection
indicates a valid permissible combination.

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

The AT END condition can occur as a result of the execution of a READ


statement. For details of the causes of the condition, see THE READ
STATEMENT later i.n thi.s Cnapter.

142
ENVIRONMENT DIVISION IN THE SEQUENTIAL I-D HODULE

INPUT-DUTPUT SECTION

The FILE-CONTROL Pa:.:agraph

Function

The FILE-CONTROL paragraph names each file and allows specification of


other file-related information. (See also Appendix I in this manual).

General Format

FILE-CONTROL. j file-control-entry j

The 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 jexternal-f~le-name-literal![, external-file-name-literal!]
------ file-ident1fier I !file-identifier I
[ ; ORGANIZATION IS ),;•;I:6,L-!]
[; ACCESS MODE IS SEQUENTIAL)

[; FILE STATUS 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 Divisiorr.

3. If the ACCESS HODE clause is not specified, the ACCESS MODE IS


SEQUENTIAL clause is implied.

4. Data-name-1 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.

143
...,
5 • When the ORGANIZATION IS S~UENTIAL clause is not specified, the
ORGANIZATION IS SEQUENTIAL clause is implied.

General Rules

1. The ASSIGN

2. The ORGANIZATION clause specifies the logical structure of a file. The


file organization is established at the time a file is created and
cannot subsequently be changed.

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

The I-o CONTROL paragraph specifies the points at which re-run is to be


established, the memory area which is to be shared by different files, and
the location of files on a multiple file reel.

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

l. The I-Q-CONTROL paragraph is


,; tkl01~~~~on··. o~y 'wb~ ll~~q.t~ .•. ;:;::: :)i:~if{f(Y{;::\_jl{:tii!T :

2. File-name-1 must be a sequentially organized file.

3. The END OF REEL/UNIT clause may only be used i f file-name-2 is a


sequentially organized file and is for documentation purposes only.
4. When either the integer-1 RECORDS clause or the integer-2 CLOCK-uNITS
clause is specified, implementor-name must be given in the RERUN
clause.

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.

RECORD DESCRIPTION STRUCTURE

A record description consists of a set of data description entries

...
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

THE FILE DESCRIPTION - COMPLETE ENTRY SKELETON

Function

The file description furnishes information cuncerning the physical


structure, identification, and record names pertaining to a given file.

General Format

FD file-name
{RECORDS }]
[; BLOCK CONTAINS integer-2 1CHARACTERS
[; RECORD CONTAINS (integer-3 TO J integer-4 CHARACTERS]

LABEL {RECORD IS } {STANDARD}}


- - RECORDS ARE OMITTED
------- -------

VALUE OF data-name-1 IS literal-!


------
[, data-name-2 IS literal-2] •• ·]

·, DATA
--
{~IS
RECORDS ARE
}
data-name-3 [, data-name-4] ••. ]
[

(; CODE-SET IS alphabet-name]

Syntax Rule.,

1. The level indicator FD identifies the beginning of a file description


and must precede the file-name.

2. The cia uses which follow the name of the


and their order of is

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

This clause is · r equired for document at~ P-;;J~,;;~~ only .

THE CODE- SET CLAUSE

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

CODE-SET IS alphabe t-name

Syn tax Rules

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.

THE DATA RECORDS CLAUSE

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.

THE LABEL RECORDS CLAUSE

Function
1!11&~\1\~~;S~mt~~~~-~lJim
General Format

RECORD IS } {STANDARD}
{ RECORDS ARE OMITTED

Syntax Rule
This clause

General Rule

THE RECORD CONTAINS CLAUSE

Function
The RECORD CONTAINS clause specifies the size of data records.

General Format

RECORD CONTAINS (integer-! TO) integer-2 CHARACTERS

General Rule
The size of each data record is within the record
de ther efore th is

149
THE VALUE OF CLAUSE

Function

The VALUE OF clause specifies the description of an item in the label


records associated with a file.

General Format

VALUE OF data-name-1 IS literal-1


----
[, dataname2 IS literal-2)

General Rules

2. A figurative constant may be substituted in the format above wherever a


literal is specified.

~I

150
PROCEDURE DIVISION IN TilE SEQUENTIAL I-Q MODULE

THE CLOSE STATEMENT

Function

The CLOSE statement terminates the processing of files.

General Format

CLOSE file-name-1 [ REEL


UNIT J
Syntax Rule

General Rules

1. A CLOSE statement may only be executed for a file in an open mode.

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.

3. If a CLOSE statement has been executed for a file, no other statement


can be executed that references that file, either explicitly or
implicitly, unless an intervening OPEN statement for that file is
executed.

4. Following the successful execution of a CLOSE statement the record area


associated with file-name is no longer available. The unsuccessful
execution of such a CLOSE statement leaves the availability of the
record area undefined.

151
THE OPEN STATEMENT

Function

The OPEN statement initiates the processing of files. It also performs


checking and/or wri ting of labels and other input-output operations.

General Format

INPUT file-name-1 [, file-name-2]

OUTPUT file-name-3 [, file-name-4]

OPEN

I-0 file-name - 5 [, file-name-6]

EXTEND file-name-7 [, file-name-S]

1. can be used

2.

General Rules

1. The successful execution of an OPEN statement determines the avail-


ability of the file and results in the file being in an open mode.

2. The successful execution of an OPEN statement makes the associated


record area available to the program .

3. Prior to the successful execution of an OPEN statement for a given


file, no statement can be executed that references that file, either
explicitly or implicitly.

4. An OPEN statement must be successfully executed prior to the execution


of any of the permissible input-output statements. In Table 5-l, 'X'
at an intersect i on indicates that the specified statement, used in the
sequential access mode, may be used with the sequential file
organization and open mode given at the top of the column.

152

lliiilil
I
Table 5-1. Permissable Combinations of Statements and O:~EN Modes for
Sequential I/0.

Statement Open Mode


1
Input Output Input-Output Extend

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.

7. The ASSIGNed name in the SELECT statement for a file is processed as


follows:

a. When the INPUT phrase is specified, the execution of the OPEN


s ta temen t causes the ASSIGNed name to be checked in accordance
with the operating system conventions for opening files for input.

b. When the OUTPUT phrase is specified, the execution of the OPEN


statement causes the ASSIGNed name to be written in accordance
with the operating system conventions for opening files for
output.

8. The file description entry for file-name-1, file-name-5, must be


equivalent to that used when this file was created.

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

READ file-name RECORD [INTO identifier] [; AT END imperative- statement]

-~ 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. The AT END phrase must be specified i f no applicable USE procedure is


specified for file-name,

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).

2. The record to be made available by the READ statement is determined as


follows:

a. If the current record pointer was positioned by the execution of


the OPEN statement, the record pointed to by the current record
pointer is made available.

b. If the current record point~r was positioned by the exec:~tion of a


previous READ statement, the current record pointer is updated to
point to the next existing record in the file and then that record
is made available.

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) •

4. Regardless of the method used to overlap access time with processing


time, the concept of the READ statement is unchanged in that a record
is available to the object program prior to the execution of any
statement following the READ statement.

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.

9. If the end of a reel or unit is recognized during the execution of a


READ statement, an end-of-file status condition exists.

a. The standard ending reel/unit label procedure.


b. A reel/unit swap.
c. The standard beginning reel/unit label procedure.
d. The first data record of the new reel/unit is made available.

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.

When the AT END condition occurs, execution of the input-output


fiilllll'(
I
statement which caused the condition is unsuccessful.

13. Following the unsuccessful execution of any READ statement, the


contents of the associated record area and the position of the current
record pointer are undefined.

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

The REWRITE statement logically replaces a record existing in a disk


file.

General Format

REWRITE record-name (FROM identifier]

Syntax Rules

1. Record-name and identifier 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 and may b~ qualified.

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.

3. The number of character positions in the record referenced by


record-name must be equal to the number of character positions in the
record being replaced.

4. The logical record released by a successful execution of the REWRITE


statement is no longer available in the record area,

5. The execution of a REWRITE statement with the FROM phrase is equivalent


to the execution of:

HOVE identifier TO record-name

followed by the execution of the same REWRITE statement without the


FROM phrase. The contents of the record area prior to the execution of
the implicit HOVE statement have no effect on the execution of the
REWRITE statement.

6. The current record pointer is not affected by the execution of a


REWRITE 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

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

USE AFTEI{ STANDARD


---
I EXCEPriON
ERROR
I INPUT
I'ROCEDURE ON OUTPUT
I-0
I
{ file-name-1\

1ffiEND
Syntax Rules

1. A USE statement, when present, must immediately follow a section header


in the declarat ives section and must be followed by a period followed
by a spac~. The remainder of the section must consist of zero, one or
more proce~ural paragraphs that define the procedure to be used.
\
2. The USE st~tement itself is never executed; it merely defines the
conditions c~lling for the execution of the USE procedures.

General Rules

1. If the AT END phase has 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 upon
recognition of the AT END condition

2. After execution of a USE procedure, control is returned to the invoking


routine.

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

The WRITF. statement releases· a logical record for an output file. It


can also be used for vertical positioning of lines within a logical page.

General Format

WRITE record-name [~ identifiet-1]

-[ 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.

4. Integer may be zero.

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).

2. The logical record released by the execution of the WRITE statement is


no longer available in the record area unless the execution of the
WRITE statement was unsuccessful due to a boundary violation.

3. The results of the execution of the WRITE statement with the FROM
phrase is equivalent to the execution of:

a. The statement:

HOVE identifier-! TO record-name

according to the rules specified for the MOVE statement, followed


by:

b. The same WRITE statement without the FROM phrase.

The contents of the record area prior to the execution of the


-· implicit ~VE statement have no effect on the execution of this
WRITE 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.)

4. The current record pointer is unaffected by the execution of a WRITE


statement.

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.

7. The numbe r of character positions on a disk r equired t o store a lo gical


record in a file may or may not be equal to the number of character
positions defined by the logical description of that record in th e
program.

8. Th e execution of the \-/RITE statement releas es a logical record to the


operating system.

9. The ADVANCING phrase allows control of the ver tical position ing of each
line on a representation of a printed page.

a. With ORGANIZATION SEQUENTIAL if the ADVANCING phrase is not used,


automatic advancing is provided when output is directed to a
list- device to act as if the user had specified AFTER
ADVANCING 1 LINE. If the ADVANCING phrase is used, advancing is
provided as follows:

i. If integer is specified, the r ep res en tation of the printed


page is advanced the numb e r of lines e qual t o the value of
integer .
ii. If the BEFORE phrase is used, the line is presen t ed before
the representation of the printed page is advanced .
iii . If the AFTER phrase is used, the line is presented after the
representation of the printed page is advanced .
iv . If PAGE is specified, the record is presented on th e logical
page before or after (depend1ng on the phrase used) the
device i s repositioned t o t he next lo gical 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).

If a USE AFTER STANDARD EXCEPTION declarative is explicitly or


implicitly specified for the file, that declarative procedure will

r- c.
then be executed.

If a USE AFTER STANDARD EXCEPTION declarative is not explicitly or


implicitly specified for the file, the result is undefined.

r-'

r-'

r-
r-
~
,...- ·-·
L 161

r-
CHAPTER 6

RELATIVE INPUT AND OUTPUT

INTRODUCTION TO THE RELATIVE I-0 MODULE

The Relative I-0 module provides a capability to access records of a mass


storage file i,n either a random or sequential manner. Each record in a
relative file is uniquely identified by an int~ger value greater than zero
which specifies the record 1 s ordinal position in the file . (See the CIS
COBOL Operating Guide for the maximum number of records in a relative file.)

LANGUAGE CONCEPTS

Organization

Relative file organization is permitted only on disk devices. A relative


file consists of records which are identified by relative record numbers.
The file may be thought of as composed of a S<=t:;l.al string of areas, each
capable of holding a logical record. Each of these areas is denominated by
a relative record number. Records are stored and retrieved based on this
number. For example, the tenth record is the one addressed by relative
record number 10 and is in the tenth record area, whether or not records
have been written in the first through the ninth record areas.

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.

Current Record Pointer

The current record printer is a conceptual entity used in this document to


facilitate specification of the next record to be accessed within a given
file. The concept of the current record pointer has no meaning for a file
opened in the output mode. The setting of the current record pointer is
affected only by the OPEN, START and READ statements.

I-0 Status

If the FTLE STATUS clause is specified in a file control entry, a value is


placed into the specified two-character data item during the execution of an
OPEN, CLOSE, READ, WRITE, REWRITE, DELETE or START statement and before any

162
applicable USE procedure is executed, to indicate to the COBOL program the

r. status of that input-output operation.

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.

'O' - indicates Successful Completion


'1' - indicates At End
'2' - indicates Invalid Key
'3' - indicates Permanent Error
'9' - indicates an Operating System Error Message

The meaning of the above indications are as follows:

'0' - Successful Completion . The input-output statement was


successfully executed.

'1' -At End. The Format 1 READ statement was unsuccessfully


executed as a result of an attempt to read a record when no
next logical record exists in the file.

'2' - Invalid Key. The input-output statement was unsuccessfully


executed as a result of one of the following:

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.

'9' - Operating System Error Message. The input-output statement was


unsuccessfully executed as the result of a condition that is
specified by the Operating System. This value is used only to
indicate a condition not indicated by other defined values of
status key 1, or by specified combinations of the values of status
key 1 and status key 2.

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:

* If no further information is available concerning the input-output


operation, then status key 2 contains a value of '0'

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:

2 Indicates a duplicate key value. An attempt has been


made to write a record that would create a duplicate key
in a relative file.

3 Indicates no record found. An attempt has been made to


access a record, identified by a key, and that record
does not exist in the file,

4 Indicates a boundary violation. An attempt has been


made to write beyond the externally-defined boundaries
of a relative file. This is normally treated as a fatal
error by the Operation System.

* When status key 1 contains a value of 1 9 1 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 the status-key-2 representation.
Note that it is not possible to eKtract this number directly.

Valid Combinations of Status Keys 1 and 2

The valid permissible combinations of the values of status key 1 and


status key2 are shown in the table. An 'X 1 at an intersection indicates a
valid permissible combination.

Status Key 1 Status Key 2

~o Further Duplicate No Record Boundary


Information Key Found Violation
(0) (2) (3) (4)
Successful
Completion (0) X

At End (1) X

Invalid Key (2) X X 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).

2. If the INVALID KEY phrase is specif1.ed in the statement causing the


condition, control is transferred to the INVALID KEY imperative
statement. Any USE procedure specified for this file is not executed.

3. If the INVALID ~'"Y phrase is not specified, but a USE procedure is


specified, either explicitly or implicitly, for this file, that
procedure is executed.

When the !~VALID KEY condition occurs, execution of the input-output


statement which recognised the condition is unsuccessful, and the file is
not affected.

The AT END Condition

The AT END condition can occur as a result of the execution of a READ


statement. For details of the causes of the condition, see The READ
Statement later in this chapter.

165
ENVIRONMENT DIVISION IN THE RELATIVE I-D MODULE

INPUT-oUTPUT SECTION

The File-Control Paragraph

Function

The FILE-CONTROL paragraph names each file and allows specification of


other file-r.>lated information. (See also Appendix F in the CI'i COBOL
Operating Guide).

Geu.. ral Format


FILE-CONTROL j file-control-entry!
The File-Control Entry

Function

The file cuntrol entry names a file and may specify other file-related
information.

General Format
SELECT file-name

ASSIGN TO external-file-name-11 terall


Ifile-identifier I
external-file-name-literal!]
[ ' ! file-identifier I

; 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.

3. If the ACCESS MODE clause is not specified, the ACCESS MODE IS


SEQUENTIAL clause is implied.

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.

5. Data-name-! must not be defined in a record description entry


associated with that file-name .

6. The data item referenced by data-name-! must be defined as an unsigned


integer.

r General Rules

1. The ASSIGN clause specifies the association of the file referenced by


r file-name to a storage medium.
:!j)e, > U flll Guide .
,q.,ii!I'II.IIII!Dl;!l wjj;1l/b
See A. l!!rul ~ F in the CIS COBOL
ff=tt ..... ~ ~li:ii!>-
~ ~ lliJ
tlOS!!~ IJ~
llii!o !~He I! IU! IJIB II nil 11 !llll!!Ji
r.Jd
2. ORGANIZATION clause specifies the logical structure of a file. The
'l.i.~
file organization is established at the time a file is created and
cannot subsequently be changed .

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) .

7. All records stored in a relative file are uniquely identified by


relative record numbers. The relative record number of a given record
specifies the record's logical ordinal position in the file. The first
logical record has a relative record number of 1, and subsequent
logical records have relative record numbers of 2, 3, 4,

8. The data item specified by data-name-! is used to communicate a


relative record number between the user and the Operating System.

167
The I-Q-CONTROL Paragraph

Function

The I-0-CONIROL paragraph specifies the points at which rerun is to be


established and the memory area which is to be shared by different files.

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

[;~AREA FOR file-name-3 ). file-name-4 ! ... J


Syntax Rules

1. The

2. File-name-1 must be a sequentially organized file.

3. When either the integer-! RECORDS clause or the integer-2 CLOCK-UNITS


clause is specified, implementor-name must be given in the RERUN
clause.

4. More than one RERUN clause may be specified for a given file-name-2,
subject to the following restriction:

When multiple integer-! RECORDS clauses are specified, no two of


them may specify the same file-name-2.

5. Only one RERUN clause containing the CLOCK-UNITS clause may be


specified.

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.

RECORD DESCRIPTION STRUCTURE

A record description consists of a set of data description entries 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 clauses used with
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
CONCEPTS 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.

THE FILE DESCRIPTION - COMPLETE I::NTRY SKELETON

Function

The file description furnishes information concerning the physical


structure, identification, and record names pertaining to a given file.

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

1. The level indicator FD identifies the beginning of a file description


and must precede the file-name.

2. The clauses which follow the name of the file are


cases, and their order of appearance is immaterial.

3. One or more re'c ord description entries must follow the file description
e ntry.

THE BLOCK CONTAINS CLAUSE

Function

The BLOCK CONTAINS clause specifies the size of a physical record .

Ge nera l Format

BLOCK CONTAINS i nteger -2 RECORDS }


{ CHARACTERS

General Rules

THE DATA RECORDS CLAUSE

Function

The DATA RECORDS clause serves only as documentation for the names of
data records with their associated file.

Genera l Format

DATA RECORD IS } data-name-1 [, data-name-2]


{ RECORDS ARE

Syn tax Rule

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 .

THE LABEL RECORDS CLAUSE

Function

The LABEL RECORDS clause specifies whether labels are present.

~ General Format

RECORD IS STANDARD}
{ RECORDS ARE OMITTED

Syntax Rule

1'his clause

General Rule

THE RECORD CONTAINS CLAUSE

Function

The RECORD CONTAINS clause specifies the size of data records.

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

The VALUE of clause specialises the description of an item in the label


records associated with a file.

General Format

VALUE OF data-name-1 IS literal-!

[,data-name-2 IS literal-2]

Syntax Rules

1. Data-name-1, data-name-2, etc, should be qualified when necessary, but


cannot be subscripted or indexed, nor can they be items described with
the USAGE IS ·INDEX clause

2. Data-name-1, data-name-2 etc, must be in the Working-Storage Section

General Rules

1.

2. A figurative constant may be substituted in the format above wherever a


literal is specified.

172
PROCEDURE DIVISION IN THE RELATIVE I-0 MODULE

THE CLOSE STATEMENT

Function

f-'1
I
General Format

CLOSE file-name-! [WITH LOCK] (,file-name-2 [WITH LOCK])

Syntax Rule

The files referenced in the CLOSE statement need not all have the same
organization or access.

General Rules

1. A CLOSE statement may only be executed for a file in an open mode.

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.

3. If a CLOSE statement has been executed for a file, no other statement


can be executed that references that file, either explicitly or
implicitly, unless an intervening OPEN statement for that file is
executed.

4. Following the successful execution of a CLOSE statement, the record


area associated with file-name is no longer available. The
unsuccessful execution of such a CLOSE statement leaves the
availability of the record area undefined.

173
THE DELETE STATEMENT

Function

The DELETE statement logically removes a record from a mass storage


file.

General Format

DELETE file-name RECORD (;INVALID KEY imperative-statement]

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)

2. For files in the sequential access mode, the last input-output


statement executed for file-name prior to the execution of the DELETE
statement must have been a successfully executed READ statement. The
Operating System logically removes from the file the record that was
accessed by that READ statement.

3. For a file in random or dynamic access mode, the Operating System


logically removes from the file that record identified by the contents
of the RELATIVE KEY data item associated with file-name. If the file
does not contain the record specified by the key, an INVALID key
condition exists. (See The INVALID KEY Condition in this Chapter).

4. After the successful execution of a DELETE statement, the identified


record has been logically removed from the file and can no longer be
accessed.

5. The execution of a DELETE statement does not affect the contents of the
record area associated with file-name.

6. The current record pointer is not affected by the execution of a DELETE


statement.

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

The OPEN statement initiates the processing of fil~9. It also performs


checking and/or writing of labels and other input-output operations.

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

1. The successful execution of an OPEN statement determines the


availability of tHe file and results in the file being in an open mode.

2. The successful execution of the OPEN statement makes the associated


record area available to the program .

3. Prior to the successful execution of an OPEN statement for a given


file, no statement can be executed that references that file, either
explicitly or implicitly.

4. An OPEN statement must be successfully executed prior to the execution


of any of the permissible input-output statements. In Table 6-1, 'X'
at an intersection indicates that the specified statement, used in the
access mode given for that row, may be used with the relative file
organization and the open mode given at the top of the column.

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.

7. The file description entry for file-name-1, file-name-2, file-name-5 or


file-name-6 must be equivalent to that used when this file was created.

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.

5. The INVALID KEY phrase or the AT END phrase must be specified if no


applicable USE procedure is specified for file-name.

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

2. The record to be made available by a Format 1 READ statement is


determined as follows:

a. The record, pointed to by the current record pointer, is made


available provided that the current record pointer was positioned
by the START or OPEN statement and the record is still accessible
through the path indicated by the current record pointer; i f the
record is no longer accessible, which may have been caused by the
deletion of the recori, the current record pointer is updated to
point to the next existing record in the file and that record is
then made available.

178
r-
r-

r- b. If the current record pointer was positioned by the execution of a


previous READ statement, the current record pointer is updated to
point to the next existing record in the file and then that record
is made available.

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).

4. Regardless of the method used to overlap access time with processing


r- time, the concept of the READ statement is unchanged in that a record
is available to the object program prior to the execution of any
statement tollow1ng the READ statement.

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.

8. If, at the time of execution of a Format l READ statement, the position


of current record pointer for that file is undefined, the execution of
that READ statement is unsuccessful.

9. If, at the time of the execution of a Format 1 READ statement, no next


logical record exists in the file, the AT END condition occurs, and the
execution of the READ statement is considered unsucce>1sful. (See I-<l
~ in this Chapter). ---

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)

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.

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.

When the AT END cor.dition occurs, execution of the input-output


statement which caused the condition is unsuccessful.

11. Following the unsuccessful execution of any READ statement, the


contents of the associated record area and the position of the current
record pointer are und~fined.

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:

a. A successfu 1 CLOSE statement followed by the execution of a


successful OPEN statement for that file.

b. A successful START statement for that file.

c. A successful Format 2 READ statement for that file.

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.

14. If the RELATIVE KEY phrase is specified, the execution of a Format 1


READ statement updates the contents of the RELATIVE KEY data item such
that it contains the relative record number of the record made
available,

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

The REWRITE statement logically replaces a record existing in a disk file.

General Format

REWRITE record-name [FROM identifier] [; INVALID KEY imperative-statement]

Syntax Rules

1. Record-name and identifier 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 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) •

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 READ statement.

3. The number of character positions in the record referenced by


record-name must be equal to the number of character positions in the
record being replaced.

4. The logical record released by a successful execution of the REWRITE


statement is no longer available in the record area.

5. The execution of a REWRITE statement with the FROM phrase is equivalent


to the execution of:

MOVE identifier TO record-name

followed by the execution of the same REWRITE statement without the


FROM phrase. The contents of the record area prior to the execution of
the implicit MOVE statement have no effect on the execution of the
REWRITE statement.

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).

8. For a file accessed in either random or dynamic access mode, the


Operating System logically replaces the record specified by the
contents of the RELATIVE KEY data item associated w1 th th£ file. If
the file does not contain the record specified by the key, the INVALID
KEY condition exists. (See THE INVALID KEY CONDITION in this Cha!)ter).
The updating operation does not take place and the data in the record
area is unaffected.

182
THE START STATEl'IENT

Function

The START statement provides a basis for logical positioning within a


relative file, for subsequent sequential retrieval of records.

General Format

IS EQUAL TO
IS =
IS GUATER
IS_>_ __ THAN
IS NOT LESS THAN
IS NOT-<-

(; INVALID KEY imperative-statement]

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

1. File-name must be the name of a file with sequential or dynamic access.

2. Data-name may be qualified.

3. The INVALID KEY phrase must be specified if no applicable USE procedure


is specified for file-name.

4. Data-name, if specified, must be the data item specified in the


RELATIVE KEY phrase of the associated file control entry.

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.

3. The type of comparison specified by the relational operator in the KEY


phrase o~curs between a key associated with a record in the file
referenced by file-name and a data item as specified in general Rule 5.

a. The current record pointer is positioned to the first logical


record currently existing in the file whose key satisfies the
comparison.

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).

s. The comparison described in general rul~ 3 uses the data item


referenced by the RELATIVE KEY clause associated with file-name.

....,
...,
...,
_,
,..,
.....
~

~
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

r USE AFTER STANDARD


~ EXCEPTION
PROCEDURE ON Hl•---1]
INPUT

~ ERROR
OUTPUT
~

S::t:ntax Rules

1. A USE statement, when present, mcst immediately follow a section header


•in the declaratives section and must be followed by a period followed
~ by a space. The remainder of the section must consist of zero, one or
I more procedural paragraphs that define the procedures to be used.

2. The USE statement itself is never executed; it merely defines the


conditions calling for the execution of the USE procedures.

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.

2. After execution of a USE procedure, control is returned to the invoking


~
I routine.

3. Within a USE procedure, there must not be any reference to any


nondeclarative procedures. Conversely, in the nondeclarative portion
there must be no reference to procedure-names in the declarative
portion, except that PERFO&~ 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


statement that would cause the execution of a USE procedure that had
previously been invoked and had not yet returned control to the
invokiag routine.

r
r
~
I

185
THE WRITE STATEMENT

Function

The WRITE statement releases a logical record for an output or input-output


file.

General Format

WRITE record-name [~ identifier] [; INVALID KEY imperative-statement]

Syntax Rules

1. Record-name and identifier m••st not reference the same storage area.

2. The record-name is the name of a logical record in the File Section of


the Data Division.

3. The INVALID KEY phrase must be specified if an applicable USE procedure


is not specified for the associated file.

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).

2. The logical record released by the execution of the WRITE statement is


no longer available in the record area unless the execution of the
WRITE statement is unsuccessful due to an INVALID KEY condition.

3. The results of the execution of. the WRITE statement with the FROM
phrase is equivalent to the execution of

a. The statement:

MOVE identifier TO record-name

according to the rules specified for the MOVE statement, followed


by:
b. The same WRITE statement without the FROM phrase.

The contents of the record area prior to the execution of the


implicit MOVE statement have no effect on the execution of this
WRITE statement.

After execution of the WRITE statement is complete, the


information in the area referenced by identifier is available,
even though the information in the area referenced by record-name
may not be. (See general rule 2 above).

4. The current record pointer is unaffected by the execution of a WRITE


statement.
-l1

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.

7. The number of character positions on a mass storage device required to


store a logical record in a file may or may not be equal to the number
of character positions defined by the logical description of that
record in the program.

!!. 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:

a. If the access mode is sequential, the WRITE statement will cause a


record to be released to the Operating System. The first record
wil.l have a relative record number of one and subsequent records
released will have relative record numbers of 2, 3, 4, ••• If the
RELATIVE KEY data item has been specified in the file control
entry for the associated file, the relative record number of the
record just released will be placed into the RELATIVE KEY data
item by the Operating System during ex~cution of the WRITE
statement.
b. If the access mode is random or dynamic, prior to the execution of
the WRITE statement the value of the RELATIVE KEY data item must
be initialised in the program with the relative record number of
be associated with the record in the record area. That record is
then released to the Operating System by execution of the I-RITE
statement.

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

b. When an attempt is made to write beyond the externally defined


boundaries of the file.

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

INDEXED INPUT AND OUTPUT

INTRODUCTION TO THE INDEXED I-0 MODULE


-
The Indexed I-0 module provides a capability to access records of a
mass storage file in either a random or sequential manner. Each record in
an indexed file is uniquely identified by the value of one key within that
record.

LANGUAGE CONCEPTS

Organization

A file whose organization is indexed is a mass storage file in which


data records may be accessed by the value of a key. A record description
includes a key data item, which is associated with an index. The index
provides a logical path to the data records according to the contents of a
data item within each record which is the record key.

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 sequential access mode, the sequence in which records are


accessed is the ascending order of tl•e record key values.

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.

Current Record Pointer

The current record pointer is a conceptual entity used in tllis document


to facilitate specification of the next record to be accessed w1thin a given
file. The concept of the current record pointer has no meaning for a file
opened only in the output mode. The setting of the current record pointer
is affected only by the OPEN, START and READ statements.

,_.,
I
J
188
I-0 Status

If the FILE STATUS clause is specified in a file control entry, a value


is placed into the specified two-character data item during the execution of
an OPEN, CLOSE, READ, l·lRITE, REWRITE, DELETE or START statement and before
any applicable USE procedure is executed, to indicate to the COBOL program
tne status or that input-output operation.

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.

'O' Successful Completion


'1' -At End
'2' Invalid Key
1 1
3 - Permanent Error
~
i '9' -Operating System Error Message

The meaning of the above indications are as follows:

0 - Successful Completion. The input-output statement was


successfully executed.

1 - At End. The Format l READ statement was unsuccessfully executed


as a result of an attempt to read a record when no next logical
record exists in the file.

2 - Invalid Key. The input-out put statement was unsuccessfully


executed as a result of one of the following:

Sequence Error
Duplicate Key
No Record Found
Boundary Violation

3 - Per:nanent Error. The input-output statement was unsuccessful as


the result of an input-output error, such as data check, parity
error, or tran~mission error.

9 - Operating System Error Hessage. The input-output statement was


unsuccessfully executed as a result of a condition that is
specified by the Operating System Error ~lessage number. This
value is used only to indicate a condition not indicated by other
defined values of status key 1, or by specified canbinations of
the value of status key l and status key 2.

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:

i t no further information is available concerning the input-o<.~tput


operation, then status key 2 contains a value of 1 0 1 •

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:

Indicates a sequence error for a sequentially accessed


indexed file. The ascending sequence requirements of
successive record key values have been viola ted (see The
WRITE Statement later in this Chapter), or H.e record key
value has been changed by the COBOL program between the
successful execution of a READ statement and the execution of
the next REWRITE statement for that file.

2 Indicates a duplicate key value. An attempt has been made to


write or rewrite a record that would create a duplicate key
in an indexed file.

3 Indicates no record found. An attempt has been made to


access a record, identified by a key, and that record does
not exist in the file .

4 Indicates a boundary violation. An attempt has been made to


write beyond the externally defined boundaries of an indexed
file. This is usually treated as a fatal erro, by Operating
Systems.

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.

Valid Combinations of Status Keys 1 and 2

The valid permissible combinations of the value of status key 1 and


status key 2 are shown in the following table. An 'X' at an intersection
indicates a valid permissible combination.

190
Status Key 1 Status Key 2

No Further Sequence Duplicate No Record Boundary


Infonnation Error Key Found Viol at ion
(0) (1) (2) (3) (4)
Successful X X
Completion (0)

At End (1) X

Invalid Key (2; X X X X

Permanent
Error (3) X

Implementor
Defined (9) Operating System Error Message Number
(O!Ii!l
!

The INVALID KEY Condition

~ The INVALID KEY condition can occur as a result of the execution of a


STAKT, KEAD, WKITE, REWKITE or DELETE statement. For details of the causes
of the condition see THE STAKT STATEMENT, THE KEAD STATEMENT, THE WKITE
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 condition. (See I-0 Status).

2. If the INVALID KEY phrase is specified in the statement causing the


condition, control is transferred to the INVALID KEY imperative
statement. Any USE procedure specified for this file is not executed.

When the INVALID KEY condition occurs, execution of the input-output


statement which recognised the condition is unsuccessful and the file
is not affected.

The AT END Condition

The AT END condition can occur as a result of the execution of a READ


statement. For details of the causes of the condition, see THE READ
STATEMENT later in this Chapter.

191
ENVIRONMENT DIVISION IN THE INDEXED I-0 MODULE

INPUT-oUTPUT SECfiON

The File Control Paragraph

Function

The FILE-CONTROL paragraph names each file and allows specification of


other file-related information. (See also append 1x F in the CIS COBOL
Operating Guide).

General Format

FILE-CONTROL. )file-control-entry!···

The 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 ~

[; ACCESS NODE IS SEQUENTIAL


DYNAMIC
~ J
tRANnCiM
; RECORD KEY IS data-name-1

(; FILE STATUS IS data-name-3]

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.

3. If the ACCESS MODE clause is not specified, the ACCESS HODE IS


SEQUENTIAL clause is implied.

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.

5. The data items referenced by data-name-1 must each be defined as a data


item of the category alphanumeric within a record description entry
associated with that file-name.

General Rules

1. The ASSIGN clause specifies the association of


file-name to a storage medium. See
Operating Guide. The first
assignments within any one
only.
2. The ORGANIZATION clause specifies the logical structure of a file. The
File organization is established at the time a file is created and
cannot subsequently be changed.

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.

9. The data description of data-name-1 as well as relative locations


("""'~ within a record must be the same as that used when the file was
created.

193
The I-0 Control Paragraph

Function

The I-0-CONTROL paragra?h specifies the points at which rerun is to be


established and the memory area which is to be shared by different files.

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

1. The I-0-CONTROL paragraph is optional.

2. File-name-1 must be a sequentially organized file.

3. When either the lnteger-1 RECORDS clause or the integer-2 CLOCK-UNITS


clause is speci fied, implementor-name must be given in the RERUN
c lause.

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

In a COBOL program the 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 clau~es
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
te~inated by a period.

RECORD DESCRIPTION STRUCTURE

A record description consists of a. set of data description entries


which describe the characteristics of a particular record . Each data
description entry consists of a level-number followed by a data-nante if
required, followed by a series of independent clauses as required. A record
description has a hierarchical structure and therefore the clauses used with
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
CONCEPTS OF LEVEl.S in Chapter 2 while the elements allowed in a record
description are shown in THE DATA DESCRIPTION - COMPLETE ENTRY SKELETON in
Chapter 3.

THE FILE DESCRIPTION - COMPLETE ENTRY SKELETON

Function

The file description furnishes information concerning the physical


structure, identification, and record names pertaining to a given file.

General Format

FD file-name

; BLOCK CONTAINS integer-2lRECORDS ']


[ CHARACTERS I

[;~CONTAINS [integer-3 TO) integer-4 CHARACTERS]

RECORD IS 1 l STANDARD 1l
l RECORDS ARE I OMITTED IJ

;~OF data-name-! IS literal-!

[,data-name-2 IS literal-2]
DATA RECORD IS I data-name-3 [ ,data-name-4]
l RECORDS ARE I

Syntax Rules

1. The level indicator FD identifies the beginning of a file description


and must precede the file-name.

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 .

THE BLOCK CONTAINS CLAUSE

Function

The BLOCK CONTAINS clause specifies the size of a physical record.

General Format

BLOCK CONTAINS integer-2{~ }


CHARACTERS

THE DATA RECORDS CLAUSE

Function

The DATA RECORDS clause serves only as documentation for the names of
data records with their associated file.

General Format

DATA RECORD IS } data-name-1 [, data-name-21 • . .


{ RECORDS ARE

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

The LABEL RECORDS clause specifies whether labels are present.

General Format

LABEL 1 RECORD IS 1 STANDARD 1


I RECORDS ARE I I ~~
~
I
General Rule

THE RECORD CONTAINS CLAUSE

Function

The RECORD CONTAINS clause specifies the size of data records.

General Format

~ 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. flll~~l
IB!UB!I~BP~~~'!JitrAI·

THE VALUE OF CLAUSE

Function
r The VALUE OF clause specialises the description of an item in the label
recorda associated with a file.

General Format

VALUE OF data-namel IS literal-1


- - - - [ ,dataname2 IS literal-2]

General Rules

2. A figurative constant may be substituted in the format above wherever a


literal is specified.

197
-
PROCEDURE DIVISION IN THE INDEXED I-0 MODULE

THE CLOSE STATEMENT

Function

The CLOSE statement terminat~s the pr ~cessing ~ f . files. >tbe 't


phrase :~ for docua.ntation,:,,~~~t.i~z~;f:·:~(~ji::' i;;,,,,~;,'t\§l!f;,,,> •:J<i\'.'·~·· ·. · ,.

General Format

CLOSE file-name-1 [wiTH~] [• file-name-2 [WITH~)]


Syntax Rule

The files referenced in the CLOSE statem@nt need not all have the same
organization or access.

General Rules

1. A CLOSE statement may only be executed for a file in an open mode.

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

3. If a CLOSE statement has been executed for a file, no other statement


can be executed that references that file, either explicitly or
implicitly, unless an intervening OPEN statement for that file is
executed.

4. Following the successful execution of a CLOSE statement, the record


area associated with file-name is no long~r available. The unsuccessful
execution of such a CLOSE statement leaves the availability of the
record area undefined.

198
THE DELETE STATEMENT

Function

The DELETE statement logically removes a record fro~ a file.


r- 1

General Format

DELETE file-name RECORD [; INVALID KEY imperative-statement]

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).

2. For files in the sequential access mode, the last input-output


statement executed for file-name prior to the execution of the DELETE
statement must have been a successfully executed READ statement. The
record that was accessed by that READ statement is logically removed
from the file.

3. For a file in random or dynamic access mode, the record identified by


the contents of the record key data item associated with file-name is
logicaJ.ly removed from the file. If the file does not contain the
record npecified by the key, an INVALID KEY condition exists. (See THE
INVALID KEY CONDITION in this Chapter).

4. After the successful execution of a DELETE statement, the identified


record has been logically removed from the file and can no longer be
accessed.

5. The execution of a DELETE statement does not affect the contents of the
record area associated with file-name.

6. The current record pointer is not affected by the execution of a DELETE


~ statement.
I

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

The OPEN statement initiates the processing of files. It also performs


checking and/or writing of labels and other input-output operations.

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

1. The successful execution of the OPEN statement determines the


availability of the file and results in the file being in an open mode.

2. The successful execution of the OPEN statement makes the associated


record area available to the program.

3. Prior to the successful execution of an OPEN statement for a given


file, no statement can be executed that references that file, either
explicitly or implicitly.

4. An OPEN statement must be successfully executed prior to the execution


of any of the permissible input-output statements. In Table 7-1,
Permissible Statements, 'X' at an intersection indicates that the
specified statement, used in the access mode given for that row, may be
used with the indexed file organisation and the open mode given at the
top of the column.

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.

7. The assigned name in the select statement for a file is processed as


follows:

a. When the INPUT phrase is specified , the execution of the OPEN


statement causes the assigned name to be checked in accordance
with the operating system conventions for opening files for input.

b. When the OUTPUT phrase is specified, the execution of the OPEN


statement causes the assigned name to be written in accordance
with the opera ting system conventions for opening files for
output.

8. The file description entry for file-name-! , file-name-2, file-name-S,


or file-n ame-6 must be equivalent to that used when this file was
created.

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

THE READ STATEMENT

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

READ file-name [NEXT] RECORD [INTO identifier)

[;AT END imperative-statement]

Format

READ file-name RECORD [ INTO identifier

[;INVALID KEY imperative-statement]

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.

3. Format 2 is used for files in random access mode or for files in


dynamic access mode when records are to be retrieved randomly.

4. The NEXT. phrase must be specified for files in dynamic access mode,
when records are to be retrieved sequentially.

5. The INVALID KEY phrase or the AT END phrase must be specified if no


applicable USE procedure is specified for file-name.

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).

2. The record to be made available by a Format 1 READ statement is


determined as follows:
a. The record, pointed to by the current record pointer, is made
available provided that the current record pointer was positioned

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.

b. If tne current record pointer was positioned by the execution of a


previous READ statement, the current record pointer is updated to
point to the next existing record in the file in key sequence and
then that record is 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).

4. Regardless of the method used to overlap access time with processing


time, the concept of the READ statement is unchanged in that a record
is available to the object l'rogram prior to the execution of any
statement following the READ statement.

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.

8. If, at the time of execution of a Format 1 READ statement, the position


of current record pointer for that file is undefined, the execution of
that READ statement is unsuccessful.

9. If, at the time of the execution of a Format 1 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 in this Chapter). ---

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,

When the AT END condition occurs, execution of the input-output


statement which caused the condition is unsuccessful.

11. Following the unsuccessful execution of any READ statement, the


contents of the associated record area and the position of the current
record pointer are undefined.

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:

a. A successful CLOSE statement followed by the execution of a


successful OPEN statement for that .file.

b. A successful START statement for that file.

c. A successful For~t 2 READ statement for that file.

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

The REWRITE statement logically replaces a record existing in a mass


storage file.

General Format

~record-name [!'ROM identifier] [; ~KEY imperative-statement]

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.

3. The number of character positions in the record refere~ced by


record-name must be equal to the number of character positions in the
record being replaced.

4. The logical record released by a successful execution of the REWRITE


statetnent is no longer available in the record area.

5. The execution of a REWRITE statement with the FRCN phrase is equivalent


to the execution of:

MOVE identifier TO record-name

followed by the execution of the same REWRITE statement without the


FROM phrase. The contents of the record area prior to the execution of
the 1mplic1.t MOVE statement have no effect on the execution of the
REWRITE statement.

6. The current record pointer is not affected by the execution of a


REWRITE 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).

8. For a file in the sequential access mode, the record to be replaced is


specified by the value contained in the record key. When the REWRITE
statement is executed the value contained in the record key data item
of the record to be replaced must be equal to the value of the record
key of the last record read from this file.

9. For a file in the random or dynamic access mode, the record to be


replaced is specified by the record key data item.

10. The INVALID KEY condition exists when:

a. The access mode is sequential and the value contained in the


record key data item of the record to be replaced is not equal to
the value of the record key of the last record read from this file
or,

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-<-

[;INVALID KEY imperative-statement]

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

l. File-name must be the name of an indexed file.

2. File-name must be the name of a file with sequential or dynamic access.

3. The INVALID KEY phrase must be specified if no applicable USE procedure


is specified for file-name.

4. If file-name is the name of an indexed file, and i f a KEY phrase is


specified, data-name may reference a data item specified as the record
key associated with file-name, or it may reference any data item of
category alpanumeric subordinate to the data-name of a data item
specified as the record key associated with file-name whose leftmost
character position corresponds to the leftmost character position of
that record key data item.

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).

2. If the KEY phrase is not specified, 'IS EQUAL TO' is implied.

3. The type of comparison specified by the relational operator in the KEY


phrase occurs between a key associated with a record in the file
referenced by file-name and a data item as specified in general rul~ 5.
If file-name references an indexed file and the operands are of unequal
size, comparison proceeds as though the longer one were truncated on
the right such that its length is equal to that of the shorter. All
other nonnumeric comparison rules apply except that the presence of the
PROGRAM COLLATING SEQUENCE clause will have no effect <>n the
comparison. (See Comparison of Nonnumeric Operands).

208
a. The current record pointer is positioned to the first logical
record currently existing in the file whose key satisfies the
comparison.

b. If the comparison is not satisfied by any record in the f11.e, an


r-- 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)

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).

5. If the KEY phras<> is specified, the comparison described in general


r- rule 3 uses the data ltem referenced by data-name.

6. If the KEY phrase is not specified, the comparison described in general


rule 3 uses ti1e data item referenced in the RECORD KEY clause

r-- associated with file-name.

,...
r-
r-"

r-
r-
~

r-
r-
r- 209

~
THE USE STATDIENT

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

l
file-name-ll
EXCEPTION 1 INP!IT
USE AFTER STANDARD
----- l ~I PROCEDURE ON ~~Pur

Syntax Rules

l. A USE statement, when present, must immediately follow a section header


in the declaratives section and must be followed by a period followed
by a space. The remainder of the section must consist of zero, one or
more procedural paragraphs that define the procedures to be used.

2. The USE statement itself is never executed; i t merely defines the


conditions calling for the execution of the USE procedures.

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.

2. After execution of a USE procedure, control is returned to the invoking


routine.

3. Within a USE procedure, there must not be any reference to any


nondeclarative 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 excecution of any


statement that would cause the execution of a USE procedure that had
previously been invoked and had not yet returned control to the
invoking routine.

210
THE WRITE STATEMENT

Function

TJ,e WRITE statement releases a logical record for an output or


input-output file.

General Format

W'l.ITE record-name [FROM identifier]~ INVALID KEY imperative-statement]

Syntax Rules

l. Record-name and identifier must not reference the same storage area.

2. The record-name is the name of a logical record in the File Section of


the Data Division.

3. The INVALID KEY phrase must be specified if an applicable USE procedure


is not specified for the associated file.

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).

2. The logical record released by the execution of the WRITE statement is


no longer available in the record area unless the execution of the
WRITE statement is unsuccessful due to an INVALID KEY condition.

3. The results of the "xecution of the WRITE statement with the FROM
phrase is equivalent tn the execution of:

a. The statement:

MOVE identifier TO record-name

according to the rules specified for the MOVE statement, followed

r b.
by:

The same WRITE statement without the FROM phrase.

The contents of the record area prior t0 the execution of the


implicit MOVE statement have no effect on the execution of this
I<RITE statement.

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).

"0 The current record pointer is unaffected by the execution of a WRITE


statement.

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.

7 0 The number of character positions on a mass storage device required to


store a logical record in a file may or may not be equal to the number
of character positions defined by the logical description of that
record in the.program.

B. The execution of the WRITE statement releases a logical record to the


operating system.

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.

13. If random or dynamic access mode is specified, records may be released


to the Operating System in any program-specified order.

14. The INVALID KCY condition exists under the following circumstances:

a. When sequential access mode is specified for a file opened in the


output mode, and the value of the record key is not greater than
the value of the record key of the previous record, or

..,,
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

c. When an attempt is made to write beyond the externally defined


boundaries of the file.

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

INTRODUCTION TO THE SEG!ENTATION MODULE

The Segmentation module provides a capabil~ty to specify object program


overlay requirements.

Segmentation provides a facility for specifying permanent and


independent segments. All sections with the :;ame segment-number must be
contiguous in the source program. All segments specified as permanent
segments must be conti~uous in the source progTam.

GENERAL DESCRII'riON OF SEQIENTAIION

COBOL segmentation is a facility that provides a means by which the


user may communicate with the compiler to specify object program overlay
requirements.

COBOL segmentation deals only with segmentation of procedures. As


such, only the Procedure Division is considered in determining segmentation
requirements for an object program.

ORGANIZATION

Program Segments

Although it is not mandatory, the Procedure Division for a source


program is usually written as a consecutive group of sections, each of which
is composed of a series of closely related operations that are designed to
collectively perform a particular function. However, when segmentation is
used, the entire Procedure Division must be in sections. In addition, each
section must be classified as belonging either to the fixed portion or to
one of the independent segments of the object program.

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.

A fixed permanent segment is a segment in the fixed portion which


cannot be overlaid by any other part of the program.

Ir.dependent Segments

An independent segment is defined as part of the object program which


can overlay, and can be overlaid by another independent segment. An
independent segment is in its initial state whenever control is transferred
(either implicitly or explicitly) to that segment for the first time during
the execution of a program. On subsequent transfers of control to the
s~gment, an indepe~de~t segment is also in its initial state when:

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.

2. Control is transferred explicitly to that segment from a segment with a


different segment-number (with the exception noted in paragraph 2
below).

On subsequent transfer of control to the segment, an independent


segment is in its last-used state when:

1. Control is transferred implicitly to that segment from a s~gment with a


different segment-number (except as noted in paragraphJ),

2. Control is transferred explicitly to that segment as the result of the


execution of an EXIT fROGlAM statement.

SEGMENTATION CLASSIFICATION

Sections which are to be segmented are classified, using a system of


segment-numbers and the foHowing criteria:

1. Logic Requirements - Sections which must be available for reference at


all times, or which are referred to very frequently, are normally
classified as belonging to one of the permanent segments; sections
which are used less frequently are normally classified as belonging to
one of the independent segments, depending on logic requirements.

2. Frequency of Use - Generally, the more frequently a section is referred


to, the lower its segment-number, the less frequently it is referred
to, the higher its segment-number,

3. Relationship to Other Sections - Sections which frequently communicate


with one another should be given the same segment-numbers

SEGMENTATION CONTROL

The logical sequence of the program is the same as the physical


sequence except for specific transfers of control. Control may be
transferred within a source program to any paragraph in a section; that ts,
tt is not mandatory to transfer control to the beginning of a section.

215
STRUCTURE OF PROGRAM SEGMENTS

SEGMENT-NUMBERS

Section classification is accomplished by means of a system of


segment-numbers. The segment-number is included in the section header.

GENERAL FORMAT

section-name SECTION [segment-number]

SYNTAX RULES

1. The segment-number must be an integer ranging in value from 0 through


gg,

2. If the segment-number is omitted from the section header, the


segment-number is assumed to be 0.

3. Sections in the declaratives must contain segment-numbers less than 50.

GENERAL RULES

l. All sections which have the same segment-number constitute a program


segment. All sections which have the same segment-number must be
together in the source program.

2. Segments with segment-number 0 through 49 belong to the fixed portion


of the object program. All sections with segment-number 0 through 49
must be together in the source program.

3. Segments with segment-number 50 through 99 are independent segments.

~:

216
REStRICTIONS ON PROGtAM FLOW

When segmentation is used, the following restrictions are placed on the


ALTER and PERFORM statement.

THE ALTER STATmENT

A GO TO statement in a section whose segment-number is greater than or


equal to 50 must not be referred to by an ALTER statement in a section with
a different segment-number.

THE PERFORM STATEMENT

A PERFORM statement that appears in a section that is not in an


independent segment can have within its range, in addition to any
declarative sections whose execution is caused within that range, only one
of the following:

Sections and/or paragraphs wholly contained in one or more


non-independent segments.
Sections and/or paragraph wholly contained in a single independent
segment.

A PERFORM statement that appears in an independent segment can have


within its range, in addition to any declarative sections whose execution is
caused within that range, only one of the following:

a. Sections and/or paragraphs wholly contained in one or more


non-independent segments.

b. Sections and/or paragraphs wholly contained in the same


independent segment as that PERFORM statement.

217
II '1: e 8 Jie£ and
~ilillili~_.IIID E:ilbE .RiJ "t.l:f;;

'"

218
CHAPTER 9

LIBRARY

INTRODUCTION TO THE LIBRARY MODULE

The Library module provides a capability for specifying text that is to


be copied from a source user-library file. This is usually created using
any suitable source text editcr.

CIS COBOL libraries consist of disk files that contain source to be


made available to the compl ler. The effect of the interpretation of the
COPY statement is to insert text into the source program, where it will be
treated by the compiler as part of the source program.

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

l. Text-name defines a unique external file name which conforms to the


rules for COBOL user-defined words. In a text~name -lower case is
upper _: · Ill?'' an
alj)hBDiJ!~<t~: :l'l~ter•l tJt>e~at:tng

2. The COPY statement must be preceded by a space and terminated by the


separator period.

3. A COPY statement may occur in the source program anywhere a


character-string or a separator may occur except that a COPY statement
must not occur within a COPY statement.

GENERAL RULES

1. The compilation of a source program containing COPY statement is


logically equivalent to processing all COPY statements prior to the
processing of the resulting source program.

2. The effect of processing a COPY statement is that the library text


associated with text-name is copied into the source program, logically
replacing the entire COPY statement, beginning with the reserved word
COPY and ending with the punctuation character period, inclusive.

3. The library text is copied unchanged.

4.

5. The text produced as a result of the complete processing of a COPY


statement must not contain a COPY statement.

220
CHAPTER 10

DEBUG AND INTERACTIVE DEBUGGING

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.

T,he ClS ' COBoL B.un'-Time Deliu$ Packag!!t J.s :!In


provide• break-point fadl ttiea 1~, ttle )tser'S. 1ir9~rllla. tl:T~oar•
frlllll the, start untU a specUied , br•ea,t-'po:I.Jlt
ps.Seed bae'k to the user. c At this
cliange~,, ''i~

STANDARD ANSI COBOL DEBUG

The decisions of what to monitor and what information to display are


explicitly in the domain of the user. The COBOL Debug facility simply
provides a convenient access to pertinent information.

The features of the language that support the COBOL Debug module are:

* A compile time switch -- WITH DEBUGGING MODE.

* An object time switch.


J'llllllll
i
* A USE FOR DEBUGGING statement.

* A special register -- DEBUG-ITEM.

* 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

The DEBUGGING MODE clause is written as p«rt of the SOURCE-COMPUTER


paragraph in the Environment Division. It serves as a compile-time switch
over debugging statements written in the program.

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.

COBOL DEBUG OBJECT TIME SWITCH

An object time switch dynamically activates the debugging code inserted by


the c.oMpil<=c. Thi.s switch cannot De addressed in the program; it is
controlled outside the COBOL environment. If the switch is 'on', the
effects of any USE FOR DEBUGGING statements written in the source program
are permitted. If the switch is 'off', all the effects described in the USE
FOR DEBUGGING Statement, are inhibited. Recompilation of the source program
is not required to provide or take away this facility.

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.

The switch is described in the CIS COBOL Operating Guide.

llNVIRONME~r DIVISION IN COBOL DEBUG

The WITH DEBUGGING MODE Clause

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

SOURCE-COMPUTER. computer-name (WITH DEBUGGING MODE) .

General Rules

l. If the WITH DEBUGGING MODE clause is specified in the SOURCE-COMPUTER


paragraph of the Configuration Section, of a program, all USE FOR
DEBUGGING statements and all debugging lines are compiled.

2. If the WITH DEBUGGING MODE clause is not specified in the


SOURCE-C<l1PUTER paragraph of the Configuration Section of a program,
any USE FOR DEBUGGI~G statements and all associated debugging sections,
and any debugging lines are compiled as if they were comment lines.

222
PROCEDURE DIVISION IN COBOL DEBUG

The USE FOR DEBUGGING Statement

Function

The USE FOR DEBUGGING statement identifies the user items that are to be
monitored by the associated debugging section.

General Format

section-name SECTION [segment number].

USE FOR DEBUGGING ON { procedure-name- 1}


- ~ PKOCEDURES

procedure-name-2]
[ 'ALL PROCEDURES •••
Syntax Rules

1. Debugging section(s), i f specified, must appear together immediately


after the DECLARATIVES header.

2. Except in the USE FOR DEBUGGING statement itself, there must be no


reference to any non-declarative procedure within the debugging
section.

3. Statements appearing outside of the set of debugging sections must not


reference procedure-names defined within the set of debugging sections.

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.

5. Procedure-names defined within debugging sections must not appear


within USE J'OR DEBUGGING statements .

6. Any given procedure-name may appear in only one USE FOR DEBUGGING
statement and may appear only once in that statement.

7. The ALL PKOCEDURES phrase can appear only once in a program.

8. When the ALL PROCEDURES phrase is specified, procedure-name-1,


procedure-name-2, ••• must not be specified in any USE FOR DEBUGGING
statement.

9. References to the special register DEBUG-ITEM are restricted to


references from within a debugging saction.

General Rules

1. In the following general rules all references to procedure-name-1,


apply equally to procedure-name-2.

223
2. Automatic execution of a debugging section is not caused by a statem~nt
appearing in a debugging section.

3. When procedure-name-! is specified in a USE FOR DEBUGGING statement iiiMi


I
that debugging section is executed:

a. Immediately before each execution of the named procedure;

b. Immediately after the execution of an ALTER statement which


references procedure-name-!.

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 .

5. The associated debugging section is not executed.for a sp~cific op~rand


more than once as a result of the execution of a single statement,
regardless of the number of times that operand is explicitly specified.
In the case of a PERFORM statement which caused iterative execution of
a referenced procedure, the associated debugging section is execut~d
once for each iteration.

Within an imperative statement, each individual occurrence of an


imperative verb identifies a separate statem~nt for the purpose of
debugging.

6. A reference to procedure-name-! as a qualifier does not constitute


reference to that item for the debugging described in the general rules
above.

7. Associated with each execution of a debugging section is the special


register DEBUG-ITEM, which provides information about the conditions
that caused the execution of a debugging section. DEBUG-ITEM has the
following implicit description:

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.

Updating is accomplished in accordance with the rules for the MOVE


statement, the so!e exception being the move to DEBUG-cONTENTS when the
1110ve is treated exactly as if it was an alphanumeric to alphanumeric
elementary move with no conversion of data from one form of internal
representation to another.

9. The contents of DEBUG-LINE is the relevant COBOL source line number.


This provides the means of identifying a particular source statement.

10. DEBUG-NAME contains the first 30 characters of the name that caused the
debugging section to be executed.

Subscripts/indices, if any, are ~nt entered into DEBUG-N~~.

11. DEBUG-cONTENTS is a data item that is large enough to contain the data
required by the following general rules.

12. If the first execution of the first nondeclarative procedure in the


program causes the debugging sEction to be executed, the following
conditions exist:

a. DEBUG-LINE identifies the first statement of that procedure.


b. DEBUG-NAME contains the name of that procedure.
c. DEBUG-CONTENTS contains 'START PROGRAM'.

13. If a reference to procedure-name-1 in an ALTER statement causes the


debugging section to be executed, the following conditions exist:

a. DEBUG-LINE identifies the ALTER statement that references


procedure-name-1.
b. DEBUG-NAME contains procedure-n~me-1.
c. DEBUG-CONTENTS contains the applicable procedure-name associated
with the TO phrase of the ALTER statement.

14. If the transfer of control associated with the execution of a GO TO


statement causes the debugging section to be executed, the following
conditions exist:

a. DEBUG-LINE identifies the GO TO statement whose execution


transfers cor.trol to procedure-name-1.
I
~
b. DEBUG-NAME contains procedure-name-1.

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
~-

a. DEBUG-LINE identifies the PERFORM statement that references


procedure-name 1.

b. DEBUG-NAME contains procedure-name-!.

c. DEBUG-CONTENTS contains 'PERFORM LOOP'.

16. If procedure-name-! is a USE procedure that is to be executed, the


following conditions exist:

a. DEBUG-LINE identifies the statement that causes execution of the


USE procedure.

b. DEBUG-NAME contains procedure-name-!.

c. DEBUG-CONTENTS contains 'USE PROCEDURE'.

17. If an implicit transfer of control from the previous sequential


paragraph to procedure-name-! causes the debugging section to be
executed, the following conditions exist:

a. DEBUG-LINE identifies the previous statement.

b. DEBUG-NAME contains procedure-name-!.

c. DEBUG-CONTENTS contains 'FALL THROUGH'.

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.

The contents of a debugging line must be such that a syntactically correct


program is formed with or without the debugging lines being considered as
comment lines.

A debugging line will be considered to have all the characteristics of a


comment line, if the WITH DEBUGGING MODE clause is not specified in the
SOURCE-COMPUTER paragraph.

Successive debugging lines are allowed. Continuation of debugging lines is


permitted, except that each continuation line must contain a 'D' in the
indicator area, and character-strings may not be broken across two lines.

A debugging line is only permitted in the program after the OBJECT-COMPUTER


paragraph.

226
CHAPTER 11

INTER!'ROGl.AM CCMMUNICATION

INTRODUCTION TO THE INTE'{-·!'ROG!.AM COMMUNICATION MODULE

The Inter-Program Communication module provides a facility by which a


program can communicate with one or more programs. This provides a
programmer with a modular programming capability. Each module when CALLed
is loaded dynamicall)' by the Run Time System. Communication is provided by:

* The ability to transfer control from one program to another within


~ ru.G uuit

The ability for both programs to have access to the same data
items.

DATA DIVIS ION IN THE INTER-!'ROG!.AM COMMUNICATION MODULE

LINKAGE SECTION

The Linkage Section in a program is meaningful i f and only if the obj~ct


program is to function under the control of a CALL statement, and the CALL
~
I
statement in the calling program contains a USING phrase.

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.

The structure of the Linkage Section is the same as that previously


d.cscribed for the Working-Storage Section, beginning with a section header,
followed by data description entries for noncontiguous data items and/or
record description entries.

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.

Of those items defined in the Linkage Section only data-name-1, data-name-2,


in the USING phrase of the Procedure Divi:n<.n header, data items
subocdinate to these data-names, and condition-names and/or

227
index-names associated with such data-names and/or subordinate data items,
may be referenced in the Procedure Division.

Noncontiguous Linkage Storage

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-·

E'ROCEDURE DIVISION IN THE INTEK-PROffiAM CCMMUNICATION ~LODULE

THE E'ROCEDURE DIVISION HEADER

The PrccP.dure Division is identified by and must begin with the following
header:

E'ROCEDURE DIVISION [USING data-nane-1 [, data-name-2] ••• ]

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.

When ~he USING phrase is present, the object program operates as if


data-name-1 of the Procedure Division header in the called program and
data-name-1 in the USING phrase of the CALL statement in the calling program
refer to a single set of data that is equally available to both the called
and calling programs. Their descriptions must define an equal number of
character positions; however they need not be the same name. In like
manner, there is an equivalent relationship between data-name-2, ••• , in the
USING phrase of the called program and data-name-2, ••• , in the USING phrase
of the CALL statement in the calling program. A data-name must not appear
more than once in the USING phrase in the Procedure Division header of the
called program; however, a given data-name may appear more than once in the
same USING phrase of a CALL statement.

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] ••• )

[ON OVERFLOW imperative-statement)

Format 2

Syntax Rules

1. Literal-1 must be a nonnumeric literal.

2. Identifier-1 must be defined as an alphanumeric data item usage


display.

3. The USING phrase is included in the CALL statement only if there is a


USING phrase in the Procedure Division header of the called program and
the number of operands in each USING phrase must be identical.

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

1. The program whose name is specified by the value of literal-1 or


identifier-! is a called intermediate code module, literal-2 is a
called run time subroutine; the program in which the CALL statement
appears is the calling program.

2. The execution of a CALL statement causes control to pass to the called


program.

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
.. ~ :.

5. If during the execution of a CALL statement, it is determined that the


available portion of run-time memory is incapable of accomodating the
program specified in the CALL statement, the next sequential
instruction is executed. If ON OVERFLOW has been specified, the
c1b~u\:.id.i..~U i.anp~cativt:! statement 1s executed betore the next instruction
is executed.

6. Called programs may contain CALL statements. However, a called program


must not contain a call statement that directly or indirectly calls the
calling program.

7. The data-names, specified by the USING phrase of the CALL statement,


indicate those data items available to a calling program that may be
referred to in the called program. The order of appearance of the
data-names in the USING phrase of the CALL statement and the USING
phrase in the Procedure Division header is critical. Corresponding
data-names refer to a single set of data which is available to the
called and calling program. The correspondence is positional, not by
name. In the case of index-names, no such correspondence is
established. Index-names in the called and calling program always
refer to separate indices.

8. The CALL statement may appear anywhere within a segmented program.


Therefore, when a CALL statement appears in a section with a
segment-number greater than or equal to SO, that segment is in its last
used state when the EXIT PROGRAM statement returns control to the
calling program.

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

1. Literal-!, literal-2, ••• ,must each be a nonnumeric literal.

2. Identifier-!, identifier-2, must each be defined as an


alphanumeric data item such that its value can be a program name.

General Rules

1. After the execution of a CANCEL statement, the program referred to


ceases to have any logical relationship to the run unit in which the
CANCEL statement appears. A subsequently executed CALL statement
naming the same program will result in that program being initiated in
its initial state. The memory areas associated with the named programs
are released so as to be made available for disposition by the
operating system.

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.

3. A logical relationship to a cancelled subprogram is established only by


execution of a subsequent call statement.

4. A called program is cancelled either by being referred to as the


operand of a CANCEL statement or by the termination of the run unit of
which the program is a member.

5. No action is taken when a CANCEL statement is executed naming a program


that has not been called in this run unit or has been called and is at
present cancelled. Control passes to the next 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

1. The EXIT PROGI.AM statement must appear in a sentence by itself.

2. The EXIT PROGRN1 sentence must be the only sentence in the paragraph.

General Rule

An execution of an EXIT PROGI.AM statement in a called program causes control


to be passed to the calling program. Execution of an EXIT PROGR~~ statement
in a program which ts not called behaves as if the statement were an EXIT
statement. (See THE EXIT STATEME)IT in Chapter 3) .

Fi!NI
!

-~

233
CHAPTER 12

PROGRAMMING TECHNIQUES, USEFUL HINTS AND PROGRAM SIZING

PROGRAMMING TECHNIQUES

Although COBOL is written in an essentially free fot11l, the user will


nevertheless obtain many advantages from a few self-imposed disciplines. It
is suggested that these should include the following:

1. Use of the first 256 bytes of working-storage for variables which are
freque;1tly referenced will produce more compact and efficient code.

2. Use subscripts as sparingly as possible because each subscript has a


storage requirement approximately equal to the size of a normal
ins·t ruction.

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.

4. Use FILLER instead of a data-name for any elementary field not


referenced explicitly because the word FILLER is compacted to one
character in the Data Dictionary.

5. Keep the number of digits in numeric fields as small as possible.

6. Whenever possible move a group instead of several elementary moves.

7. CIS COBOL provides for values greater than decimal 99 to be stored in a


nonnumeric field of one character,
e.g, PIC X "7F"

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.

If your operating system returns an error number greater than 99 in the


error Status Key Z byte ( see I-o Status in chapters 5,6 and 7 ) careful
redefinition of data-items is required if you wish to display this status
with its correct decimal value. See the appendix that describes disk files
in your operating system specific CIS COBOL Operating Guide for a sample
program.

USEFUL HINTS

When writing interactive programs the following facilities of CIS COBOL


should be remembered:

1. By use of the CURSOR IS facility and the ACCEPT statement it is easy to


program conditionally depending on the cursor position after a menu
type of prompt. The operator need then only move thP cursor to the
option required to reply to the prompt, or just press RETURN in the
default case.
234
2. By use of the ACCEPT FROM CONSOLE facility it is easy to pass
par.tmeters to your program via the Run conunand line. See ·THE ACCEPT
STATEMENT in Chapter 3.

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).

s. Never define a Linkage Section in the main pro~ram, onlv in sub-


programs. The CIS COBOL Compiler will not treat such a Linkage Section
as ~n error but it can result in memory content corruption at run time.

6. Be careful to specify literal filenames in Select statements


in quotation marks (" .••• "). This is the only indication to the
compiler that a literal filename is desired.

(Filename identifiers are not declared in the Working Storage Section


or elsewhere explicitly). The omission of quotation marks where
required will result in an undefined file being accessed at run time.

r-

r:
r-
r-
r- 235

r-
~.

Table 12-1. Data Dictionary Entry Sizing

User-defined name Number of Bytes


File-name 18 + n
kecord-name 8 + n
Key-name 8 + n
Status-name 8 + n
Paragraph-name 6 + n
Data-name Group 2
8 + n
Alphanumeric < 32 characters 7 + n
2
Alphanumeric ? 32 characters 2
8 + n
Numeric inteRer 7 + n
2
Numeric non integer l
8 + n
Numeric edited 7 + n + x

n a number of characters in user-defined name.

For a FILLER, n = 1.

x • number of characters in PICture, after coalescing repetitions.

e.g. 9 9 9 9 9 = 3 bytes
9 (4) 9 a 3 bytes
Z (2) 9 (4) • 9 (3)= 4 bytes

2 Subtra~t 1 byte if item is in the first 256 bytes of


Working-Storage.

Add 4 bytes if item has an OCCUltS clause associated with it.

Add 2 bytes if item is subordinate to an item described with


OCCURS.

236
APPENDIX A

RESERVED WORD LIST

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

CHARACTER SETS AND COLLATING SEQUENCE

ASCII HEX COBOL ASCII liEX COBOL ASCII HEX COBOL


NUL 00 X I 2F 5E X
SOH 01 X 0 30 5F X
STX 0~ X 1 31 6~ X
£TX 03 X 2 32 a 61
EOT 04 X 3 33 b 62
E~~ 1!)5 I I
X 4 34 c 63
ACK I !
BEL
B$
06
07
08
I
X

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.

These definitions are also intended to be either reference material or


introductory material to be reviewed prior to reading the detailed language
specifications that are contained in this manu"ll. For this reason, these
definitions are, in most instances, brief and do not include detailed
syntactical rules.

DEFINITIONS

Access fude. The manner in which records are to be operated upon within a
file

Actual Decimal Point. The physical representation, using either of the


decimal point characters • (period} or , (comma} of the decimal
point position in a data item.

Alphabet-Name. A user-defined word in the SPECIAL-NAMES paragraph of the


EnvironmP.nt Division that assigns a name to a specific character
set and/or collating sequence.

Alphabetic Character. A character that belongs to the following set. of


letters: A ,B ,C,D,E ,F ,G,H ,I ,J ,~ ,~ ,M ,N ,0 ,P ,Q,R ,S ,T ,U ,V ,~ ,X,Y ,Z . and

~~~·· ·.-~:~.~.-·wil~~a::~ ~~~~;·~~!~~;ic!~~~~-:~~;·:~;~~:e;i:;;;~f; ;: !;:t~.


Abhanumeric Character. Any character in the computer's character set.

Arithmetic Expression. An arithmetic expression can be an identifier or a


numeric elementary item, a nwneric literal, such identifiers and
literals separated by arithmetic operators, two arithmetic
expressions separated by an arithmetic operator, or an arithmetic
expression enclosed in parentheses.

Arithmetic Operator. A single character, or a fixed two-character combin-


ation, that. belongs to the following set:
Character Meaning
+ Addition
Subtraction
* Multiplication
Division

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.

At End Condition. A condition caused in one of two circumstances:

1. During the execution of a READ statement for a sequentially


accessed file.
2. During the execution of a RETURN statement when no next
logical record exists for the associated sort or merge file.

Called Program. A program which is the object of a CALL statement combined


at run time with the calling program to produce a run unit.

Calling Program. A program which executes a CALL to another program.

Character. The basic indivisible unit of the language.

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

Character Position. A character position is the amount of physical storage


required to store a single standard data format character
described as usage in DISPLAY. Further characteristics of the
physical storage are defined by the implementor.

Character-String. A sequence of contiguous characters which for111 a


CIS COBOL word, a literal, a PICTURE character-string or a
comment-entry.

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.

Collating Sequence. The sequence in which the characters that are


acceptable in a computer are ordered for purposes of sorting,
merging and or comparing.

~· A character position within a print line. The columns are


numbered from one, by one, starting at the left-most character
position of the print line and extending to the right-<Dost
character position of the print line.

Comment Entry. An entry in the Identification Division tliat may be any


combination of characters from the computer character set.

Comment Line. A source program line represented by an asterisk in the


indicator area of the line and any characters from the computer's
character set in area A and area B of that line. The comment line
serves only for documentation in a program. A special form of
comment line represented by a stroke (/) in the indicator area of
the line and any characters from the computer's character set in
area A and area B of that line causes page ejection before
printing the comment.

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.

Compiler-Directing Statement. A statement, beginning with a


compiler-directing verb, that causes the compiler to take a
specific action during compilation.

Computer-Name. A system-name that identifies the computer upon which the


program is to be compiled or run.

Condition. A status of a program at execution time for which a truth value


can be determined. Where the term "condition" (condition-1,
condition-2, ••• ) appears in these language specifications in or 1n
reference to "condition" (condition-1, condition-2, ••• ) of a
general format, it is a conditional expression consisting of
either a simple condition optionally parenthesised, or a negated
simple condition.

Condition-Name. The user-defined word assigned to a status of an


implementor-defined switch or device.

Conditional Expression. A simple condition specified in an IF, or PERFORM.


(See Simple Condition and Complex Condition.)

Conditional Statement. A conditional statement specifies that the truth


value of a condition is to be determined, and that the subsequent
action of the run-time program is dependent on this truth value.

Configuration Section. A section of tne Environment Division tnat describes


overall specifications of source and run computers.

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.)

Contiguous Items. Items that a r e described by consec utive entries in


the Data Division , and that bea r a definite hierarchic
relationship to one another .

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.

CRT . An interactive input / ouq)ui: ., device compri~ing


and a keyboar<l by which an , Operator
data .

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 .

Current Record. The r eco rd which is available in th e record area associated


with the file .

Curren t Record Po int er . A conceptual entity that is used in the selec tion
of the next r eco rd.

The indicator on a GRT · screen that marks th~ r{t~


7

position which the input{output cori,t .r ol is curr<;.nt:,ly


--~~.:X~ '*'·#©
Da t a Clause. A clause that appears in a da t a descrip tion en t ry in the Data
Di visio n and provides information describ ing a particular
a ttribut e of a da t a item.

Data Description En tr y . An en tr y i n the Da t a Division that is composed of a


l evel -numbe r followed by a data- name , i f requir ed, and then
fol l owed by a set of data c l auses as required.

Da t a Dictionary. A dicti ona r y file of user def in ed names constructed by the


Compiler containing the number of bytes for each entry .

Da t a Item. A c·haracter or se t of con t iguous charac t ers (excluding in ei ther


case literals) defi ned as a unit of data by the CIS COBOL prog r am .

Data - name . A user-defined word that names a data item described in a da t a


description entry in t he Data Division . When used in the general
formats , "data - name " rep r esents a wo r d tvhich can ne it her be
subscripted , no r indexed unle s s specifically permitted ty the
rules for that forma t.

24 7
Debugging Line. A debugging line is any line w1 th "D" in the indicator area
of the line.

Declaratives. A set of one or more special purpose sections written at the


beginning of the Procedure Division, the first of which is
preceded by the key word DECLARATIVES and the last of which is
followed by the key words END DECLARATIVES. A declarative is
composed of a section header, followed by a USE compiler directing
sequence, followed by a set of associated paragraphs (0 or more).

Declarative-Sentence. A compiler-directing sentence consisting of a single


USE statement terminated by the separator period (.).

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

Digit Position. A digit position is the amount of physical storage


required to store a single digit. This amount varies depending on
the usage of the data item describing the digit position. Further
charactersitics of the physical storage are defined by the
implementor.

Division. A set of sections or paragraphs (0 or more) that are formed and ~


combined in accordance with a specific set of rules is called a
division body. There are four divisions in a CIS COBOL program:
Identification, Environment, Data and Procedure.

Division Header. A combination of words followed by a period and a space


that indicate the beginning of a division. The division headers
are:
IDENTIFICATION DIVISION.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION USING data-name-1 data-name-2

Dynamic Access. An access mode in which specific logical records can be


obtained from or placed into a disk file in a non-sequential
manner (see Random Access) and obtained from a file in a
sequential manner (see Sequential Access) during the scope of the
same OPEN statement.

Editing Character. A single character or a fixed two character combination


belonging to the same set:

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)

Elementary Item. A data item that is described as not being further


logically subdivided.

End of Procedure Division. The physical position in a CIS COBOL source


program after which no further procedures appear.

~- Any descriptive set of consecutf".·a clauses terminated by a


period (.) and written in the Identification Division, Environment
Division or Data Division of an CIS COBOL source program.

Environment Clause. A clause that appears as part of an Environment


Division entry.

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.

Figurative Constant. A compiler-generated value referenced through the use


of certain reserved words.

!!_!!. A collection of records.

File Clause. A clause that appears as part of any of the following Data
Division entries:
File Description (FD)

FILE-CONTROL. The name of an Environment Division paragraph in which the


data files for a given source program are declared.

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.

File-Name. A user-defined word that names a file described in a file


description entry or a sort-merge file description entry within
the File Section of t~e Data Division.

~
~~ .. - 249
File Organization. The permanent logical file structure established at the
time that a file is created.

File Section. The section of the Data Divisionthat contains file


description entries together with their associated record
descriptions.

Format. A specific arrangement of a set of data.

Group Item. A named contiguous set of elementary or group it~ms.

High Order End. The leftmost character of a string of characters.

I-0-CONTROL. The name of an Environment Division paragraph in which object


program requirements for specific input/output techniques, rerun
points, sharing of same areas by several data files, and multiple
file storage on a single input/output device are specified.

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.

Identifier. A data-name, followed as required by the syntactically


correct combination of subscripts and indices necessary to make
unique reference to a data item.

Imperative Statement. A statement that begins with an imperative verb and


specifies an unconditional action to be taken. An imperative
statement may consist of a sequence of imperative statements.

Implementor-Name. A system-name that refers to a particular feature avail-


able on the implementors computing system.

Index. A computer storage position or register, the contents of which


represent the identification of a particular element in a table.

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.

Indexed File. A file with indexed organization.

Indexed Organization. The permanent logical file structure in which each


record is identified by the value of one or more keys within that
record.

Indicator Area. The leftmost parameter position of a CIS COBOL source


record that indicates the use of the record.

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.

Input - Output File. A file th at is opened in the I - 0 mode .

Input - Ou t put Section. The section of th e Environment Division th at names


the files and the exte rnal media used by a program and which
provides information required for transmission a nd handling of
data during exec ution of the run-time program.

Integer. A numeric literal or a numer ic dat a item that does not


include any character positions to the right of the ass umed
decimal point. l<here the t erm 'integ er ' appears in genera l
formats, integer must not be a numeric data item, and mu st not be
signe d, nor zero unless explicitly allowed by the rules of that
format.

Invalid Key Condition. A condition, at object time, caused when a specified


value of the key associated with an indexed or relative file is
determined to be invalid .

Issue Disk . The flexible diskette or which th e CIS COBOL softwa r e is


supplied to users.

A data item which identifies the location of a record , or a set of


data items which serve to id e nt ify the ordering of data .

Key of Reference. The key currently being used to access records within an
indexed file .

Key Word . A reserved word whose presen ce is required wh en the format in


which th e word appears is used in a source program.

Level - Number . A user - defined word wh i ch indicates the position of a data


item in the hierarchical s tru cture of a logical record or which
indicates special properties of a data description entry . A
level - number is expressed as a one or t wo digit number .
Level- numbers in the range l through 49 indica t e the posi ti on of a
data item in the hierarchical structure of a logical record .
Level- numb ers in th e range l through 9 may be written either as a
sing l e digit or as a zero followed by a significant d igit.
Level - number 77 identifies special properties of a data
de sc ripti on entry.

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.

Literal. A character-string whose value is implied by the ordered set of


characters comprising the string.

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.

Low Order End. The righ~ost character of a string of characters.

Mnemonic-Name. A ·Jeer-defined word that is associated in the Environment


Division with a specified implementor-name.

Native Character Set. The implementor-defined character set associated with


the cauputer specified in the OBJECi'-C<MPIJl'ER paragraph.

Native Collating Sequence. The implementor-defined collating sequence


associated with the computer specified in the OBJECT-C<MPtrrER
paragraph.

~ega ted S im.ple Condition. The 'NOT' logical operator immediately followed
by a simple condition.

Next Executable Sentence. The next sentence to which control will be


transferred after execution of the current statement is complete.

~;ext Executable Statement. The next statement to which control will be


transferred after execution of the current statement is complete.
~ext Record. The record which logically follows the current record of a
file.

Non<:ontiguous Items. Elementary data items, t.n the Working-Storage and


Linkage Sections, which bear no hierarchic relationship to other
data items.

Nonnumeric Item. A data item whose description permits its contents to be


composed of any combination of characters taken from the
computer's character set. Certain categories of nonnumeric items
may be formed from more restricted character sets.

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.

Numeric Character. A character that belongs to the following set of digits:


0, 1, 2, 3, 4, 5, 6, 7. 8, 9.

Numeric Item. A data item whose description restricts its contents to a


value represented by characters chosen from the digits 'O' through
'St; if 3~iu:al, i.hc l.i.t::m IDdY also con'tain a 1 -+:, ;_:, or other
representation of an operational sign.

NuMeric Literal. A literal caaposed of one or Mere numeric characters that


also may contain either a deciMal point, or an algebraic sign, or
both. The deciMal point MUSt not be the righanost character. The
algebraic sign, if present, Must be the lefanost character.

OBJEcr-CCMPtrrER. The name of an EnviroDIIIent Division paragraph in which the


computer environMent, lli.thin which tl:.e run-tiMe program is
executed, is described.

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.

Operand. Whereas the general definition of operand is 'that component which


is operated upon', for the purposes of this publication, any
lowercase word (or words) that appears in a statement or entry
format may be considered to be an operand and, as such, is an
implied reference to the data indicated by the operand.

Operational Sign. An algebraic sign, associated lli.th a numeric data iteM or


a nUMeric literal, to indicate whether its value is positive or
negative.

Optional Word. A reserved word that is included in a specified forMat only


to improve the readability of the language and whose presence is
optional to the user when the forMat in which the word appears is
used in a source program.

Output File. A file that is opened in either the output Mode or extend
MOde.

Output~~ode. The state of a file after execution of an OPEN statement, with


the OUTPUT or EXIEND phrase specified for that file and before the
execution of a CLOSE statement for that file.

Paragraph. In the Procedure Division, a paragraph-naMe followed by a period


and a space and optionally by one, or More sentences. In the
Identification and EnvironMent Divisions, a paragraph header
follo~d by zero, one, or More entries.

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:

In the Identification Division:

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.

Para~raph-Name. A user-defined word that identifies and begins a paragraph


in the Procedure Division.

Phrase. A phrase is an ordered set of one or more consecutive COBOL


character-strings that form a portion of a CIS COBOL procedural
statement or of a COBOL clause.

Prime Record Key. A key whose contents uniquely identify a record within an
indexed file.

Procedure. A paragraph or group of logically successive paragraphs, or a


section or group of logically successive sections, within the
Procedure Division.

Procedure-Name. A user-defined word which is used to name a paragraph or


section in the Procedure Division. It consists of a
paragraph-name or a section-name.

Punctuation Character. A character that belongs to the following set:

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.

(see Logical Record)



Record .\rea. A storage area allocated for the purpose of processing the
record described in a record description entry in the File
Section.

Record DescriPtion. (See Record Description Entry)

Record Description Entry. The total set of data description entries


associated with a particular record.

Record Key. A key, either the prime record key or an alternate record key,
whose contents identify a record within an indexed file.

Record-Name. A user-defined word that names a record described in a record


description entry in the Data Division.

Reference-Format. A format that provides a standard method for describing


COBOL source programs.

Relation. (See Relational Operator)

Relation Character. A character that belongs to the following set:

Character

> greater than


< less than
equal to

Relation Condition. The proposition, for which a truth value can be


determined, that the value of an arithmetic expression or data
item has a specified relationship to the value of another
arithmetic expression or data item. (See Relational Operator),

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:

Relational O~erator Meaning

IS NOT GREATER THAN Greater than or not greater than


IS NOT >
IS NOT LESS THAN Less than or not less than
IS NOT <
IS NOT EQUAL TO Equal to or not equal to
IS NOT

Relative File. A file with relative organization.

Relative Key. A key whose contents identify a logical record in a relative


file.

Relative Organization. The permanent logical file structure in which each


record is uniquely identified by an integer value greater than
zero, which specifies the record's logical ordinal position in the
file.

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.

Routine-Name. A user-defined word that identifies a procedure written in a


language other than COBOL

Run Unit. A set of one or more intermediate code programs which function, at
run time, as a unit to provide problem solutions.

~· A set of none, one, or more paragraphs or entries, called a


section body, the first of which is preceded by a section header.
Each section consists of the section header and the related
section body.

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.

In the Environment and Data Divisions, a section header is composed of


reserved words followed by a period and a space. The permissible section
headers are:

In the Environment Division:

CONFIGURATION SECTION
INPI!l'-Qt.i'"!PUT SECT ION

In the Data Division:

FILE SECT ION


WORKING-STORAGE SECTION
LINKAGE SECTION .

In the Procedure Division, a section header is composed of a section-name,


followed by the reserved word SECTION, followed by a segment-number
(optional) , followed by a period and a space.

Section-Name. A user-defined word which names a section in the Procedure


Division.
Segment-Number. A user-defined word which classifies sections in the
Procedure Division for purposes of segmentation. Segment-numbers
may contain only the characters '0', 1
1', ... , '9'. A
segment-number may be expressed either as a one or two digit
number, and is checked for syntax only.

Sentence. A sequence of one or more statements, the last of which is


te~inated by a period followed by a space.

Separator. A punctuation character used to delimit character-strings.

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.

Sequential File. A file with sequential organization.

Sequential Organization. The permanent logical file structure in which a


record is identified by a predecessor-successor relationship
established when the record is placed into 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
!
~-

Simple Condition. Any single condition chosen from the set:

relation condition
class condition
switch-status condition
sign condition
(simple-condition)

SOURCE-COMPUTER. The name of an Environment Division paragraph in which


the computer environment, within which the source program is
compiled, is described.

Source Program. Although i t is recognised that a source program may be


represented by other forms and symbols, in this document it always ~
refers to a syntactically correct set of COBOL statements !
oeginn1ng with an Identification Division and ending with the end
of the Procedr.re Division. In contexts where there is no danger
of ambiguity, the word 'program' alone may be used in place of the
phrase 'source program'.

Special Character. A character that belongs to the following set:

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

Special-Character Word. A reserved word which is an arithmetic operator or


a relation character.

SPECIAL-NAMES. The name of an Environment Division paragraph in which


implementor-names are related to user specified mnemonic-names.

Special Registers. Compiler generated storage areas whose prtmary use is to


store information produced in conjunction with the user of
specified COBOL features.

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.

Statement. A syntactically valid combination of words and symbols written in


the Proc~dure Division beginning with a verb.

Subprogram. (See Called Program).

Subscript. An integer whose value identifies a particular element in a


table.

Subscripted Data-N~me. An identifier that is composed of a data-name


followed by one or more subscripts enclosed in parenthesis.

Switch-Status Condition. The proposition, for which a truth value can be


determined, that an implementor-defined switch, capable of being
set to an 1 on 1 or 1 off 1 status, has been set to a specified
status.

Symbol Function. The use of specified characters in the PICTURE clause to


represent data types.

System-Name. A COBOL word which is used to communicate with the operating


environment.

Syntax. The order in which elements must be put together to form a


program.

A set of logically consecutive items of data that are defined in


the Data Division by means of the OCCURS clause.

Table Element. A data item that belongs to the set of repeated items
comprising a table.

Text-Name. A user-defined word which identifies library text.

Text-Word. Any character-string or separator, except space, in a COBOL


library or in pseudo-text.

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.

User-Defined Word. A COBOL word that must be supplied by the user to


satisfy the format of a clause or statement.

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.

~- A character-string of not more than 30 characters which forms a


user-defined word, a system-name, or a reserved word.

Working-Storage Section. The section of the Data Division that describes


working storage data items, composed either of noncontigu~us items
or of working storage records or of both.

77 Level-De~cription-Ent=z. A d,~~ description en::)· that dascrib~~ a


noncontiguous data item with the level-number 77.

~
i

260
~

r
r,
r.

r
r
r 261
APPENDIX D

COMPILE-TIME ERRORS

The error descriptions that correspond to error numbers as printed on


listings produced by the CIS COBOL compiler are as follows:

ERROR DESCRIPTION

01 Compiler Error; consult your Technical Support


Service
02 Illegal format of data-name
03 Illegal format of literal or invalid use of 'AT.T..'
04 Illegal format of character
05 Data-name declared twice
06 Too many data or procedure names have been
declared - compilation abandoned
07 Illegal character in column 7, or continuation
line error
08 Nested COPY statement or unk~own file specified
1
09 . ' missing

10 The statement starts in the wrong area of the


source line
22 'DIVISION' missing
23 'SECTION' missing
24 'IDENTIFICATION' missing
25 'PROGRAH-ID' missing
26 'AUTHOR' missing
27 'INSTALLATION' missing
28 'DATE-WRITTEN' missing
29 'SECURITY' missing
30 'ENVIRONMENT' missing
31 'CONFIGURATION' missing
32 'SOURCE-COMPUTER' missing
33 OBJECT-COMPUTER or SPECIAL-NAMES clause in error
34 'OBJECT-COMPUTER' missing
36 'SPECIAL-NAMES' missing
37 SWITCH Clause in error
38 DECIMAL-POINT Clause in error
39 CONSOLE Clause in error
40 Illegal currency symbol
42 'DIVISION' missing
43 'SECTION' missing
44 'INPUT-OUTPUT' missing
45 'FILE-CONTROL' missing
46 'ASSIGN' missing
47 'SEQUENTIAL' oc 'RELATIVE' or 'INDEXED' missing
48 'ACCESS' missing on indexed or relative file
49 'SEQUENTIAL' or 'DYNAMIC' missing

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:

FATAL I-0 ERROR: filename

where filename is the erroneous file.

Any intermediate code file produced is not usable.

The following conditions will cause this error:

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.

There are two types of ru~-t~e errors: Recoverable and Fatal.

(a) Recoverable errors

If the programmer has specified the STATUS clause in the FILE-CONTROL


paragraph of a program error handling is the programmer's responsibility.
This will generally or.ly apply to errors that are not considered fatal
by the operating system. (See File Status in Chapters 5,6 and 7)

(b) Fa~al errors

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.

(ii) I-0 errors


These exclude those for which STATUS is not selected as above.

Description

151 Random read on sequential file


152 REWRITE on file not open I-o
153 Subscript out of range
154 Perform nesting exceeds 22 levels
156 Invalid file operation
157 Object file too large
158 REWRITE on line-sequential file
159 Malformed line-sequential file
161 Illegal inteonediate code
162 Arithmetic overflow or underflow
164 Specified CALL code not supplied or
Attempt to call a COBOL module re~sively (i.e
when is already active)
165 Incompatible releases of compiler and run-time
system
168 ~lemory arrangement failure
169 Invalid indirect sequential file key length
(>32 characters)
170 Illegal operation in Indexed Sequential
171 Attempt to read I-S record in output/extend mode

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

All the syntax for CIS COBOL is summarized below.

E denotes that the feature is a CIS COBOL extension to ANSI COBOL.

D denotes that the feature is documentary only in CIS COBOL.

GENERAL FORMAT FOR IDENTIFICATION DIVISION

fiDENTIFICATION DIVISION.f

fPROGRAM-ID. program namef

[AUTHOR. [comment entry] ... ]


[INSTALLATION. [comment entry] ... ]
[DATE-WRITTEN. [comment entry] ... ]
[DATE-COMPILED. [comment entry] ... ]
[SECURITY. [comment entry] ... ]

~J

268
GENERAL FORMAT FOR ENVIRONMENT DIVISION

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

SOURCE-COMPUTER. source-computer-entry [WITH DEBUGGING MODE].

OBJECT-COMPUTER. object-computer-entry

[.MEMORY SIZE integer


I WORDS
CHARACTERS
MODULE~
!]

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

[,CURRENCY SIGN }i literal-9]

(,DECIMAL-POINT }i COMMA}

W-J:~~
E

INPUT-OUTPUT SECTION.

FILE-CONTROL.
r-
1 file-control-entry

r
r 269
[ H)-CONTROL.

T;t !!!!!!!_fOB ..l f i - 1 '


:l ~~~
f]
-
'

• . miR't - ~ t.~:88°~1~s I file-name-2

, , integer-2 CLOCK-UNITS
eondition-name

: : :[;{~~:'; ARP.A · Fofi file-ur&e~l, ·. l.,fi:l~~r--2· (. ~ .J.. ·].


GENERAL FORMAT FOR FILE-CONTROL ENTRY

Sequential SELECT:

SELECT file-name

ASSIGN TO external-file-name-literal~ ~;.[· ~sexte~nal-file~"OSme-literal~]


l file-identifier S ( lfile.-.identifier
··:.
::·:.··.·.
S

[;ORGANIZATION IS
E

[;ACCESS MODE IS SEQUENTIAL]

[;FILE STATUS IS data-name]

Relative Select:

SELECT file-name

ASSIGN TO

ORGANIZATION IS RELATIVE

[ ;ACCESS MODE IS
~ SEgUENTIAL
{RANDOM }
DYNAMIC

(;FILE STATUS IS data-name]


(,RELATIVE KEY IS data-name]
,RELATIVE KEY IS data-name
!J

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

[;FILE STATUS 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

GENERAL FORMAT FOR DATA DESCRIPTION ENTRY

level-number {data-name}
FILLER
[;REDEFINES data-name]
PICTURE} . ]
)~~M:~~:~;:~:ringl
[ {
; PIC

[
·US GE IS
, ___A___
~UTATIONAL-3l
COMP-3
DISPLAY

[ (; SIGN IS] { LEADING


TRAILING
} [SEPARATE CHARACTER]]

[ ;OCCURS integer TIMES INDEXED BY index-name-1 [, index-name-2] •.• ]

::p·~~~~~aJ.'. '":· '}:. {i~=-~J D

[ ;{ ~~~~IFIED} RIGHT ]
{;BLANK WHEN ZERO]
[;VALUE IS literal] •

272
GENERAL FORMAT FOR PROCEDURE DIVISION

Declarative format:

PROCEDURE DIVISION (usiNG data-name-1 [. data-name-2] ..• ].

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:

PROCEDURE DIVISION ( ~ data-name-1 [,data-name-2] ... ] .


{paragraph-name [sentence] ···J···
GENERAL FORMAT FOR VERBS

ACCEPT dataname-1 IAT ~~::;~~[;J-lt ~at , . E

ACCEPT identifier [FROM CONSOLE]

ADD sidentifier-1~ Sidentifier-2~ ... TO identifier [ROUNDED)


lliteral-1 S lliteral-2 S
[; ON SIZE ERROR imperative-statement]
s identifier-!~ sidentifier-2l [ sidentifier-3i]
ADD lliteral-1 S' lliteral-2 S 'lliteral-3 S • ••

GIVING identifier (ROUNDED]

[; ON SIZE ERROR imperative-statement]


~
I ALTER ~procedure-name-! TO [PROCEED TO J procedure-name-2
CALL Si~entifier-ll [USING data-name-1 [, data-name-2] ..• J
- - l hteral-1 S
CANCEL Sidentifier-1l • identifier-2]
- - - lliteral-1 S [ ,literal-2

D D D

~ , file-name

r-
1
DELETE file-name RECORD [; INVALID KEY imperative-statement]

DISPLAY sidentifier-1~ , Sidentifier-2l .•• [UPON CONSOLE]


- - - hiteral-1 S luteral-2 S

273
E

DIVIDE Sidentifier-ll INTO 'd 'f' -2 [ROUNDED]


hiteral-1 ~ - - 1 ent1 1er

[;ON SIZE ERROR imperative-statement]

DIVIDE Si~entifier- 1 l INTO Sidentifier- 2 l GIVING identifier-2 [ROUNDED]


l h teral-1 S -- lliteral-2 ~ ---

[;ON SIZE ERROR imperative-statement]

DIVIDE Sidentifier-ll BY Si~entifier- 2 l GIVING identifier-3 [ROUNDED]


lliteral-1 S - - l11tera1-2 S

[;ON SIZE ERROR imperative-statement]

: . :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

INSPECT identifier-! TALLYING


-~ ){ALL } Sidentifier-3l~
identifier-2 FOR , LEADING lliteral-2 ~

· [{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

MOVESi~entifier-ll TO identifier-2 [, identifier-3]


--lh.teral-1 ~

sidentifier-ll [ROUNDED]
MULTIPLY lliteral-l S BY identifier-2

(;ON SIZE ERROR imperative-statement)

MULTIPLY )~~~~~!~~7r-lt BY~~~~:~!~~;r- 2 ( GIVING identifier-3 [ROUNDED]


[; ON SIZE ERROR imperative-statement]

OPEN ~~ ~~~~~T I file-name-1


ll EXTEND ~ ,file-name-2 ···l
PERFORM THROUGH} procedure-name-2
procedure-name-! { ~

Sidentifier-ll
PERFORM procedure-name-! { THROUGH}
THRU procedure-name-2 lliteral-1 ~

PERFORM THROUGH} procedure-name-2


procedure-name-! { ~ UNTIL condition

READ file-name [NEXT) RECORD (INTO identifier]

[;AT END imperative-statement]

READ file-name RECORD [INTO identifier]


r-
1
[;INVALID KEY imperative-statement)

REWRITE record-name [FROM identifier]

[;INVALID KEY imperative-statement]

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-!

START file-name [KEY ~ i~ : ~ data-name]


~IS NOT < ~

[;INVALID KEY imperative-statement]

275
SUBTRACT ~identifer-ll [• ~identifier-2l] FROM identifier-) [ROUNDED]
lliteral-1 ~ lliteral-2 S ···

[; ON SIZE ERROR imperative-statement]

SUBTRACT Sidentifier-ll , Sidentifier-2l FROMSi~entifier-3l


lliteral-1 S lliteral-2 S • • • --hl.teral-3 S

GIVING identifier 4 [ROUNDED]

[; ON SIZE ERROR imperative-statement]

file-name
INPUT
USE AFTER STANDARD {EXCEPTION} PROCEDURE ON OUTPUT
--- ERROR
r:o-
EXTEND

USE FOR DEBUGGING {procedure-name-1 [, procedure-name-2]}···


- ALL PROCEDURES

~ITE l;;;;;:; F::~::::tif ie;~;}er { LINE


LINES } l E

WRITE record-name [FROM identifier]

[;INVALID KEY imperative-statement]

GENERAL FORM FOR COPY STATEMENT


~text-name l
lexternal-file-name-literal S

276
APPENDIX G

S~.ARY OF EXTE~!SIONS TO A~YSI COBOL

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.

SCREEN FORMATTING AND DATA ENTRY

THE ACCEPT STATEMENT

An additional format for the ACCEPT statement is provided as follows:

Ida ta:::•me-2l
ACCEPT dataname-l [ ATiliteral-l 1

data-name-2 allows the start of screen to be changed dynamically. It


refers to a PIC 9999 field where the most significant 99 is a
line count l-25 and the least significant 99 is a charact~r
position 1-80.

da ta-name-1 refers to a record, group or elementary item but may not be


subscripted.

literal-! is a numeric literal

NOTE: See Chapter 3 for description. See also Appendix H for


Environment Division changes.

THE DISPLAY STATEMENT


~ An additional format for the DISPLAY statement is provided as follows:
I
Format
DISPLAY !data-name-ll[AT
- lliteral-3 I -
sdataname-2l]
lliteral-1 I
UPON ~CRT I
- - ~CRT-UNDER~

literal-3 is an alphanumeric literal

dataname-1 • refers to a record, group or elementary item but may not be


subscripted

dataname-2 defines the left-most position on the screen. It refers to a


PIC 9999 field where the most significant 99 is a line count
l-25 and the least significant 99 is a character position
l-80.
NOTE: See Chapter 3 for description.

277
DISK FILES

Two eALensions are offered by CIS COBOL file processing; these are as
follows:

l. Line sequential files


2. Run time input of filenames

LINE SEQUENTIAL FILES

When LINE SEQUENTIAL ORGANIZATION is specified in the FILE CONTROL


paragraph ORGANIZATION IS entry, the file is treated as consisting of
variable length records separated by the lir.c delimiter characters.
lra111ng spaces in output records are replaced by a record terminator which
is operating system dependent.

RUN TIME INPUT OF FILENANES

The ASSIGNed name in the SELECT statement for a file is processed on


OPENing as follows:

When the INPUT or OUTPUT phrase is specified, execution of OPEN causes


checking of the file names in accordance with the operating system
conventions for opening an input or output file. The full operating system
features for file reallocation and device control are therefore available to
the CIS COBOL program,

LOWER CASE CHARACTERS

The full alphanumeric lower case a to z is available in CIS COBOL.


Reserved and user word characters are read as their upper case equivalents
(A to Z).

HEXADECU1AL VALUES

Hexadecimal binary values can be attributed to non-numeric literals in


CIS COBOL by expressing them as X "xx", where x is a hexadecimal character
in the set 0-9, A-F; xx can be repeated up to 120 times, but the number of
hexadecimal digits must be even.

INTERACTIVE DEBUGGING

There is a Run-Time Debug Package to provide break-point facilities in


the user's program. Programs may be run from the start until a specified
break-point is reached, when control is passed back to the user. At this
point, data areas may be inspected or changed.

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

SYSTEM DEPENDENT LANGUAGE FEATURES

This Appendix summarizes those parts of a COBOL program that need to be


changed to run them as CIS COBOL programs and those parts that do not need
changing specifically but are ignored by the CIS COBOL compiler when
generating the object program.

MANDATORY CHANGES

ENVIRONMENT DIVISION

The only statements in the environment division that must be


specialized for CIS COBOL are shown below:

Configuration Section

SPECIAL-NAMES. spec~al names entry

special names entry must include the following:

~ 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

File names must be as described in Appendix F of the CIS COBOL


Operating Guide.

STATEMENTS COMPILED AS DOCUMENTATION ONLY

COBOL programs not specifically written for compilation as CIS COBOL on


microcomputers can still be compiled. Statements using features that are
not available are treated as documentary only, and are not compiled. A
summary of these features follows:

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)

DATA DIVIS ION

File Description Paragraph

The following cauplete statements 1.n the fUe description are ignored
by the compiler during compilation but da not cause compile time errors:

~ CONTAINS integer-! I£ integer-2

~~ l
i CH.ARACfERS S

CODE-SET IS alphabet~c-name

\~IS l \STANDARD l
l~ARES l~S

VALUE OF tmplementor-name-1 IS liter al-l


- - - - [ , implementor-name-2 IS literal-2]

ffiOCEDURE DIVIS ION

CLOSE Statement

The following phrases 1.n the CLOSE statement are ignored by the
compiler during compilation but do not cause compiler-time errors:

(No magnetic tape)

,..,,

280
~
I
APPENDIX I

LANGUAGE SPECIFICATION

CIS COBOL is ANSI COBOL as given in "American Natioual Standard Programming


Language COBOL" (ANSI X.3.23 1974). CIS COBOL implements both levels of
ANSI COBOL. The following modules are fully Unplemented at Level 1:

Nucleus
TR.blP Hanrlline
Sequential Input and Output
Relative Input and Output
Indexed Input and Output
Segmentation
Library
Inter-Program Communication
Debug

In addition many Level 2 features are Unplemented such as:

Nucleus -Nested IF, PERFORM UNTIL


r.- Relative and Indexed sequential I/O - START statement
1
Inter-Program Communication - Fully implemented at level 2

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

Appendix F in this manual is a CIS COBOL syntax summary.

r
~
I

281

~
!
Level One Implementation

Fully implemented to Level One.

Level Two Implementation

1. DATE-COMPILED in the Identification Division is accepted for


documentation purposes only.

2. Up to 49 Level Numbers are permitted ar.d 1-9 can be a single digit.

3. The characters • and ; are permitted as separators

4. The character '>'. '='and '<'are permitted in relative conditions.

5. The PERFORM ••• THROUGH ••• UNTIL feature is implemented.

6. Plural forms of the figurative constants can be · used.

7. IF statements can be nested.

8. Mnemonic names are permitted in ACCEPT and DISPLAY statements (See


CIS COBOL extensions 6 and 7 below).

9. Procedure names can be all digits.

10. REDEFINES clauses can be nested.

11. Non-numeric operands can be compared.

CIS COBOL Extensions

1. Lower case letters a to t are read as upper case letters A to z.


2. Hexadecimal binary values can be attributed to non-numeric values by
expressing literals as X"nn".

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).

6. sdata-name-2l] FROM CRT


ACCEPT data-name-1 [ AT lliteral- 1 S

gives enhanced CRT input features

282
7. DISPLAY sdata-name-1l[AT~data-name-2l] SCRT l
t literal-1 ~ lliteral-2 ~ UPONlCRT-UNDERS

gives enhanced CRT output facilities.


8. 'CURSOR IS data-name' can be sp~cified in SPECIAL-NAMES and 1data-name 1
in WORKING-STORAGE section to specify CRT cursor address for ACCEPT
statements

SEQUENTIAL, RELATIVE AND INDEXED I-J


Level One Implementation
Fully ~plemented to Level One.

r Level Two Implementation

1. The START statement is fully supported for Relative and Indexed files.

2. In sequential files, EXTEND is supported.

3. In OPEN and CLOSE statements:

sREELl
l UNIT~

are accepted for documentation purposes only.


4. LOCK in the CLOSE statement is treated as documentary only.

5. Dynamic access 1110de and READ NEXT are supported for relative and
indexed files.

6. Only the first assignment in each ASSIGN is actioned, others are


treated as documentary only at compilation.

7. The I-Q-CONTROL paragraph is treated as documentary only as are its

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

1. Run Time allocation of file-names. See Appendix Fin Operating Guide.

2. LINE SEQUENI'IAL is an additional file type.

3. All File Description (FD) clauses are optional when ANS switch is
unset.

4. Tabbing is available, specified by TAB in the WRITE statement.

TABLE HANDLING
Level One Implementation

Fully implemented to Level One.


CIS COBOL Extensions

1. Items can be accessed in tables up to 49 dimensions. This extension is


restricted to three dimensions if the ANS switch is set.

SE(}{ENTAI ION
Level One Implementation

Fully implemented to Level One

Level One Implementation


Fully U.plemented to Level One

Level One Implementation

Fully implemented to Level 1 plus an additional Interactive Run-TU.e Debug


package.

284
CIS COBOL Extensions

A powerful Run-Time Debug package is available. See Chapter 3 in the


CIS COBOL Opera'ting Guide.

r INTER-FROGUM C<MMUNICAIION

Level Two Implementa'tion

Fully implemented to Level Two.

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

~
~ --··· -

You might also like