GC28 6394 6_IBM_DOS_Full_American_National_Standard_COBOL_Apr76 6 IBM DOS Full American National Standard COBOL Apr76

GC28-6394-6_IBM_DOS_Full_American_National_Standard_COBOL_Apr76 GC28-6394-6_IBM_DOS_Full_American_National_Standard_COBOL_Apr76

User Manual: GC28-6394-6_IBM_DOS_Full_American_National_Standard_COBOL_Apr76

Open the PDF directly: View PDF PDF.
Page Count: 488

DownloadGC28-6394-6_IBM_DOS_Full_American_National_Standard_COBOL_Apr76 GC28-6394-6 IBM DOS Full American National Standard COBOL Apr76
Open PDF In BrowserView PDF
File No. S360-24
~
Order No. GC28-6394-6,

DOS

I

Systems Reference Library

IBM DOS Pull American
National Standard COBOL
Program Numbers: (Versions 1 & 2) 360N-CB-4B2
(Version 3) 5736-CB2 (Compiler Only)
5736-LM2 (Library Only)
DOSjVS COBOL 5746-CBl (Compiler & Library)
5746-LM4 (Library Only)

This publication gives the programmer the rules for
writing programs that are to be compiled by the IBM
DOS/VS COBOL and IBM Full American National Standard
COBOL compilers under the Disk Operating System. It is
meant to be used as a reference manual in the writing
of IBM Full American National Standard COBOL programs.
COBOL (Cammon Business Oriented Language) is a
programming-language, similar to English, that is used
for commercial data processing. It was developed by
the Conference On DAta SYstems Languages (CODASYL).
The standard of-the-Ianguage is-American National
Standard COBOL, X3.23-1968, as approved by the American
National Standards Institute (ANSI). American National
Standard COBOL is compatible with, and identical to
international standarj ISO/R1989-1972, Programming
Language COBOL.
IBM DOS/VS COBOL and IBM DOS Full American National
Standard COBOL, Version 3, which include all the
features of earlier versions, incorporate tne eight
processing modules defined in the highest level of the
American national stanjard.
These modules include:
Nucleus
Table Handling
Sequential Access
Random Access
Sort
Report Writer
segmentation
Library
A significant number of IBM extensions are implemented
as well; these extensions are printed on a shaded
background.

Page of GC28-6394-4, -5, -6 revised 12/03/76 by TNL GN26-0887

PREFACE

This publication describes the IBM
implementation of Full American National
Standard COBOL, and all IBM extensions to
that standard. Some statements are
extensions to either American National
Standard COBOL or to both American National
Standard COBOL and the complete definition
of CODASYL COBOL.

In this publication, the term standard
COBOL means American National Standard
COBOL; the term IBM Full American National
Standard COBOL means this IBM
implementation of American National
Standard COBOL and all extensions to that
standard. There are two types of
extensions:

1.

Those that represent features not
specified by American National
Standard COBOL.

2.

Those that represent an easing of the
strict American National standard

COBOL rules and allow for greater
programming convenience.
All such extensions are printed on a shaded
background for the convenience of users who
wish strict conformance with the standard.
Use of features that are extensions to the
standard may result in incompatibilities
between the implementation represented by
this document and other implementations.
If a complete chapter is a~ extension, only
the page heading is shaded. These chapters
are:

Seventh Edition (April 1976)
This editiotJ. is a reprint of GC28-6394-5 incorporating changes released in Technical Newsletter
GN26-0801 (dated November 1,1975).
This edition, as amended by Technical Newsletter GN26-0887, describes Version 2 of IBM DOS Full
American National Standard COBOL at the Release 26 level of the Disk Operating System. It also
describes the Program Product Version 3, Release 3, including amended System/370 device support, and
Release 2 of the Program Product DOS/VS COBOL.
Information in this publication is subject to significant change. Therefore. before using this
publication, consult the latest IBM System!360 Bibliography, GC20-0360, and IBM System!370
Bibliography, GC20-000I. and the technical newsletters that amend the bibliography, to learn
which editions and technical newsletters are current and applicable.
Requests for copies of IBM publications should be made to your IBM representative or to the
IBM branch office serving your locality.
Forms for readers' comments are provided at the back of the publication. If the forms have
been removed. comments may be addressed to IB!\1 Corporation. P.O. Box 50020, Programming
Publishing, San Jose. California 95] 50. Comments and suggestions become the property of IBM.
© Copyright International Business ~lachines Corporation 1968, 1969. 1970.1971. 1972. 1973

For the less experienced programmer, the
introduction summarizes the general
principles of COBOL, highlights features of
American National Standard C~BOL, and,
through an example, illustrates the logical
sequence and interrelationship of conooonly
used elements of a COBOL program. The
balance of the publication gives the
specific rules for correct programming in
IBM Full American National Standard COBOL,
as implemented by the Systerr,/360 Disk
Operating System. Appendixes provide
supplemental information useful in writing
COBOL programs. Appendix A describes the
use of intermediate results in arithmetic
operations; Appendix B contains several
sample programs showing the use of mass
storage files; Appendix C lists all of the
formats and reserved words in IBM Full
American National Standard COBOL; Appendix
D is a file processing summary; Appendix E
gives considerations for the use of ASCII
encoded files; Appendix F explains the
symbolic debugginq feature; Appendix G
explains combined function card processing.
Compiler output and restrictions,
programming examples, and information on
running an IBM American National Standard
COBOL program are found in the publication
IBM DOS Full American National Standard
COBO~ Programmer's Guide, Order
No. GC28-6398 and in the Program Product
publications:
IBM DOS Full American National Standard
COBOL Compiler and Library, Version 3,
Programmer's Guide, Order No. SC28-6441
IBM DOS/VS COBOL Compiler and Library
Guide, Order No. SC28-6478

Progr~lli~er's

These programmer's guides and this
lanquage reference manual are corequisite
publications.
A knowledge of basic data processing
techniques is mandatory for the

understanding of this publication. Such
information, as it applies to System/360,
can be found in the following publications:
Introduction to IBM Data Processing
Systems, Order No.
GC20-1684
Introduction to IBM System/360 Direct
Access Storage Devices and Organization
Methods, Order No.
GC20-1649

The reader should also have a general
knowledge of COBCL before using this
manual.
Useful background information can
be found in the following publications:
American National Standard COBOL Codinq:
Card And Tape Applications 'Text, Order
No. SR29-0283
Coding Techniques And Disk Applications
Text, Order No. SR29-0284
Illustrations, Order No. SR29-0285
Student Reference Guide, Order
No. SR29-0286
Where information in the foregoing
publications conflicts with information in
this publication, the contents herein
supersede any other in the writing of COBOL
programs. Any violation of the rules
defined in this publication for using the
Disk Operating System is considered an
error.
A general knowledge of the IBM Disk
Operating System is desirable, although not
mandatory.
The following publication gives
such information:
IBM System/360 Disk and Tape Operating
System: Concepts and Facilities, Order
No.
GC24-5030.

ACKNOWLEDGMENT

The following extract from Government Printing Office Form Number
1965-0795689 is presented for the information and guidance of the user:
"Any organization interested in reproducing the COBOL report and
specifications in whole or in part, using ideas taken from this report
as the basis for an instruction manual or for any other purpose is free
to do so. However, all such organizations are requested to reproduce
this section as part of the introduction to the document. Those using a
short passage, as in a book review, are requested to mention 'COBOL' in
acknowledgment of the source, but need not quote this entire section.
"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
COBOL committee as to the accuracy and functioning of the programming
system and language. Moreover, no responsibility is assumed by any
contributor, or by the committee, in connection therewith.
"Procedures have been established for the maintenance of COBOL.
Inquiries concerning the procedures for proposing changes should be
directed to the Executive Committee of the Conference on Data Systems
Languages.
"The authors and copyright holders of the copyrighted material used
herein
FLOW-MATIC (Trademark of Sperry Rand Corporation),
Programming for the UNIVAC (R) I and II, Data Automation
Systems copyrighted 1958, 1959, by Sperry Rand
Corporation; IBM Commerical Translator, Form
No. F28-80l3, copyrighted 1959 by IBM; FACT, DSI
27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell
have specifically authorized the use of this material in whole or in
part, in the COBOL specifications.
Such authorization extends to the
reproduction and use of COBOL specifications in programming manuals or
similar publications."

Summary of Amendments

Number 10

Date of Publication: December 3, 1976
Form of Publication: TNL GN26-0887 to GC28-6394-4, -5,-6

I BM DOS COBO L

Maintenance: Documentation

• Minor technical changes and additions have been made to the text.

Summary of Amendments

Number 9

Date of Publication: March 15, 1974
Form of Publication: TNL GN28-1062 to GC28-6394-4

IBM DOS!VS COBOL

New: Programming Features

• SORT -OPTION clause for Sort and Merge Features
• 5425 MFCU Support
Maintenance: Documentation only

Minor technical changes and corrections to update the documentation to
Release 2

IBM DOS Full American National Standard COBOL, Versions 2 and 3
Maintenance: Documentation only

• 5425 MFCU support deleted
• Minor technical changes and corrections

Editorial changes that have no technical significance are not noted here.
Specific changes to the text made as of this publishing date are indicated by a vertical bar to the
left of the text. These bars will be deleted at any subsequent republication of the page affected.

Summary of Amendments

Number 8

Date of Publication: October 15, 1973
Form of Publication: TNL GN28-1 047 to GC28-6394-4

IBM DOS/VS COBOL

New: Programming Features
• Merge Facility

New: Documentation only
• Miscellaneous File Processing Considerations

Maintenance: Documentation only
Minor technical chai1ges to update the documentation to the initial release level.
IBM DOS Full American National Standard COBOL, Versions 2 and 3

Maintenance: Documentation only
Minor technical changes and corrections.

Editorial changes that have no technical significance are not noted here.
Specific changes to the text made as of this publishing date are indicated by a vertical bar to the
left of the text. These bars will be deleted at any subsequent republication of the page affe·cted.

Summary of Amendments

Number 9

Date of Publication: March 15, 1974
Form of Publication: TNL GN28-1062 to GC28-6394-4

IBM DOS/VS COBOL

New: Programming Features
• SORT-OPfION clause for Sort and Merge Features
• 5425 MFCU Support

Maintenance: Documentation only
Minor technical changes and corrections to update the documentation to
Release 2
IBM DOS Full American National Standard COBOL, Versions 2 and 3

Maintenance: Documentation only
• 5425 MFCU support deleted
• Minor technical changes and corrections

Editorial changes that have no technical significance are not noted here.
Specific changes to the text made as of this publishing date are indicated by a vertical bar to the
left of the text. These bars will be deleted at any subsequent republication of the page affected.

Summary of Amendments

Number 8

Date of Publication: October 15, 1973
Form of Publication: TNL GN28-1047 to GC28-6394-4

IBM DOS!VS COBOL

New: Programming Features

• Merge Facility
New: Documentation only

• Miscellaneous File Processing Considerations
Maintenance: Documentation only

Minor technical changes to update the documentation to the initial release level.
IBM DOS Full American National Standard COBOL, Versions 2 and 3

Maintenance: Documentation only

Minor technical changes and corrections.

Editorial changes that have no technical significance are not noted here.
Specific changes to the text made as of this publishing date are indicated by a vertical bar to the
left of the text. These bars will be deleted at any subsequent republication of the page affected.

Summary of Amendments

Number 4

Date of Publication: May 15, 1972
Form of Publication: TNL GN28-0489 to GC28-6394-2
IBM DOS Full American National Standard COBOL, Version 3

New: Programming Features
• Added System/370 device support: 2319,3211,3330,3410,3420,3505,
3525

New: Documentation Only
• Symbolic Debug example
• 3525 Combined Function Processing
Miscellaneous Changes for Versions 2 and 3

Maintenance: Documentation only
Minor technical changes and corrections

Summary of Amendments

Number 3

Date ofPubiication: April 15, 1971
Form of Publication: TNL GN28-0436 to GC28-6394-2
IBM DOS Full American National Standard COBOL, Version 3

New: Programming Features
• ASCII Tape file processing
• SIGN clause implementation
• OBJECT-COMPUTER paragraph requests System/370 instructions
• ON statement enhancement
Miscellaneous Changes for Versions 2 and 3

Maintenance: Documentation only
• PICfURE clause description and table of precedence
• USAGE clause deSCription
• Minor technical changes and corrections
• Added device support

Summary of Amendments

Number 2

Date of Pub licatiD n: January 1970
Form of Publication: Revision, GC28-6394-2
IBM DOS Full American National Standard COBOL, Version 2

Maintenance: Documentation only
Minor technical changes and corrections

Summary of Amendments

Date of Publication: July 1969
Form of Publication: Revision, GC28-6394-1
Miscellaneous Changes

New: Documentation only
• Table Handling clarifications
• Table Handling sample program

Maintenance: Documentation only
Minor technical changes and corrections

Number 1

CONTENTS -- DOS/VS COBOL
DOS/VS COBOL CONSIDERATIONS • ..
WHEN-COMPILED Special Register
Configuration Section • • •
SOURCE-COMPUTER Paragraph
OBJECT-COMPUTER Paragraph
SPECIAL-NAMES Paragraph •
VSAM File Processing
Environment Division -- File-Control Paragraph
SELECT Clause ..
ASSIGN Clause .. • .. •
RESERVE Clause
ORGANIZATION Clause ..
ACCESS MODE Clause ~ _ _ _ . . _ .. .. _
RECORD KEY Clause (Format 2)
PASSWORD Clause • • •
FILE STATUS Clause
Environment Division -- I-O-CONTROL Paragraph
RERUN Clause
SAME Clause .. .. • • ..
Data Division -- FD Entry
LABEL RECORDS Clause
Procedure Division
Common processing Facilities
..........
EXCEPTION/ERROR Declarative ..
.. ..
OPEN Statement
• .. .. .. • .. _
START Statement
READ Statement
WRITE Statement •
REWRITE Statement •
DELETE Statement
CLOSE Statement • •
Merge Facility •• ...
Environment Division .. .. _ _ ..
File-Control Entry for Merge Files
I-O-Control Paragraph _ .. .. .. .. .. .. .. _
Data Division • .. • .. • .. .. .. _ ..
Merge-File Description Entry
Procedure Division
MERGE Statement .
3886 OCR Processing •
FIPS Flagger • • • •
• .. _ ..
Miscellaneous File Processing Considerations
File Processing Summary -- New Devices .. • ..
ASSIGN Clause .. . .. .. • • ..
ACTUAL KEY Clause .. .. .. • _
APPLY WRITE-VERIFY Clause .. ..
APPLY CYL-OVERFLOW Clause ..
BLOCK CONTAINS Clause _
LABEL RECORDS Clause
ERROR Declarative .. ..
ACCEPT Literal Statement
OPEN Statement
WRITE Statement
CLOSE Statement
Sort Feature
5425 Combined Function Processing
0

0

..

..

..

i
i

.. ii
.. i i

• .. ii
.. iv
iv
v

vi
• ... vi
• vi
vii
•

..

..

G

u

o

_

u

Vll.

.. vii
viii
viii
viii
ix
ix
ix
ix
ix
x
xi
• xiii
.. xv
.. xvi
xvii
xix
...... xx
• .. xxi
....... - .. xxi
xxii
xxii
....... xxii
.. xxiii
. . . . . . xxiii
xxiv
.... xxiv
• xxvii
xxviii
.... xxxiv
.... xxxiv
.... xxxiv
........ xxxv
........ xxxv
- .. - ..
xxxv
........ xxxv
.. .. .. ..
xxxv
.... - - xxxv
•• xxxvi
.... xxxvi
.... xxxvi
.... xxxvi
.. - xxxvi
- .. xxxvi

FIGURES
Figure I. Moves and Comparisons -- System/360 vs. System/370
..iii
Figure II. Shift And Round Decimal (SRP) -- System/360 vs ..
System/370
• iv
Figure III. Status Key Values and Their Meanings
................ x
Figure IV. OPEN Statement Options and Permissible I/O Statements •• xiv
Figure V. KEY Item Categories and Collating Sequences
xxvi
Figure VI. The Four Levels of FIPS Processing ... • .. .. .. .. .. .. .. xxix
Figure VII. File Processing Summary -- DOS/VS COBOL Devices .. _ -xxxiv
Figure VIII. Error Bytes for 3540 -- GIVING Option
..... _ .... -xxxvi
•

•

•

-

•

-

~

•

•

•

,

•

•

•

•

•

_

u

•

•

•

_

_

_

•

_

CONTENTS -- AMERICAN NATIONAL STANDARD COBOL

FEATURES OF THE DOS FULL COBOL PROGRAM
PRODUCT COMPILERS
v
~
G

G

INTRODUCTION • .. •
••
principles of COBOL • • • ...
A Sample COBOL Program •
• ..
Identification Division
Environment Division ..
Data Division • .. • .. _
..
Procedure Division • ..
Beginning the program -- Input
Operations • • • • • • ..
..
Arithmetic Statements
Conditional Statements ..
..
Handling Possible Errors ..
Data-Manipulation Statements
Output Operations ..... _ • •
Procedure Branching Statements
Ending the Program .. ..
a

d

..

Q

FORMAT NOTATION

..

•

q

..

• • • 15
16
• .. .. 18
19
• 19
.. .. .. 20
..

n

..

23

.. •. .. 23
24
_ _
25
26
26
27
28
31
0

n

Q

..

PART I -- LANGUAGE CONSIDERATIONS

35

STRUCTURE OF THE LANGUAGE
COBOL Character Set
Characters Used in Words .. ..
..
Characters Used for Punctuation .. ..
Character3 Used for Editing
..
Characters Used in Arithmetic
Expressions . . . . . . .
..
Characters Used for
Relation-conditions
Types of Words .. • .. .. .. .. ..
........
Reserved Words
Names • .. .. •
.. .. .. •
Special-Names
Constants
Literals . . . . . . .
..
.. .. .. ..
Figurative Constants
.. ..
Special Registers ........

37
37
37
38
39

Q

ORGANIZATION OF THE COBOL PROGRAM
Structure of the COBOL Program
METHODS OF DATA REFERENCE
Qualification .. • .. ..
Subscripting
Indexing ..

39
39
39
40

41
41
41
41
43

44
46
46

• .0 .. .. 48
.. .. .. .. 48
49
.. 49

USE OF THE COBOL CODING FORM
Sequence Numbers
Area A and Area B
Division Header
........
Section Header .. ..
Paragraph-names and Paragraphs
Level Indicators and Level Numbers •
continuation of Lines ... .. .. .. .. • ..
Continuation of Nonnumeric Literals
Continuation of Words and Numeric
Literals • •
.. co ., • • • .. ...
Blank Lines
.. .. ..
Comment Lines
ft

Q

.. .• '. ..

• 53

11

..

..

50
50
50
51
51
51
51
51
52
52
52
52

PART II -- IDENTIFICATION AND
ENVIRONMENT DIVISIONS

• 55

IDENTIFICATION DIVISION
PROGRAM-ID Paragraph •
DATE-COMPILED paragraph

• 57
• 57
.. 58

ENVIRONMENT DIVISION -- FILE
PROCESSING SUMMARY • • • • ..
• 59
Data Organization .. • • .. ..
• 59
Sequential Data Organization .. ..
59
Direct Data Organization • • • .. .. • 59
Indexed Data Organization .... _ .. .. 60
Access Methods • • • • • .. .. •
60
Accessing a Sequential File
.. 60
Accessing a Direct File
60
Sequential Access .. .. ... ..
60
Random Access
.. 61
Accessing an Indexed File
61
sequential Access
• 61
Random Access
• 61
ORGANIZATION OF THE ENVIRONMENT
DIVISION _ .. .. .. • .. .. .. .. .. .. ..

• 63

ENVIRONMENT DIVISION -- CONFIGURATION
SECTION .. .. • .. .. .. .. • ~ .. •
SOURCE-COMPUTER paragraph
OBJECT-COMPUTER paragraph
Program Product Information -Version 3 • • .. .. .. .. ..
SPECIAL-NAMES Paragraph

64
64
.. 65

• 65
• 65

DIVISION -- INPUT-OUTPUT
SECTION .. .. • .. ..
FILE-CONTROL Paragraph • .. • .. • .. .. ..
SELECT Clause .. ..
ASSIGN Clause ....... ~ .. •
Program Product Information -Version 3
• .. • .. .. ..
RCE and OMR Format Descriptor
RESERVE Clause .. .. • • • a
Program Product Information -Version 3 . . . . . . . . . . . . _ ... .. ..
FILE-LIMIT Clause _ .. .. .. • .. .. •
ACCESS MODE Clause
• .. .. _
PROCESSING MODE Clause • • ..
ACTUAL KEY Clause
NOMINAL KEY Clause
RECORD KEY Clause .... • .. .. ., .. ..
TRACK-AREA Clause
I-O-CONTROL Paragraph
RERUN Clause .. .. •
SAME Clause
MULTIPLE FILE TAPE Clause .......
APPLY Clause
ENVIRON~ENT

n

•

..

..

..

•

..

..

Q

..

0

..

..

•

u

PART III -- DATA DIVISION

..

..

..

..

68
.. 68
69
69
..

•

.. 72
.. 75

.. 77
..
..
..
..
..

77
77
78
78
79

.. 82
• 83
.. 83
84
.. 84
.. 85
.. 86
• 87

• 91

DATA DIVISION -- INTRODUCTION
93
Organization of External Data . . . ~ ..
93
Description of External Data _ .. • • • .. 93

Imperative statements a • • •
Compiler-Directing statements

.151
.152

Q

ARITHMETIC EXPRESSIONS • ..
Ari thmetic Operators
a

ORGANIZATION OF THE DATA DIVISION
Organization of Data Division Entries
Level Indicator
Level Number .. _ .. • .. ..
Special Level Numbers
Indentation
.. .. ..
File Section ..
File Description Entry ..
Record Description Entry .. .. _ _ _
Working-Storage Section
Data Item Description Entries
Record Description Entries .. • • _
Linkage Section
.. .. _
Report section ..
_ .. .. .. ..
u

•

..

•

•

q

• 94
• 95
95
95
96
.. 97
97
97
~
97
98
98
.. 98
• 98
99

FILE DESCRIPTION ENTRY -- DETAILS OF
CLAUSES . . . .. ..
.. 100
BLOCK CONTAINS Clause
100
RECORD CONTAINS Clause ..
... 102
Recording Mode .. a •• .. ..
..103
.... 104
RECORDING MODE Clause
LABEL RECORDS Clause ..
.. 105
VALUE OF Clause
.. .. 106
DATA RECORDS Clause
.106
REPORT Clause
.107

••

••

..

.153
.153

0

CONDITIONS
.155
Test Conditions
.155
Class Condition
.156
Condition-Name Condition ..
... 157
Relation Condition . . . . . . .
.158
Sign Condition • • • • • •
.162
Switch-Status Condition . . . . . . • .162
Compound Conditions
• .162
Evaluation Rules .. ..
.163
Implied Subjects and
Relational-Operators • _
.. 164
Implied Subject
.. 165
Implied Subject and Relational
Operator • • .. .. .. .. .. .. • • ..
.165
Implied Subject. and Subject and
Relational-Operator
.. 165

0.... • • . .. •

q

.. 108

DATA DESCRIPTION

DATA DESCRIPTION ENTRY -- DETAILS OF
CLAUSES .... • ..
.. .. .. • •
.. 111
Data-name or FILLER Clause
.111
REDEFINES Clause ...... _ . . . . . _ .. 112
BLANK WHEN ZERO Clause..
0115
JUSTIFIED Clause.. ..
..116
OCCURS Clause
. . . . . . . . . . . 116
PICTURE Clause. .. ..
.116
The Three Classes of Data
.. 117
Character String and Item Size . . . . 118
Repetition of Symbols _ . . . . . . . . . . . 118
Symbols Used in the PICTURE Clause .118
The Five Categories of Data
.. 120
Types of Editing.. .. ................ 125
Insertion Editing . . . . . . . . . . . _ • .,125
Zero Suppression and Replacement
Editing .. • .. .. .. .. .. .. .. _ ..
..128
Program Product Information -Version 3 .... _ .. .. ..
.. .. 129
SIGN Clause . . . . . ..
129
SYNCHRONIZED Clause
... 130
.. 132
Slack Bytes
__ 136
USAGE Clause ..
Display Option .. .. • .. ..
.... 137
The Computational Options
.... 138
Program Product Information -Version 3
• .. .. .. 139
VALUE Clause.. .. .. .. • ..
..142
RENAMES Clause .. ..
.. ..144
a

0

..

..

..

..

CONDITIONAL STATEMENTS ....
I F Statement ..
Nested IF Statements ..
u

..

..

.166
.166
.167

••

DECLARATIVES .. • .. .. .. .. ..
• . . . . . . . 169
Sample Label Declarative Program.
.172
ARITHMETIC STATEMENTS . . . . .
CORRESPONDING Option ..
GIVING Option
ROUNDED Option _ • •
SIZE ERROR Option
Overlapping Operands •
ADD Statement
COMPUTE Statement
DIVIDE Statement ..
MULTIPLY statement ....
SUBTRACT Statement .. ..

u

• .. .. .. .179
.179
179
.. 179
c

• .. .. .. .180
· .. .. .. .180
.. 181
.182
.183

..184
.. _185

PROCEDURE BRANCHING STATEMENTS •
GO TO Statement . ' 0 .. •
ALTER Statement
PERFORM Statement
STOP statement
EXIT Statement _ _

.187
.187

DATA-MANIPULATION STATEMEN~S •
MOVE Statement .. • •
EXAMINE Statement
TRANSFORM statement

.198
.198

.188
.189

.196
.196

.201
.203

INPUT/OUTPUT STATEMENTS
• .206
OPEN statement ~ ~
.206
START Statement
.208
SEEK Statement _ a
.. 210
READ Statement w
211
WRITE Statement
.212
Program Product InforITation
(Version 3)
.216
REWRITE Statement
....
.218
ACCEPT Statement • ..
.219
DISPLAY Statement
• • .. ..
.220
CLOSE Statement
••
.221
Sequential File Processing.
.222
Random File Processing . . . . . . _ • • 224
m

d

.. 147

PART IV -- PROCEDURE DIVISION

ORGANIZATION OF THE PROCEDURE DIVISION .149
categories of Statements.
.150
Conditional Statements .... _ . . .
151
Q

n

_

••

U

d

SUBPROGRAM LINKAGE STATEMENTS
CALL Statement .. •.
ENTRY Statement •
~
USING Option • • •
Program Termination Considerations
EXIT PROGRAM Statement • • • ~ ~ ..
GOBACK Statement
STOP RUN Statement .. •
n

•

•

a

..

•

•

..

..

fl

COMPILER-DIRECTING STATEMENTS
COPY Sta tem"ent ..
ENTER Statement
NOTE Statement
0

.226
.. 226
.. 227
.228
.. 231
.232
.. 232
232
co

• .. 233
.. 233
.. 233
.,233

..

PART V -- SPECIAL FEATURES ..

co

•

c. . . . .

a

u

ft

•

•

•

n

n

_

•

•

..

_

u

•

OJ

..

..

Sample Program Using the Sort Feature

.250

REPORT WRITER FEATURE ... _ .. ..
.. 252
Data Division -- Overall Description _ .. 252
Procedure Division -- Overall
Description ... _ • _ .. • •
253
Data Division Considerations for
• • .. .. • .. 254
Report Writer
254
File Description .. • .. ..
REPORT Clause .. _ .. _ 0 • .. .. _ .... 254
.255
RECORDING MODE Clause
.. _ .. .. .. .. 255
DATA RECORDS Clause
.... 255
RECORD CONTAINS Clause ~ •
.. 256
Report section • • •
Report Description Entry
• .. 256
CODE Clause .. _ • ..
• .. 256
.. 257
CONTROL Clause • •
PAGE LIMIT Clause
• ... 258
Report Group Description Entry ...... 261
... 263
LINE Clause
.... 265
NEXT GROUP Clause
.267
TYPE Clause
. . . . . . . . . . . 269
USAGE Clause ..
_ .. 269
COLUMN Clause
GROUP INDICATE Clause
.270
JUSTIFIED Clause
.270
PICTURE Clause _ .. .. _ _
.... 270
RESET Clause • .. • • • _
.... 270
BLANK WHEN ZERO Clause
• .. 271
SOURCE, SUM, or VALUE Clause _ • .... 271
U

•

fl

..

n

.....

0

•

n

......

Q

....

235

.. .. 237
SORT FEATURE • ... •
.. 237
Elements of the Sort Feature ..
Environment Division Considerations
for Sort • .. _ .. • • • .. _ • • _ ..
.... 238
.... 238
Input-Output Section • .. .. .. • ..
File~Control Paragraph
.. 238
239
Assignment of Sort Work units
I-O-CONTROL Paragraph _ .. _ ..
0239
RERUN Clause • .. .. 0 .. _ • ..
.240
SAME RECORD/SORT AREA Clause ..
.. 240
Data Division Considerations for Sort .241
File Section
.241
_ 241
Sort-File Description
Procedure Division Considerations for
Sort • • .. _ • _ • _ •
c.242
SORT Statement • .. ..
• .. c.242
.. 247
RELEASE Statement
_ .. 248
RETURN Statement ..
EXIT Statement .. • ..
• .. 248
... 249
Special Registers for Sort •
0

Procedure Division Considerations
.273
GENERATE Statement ..
_ • .. .. .. .273
Detail Reporting . . . . . . . . . _
.273
Summary Reporting ... • .. • ..
.273
Operation of the GENERATE Statement 274
INITIATE Statement. ..
.. ....... 275
TERMINATE Statement .. • .. • c. .. _ .275
USE Sentence.
_ •••
276
Special Registers: PAGE-COUNTER and
LINE-COUNTER • ..
•• 277
PAGE-COUNTER • .. _ .. .. •
.277
LINE-COUNTER • .. .. .. .. • • • co .. ., .278
Sample Report writer Program
.. 279
Key Relating Report to Report
Writer Source Program
.282
TABLE HANDLING FEATURE ..
.. 289
Subscripting _ .. • •
.289
Indexing • • • .. .. .. .. •
.290
Restrictions on Indexing,
Subscripting, and Qualification
.291
Example of Subscripting and Indexing .. 291
Data Division considerations for Table
Handling . . . . . . . . . . . . . _
• • 292
OCCURS Clause _ • _ •
.292
USAGE IS INDEX Clause
.299
Procedure Division Considerations for
Table Handling _ •
• • _
300
Relation Conditions
... 300
SEARCH Statement .. _ ..
•
301
SET Statement
.306
Sample Table Handling Program
.307
H

Q

u

•

_

_

0

••

_

• •

_

SEGMENTATION FEATURE _ •
Organization • • • ~
Fix::d Portion
Independent Segments _ •
Segment Classification
segmentation Control •
Structure of Program Segments
Priori~y Numbers .. _ • •
• ..
Segment Limit
• • .. • _
Restrictions on Program Flow _
ALTER Statement • _ • • •
PERFORM Statement
Called Programs

.309
309
.. 309
.309
.310
.310
.310
.310
.311
.312
.312
.312
.312

a

co

n

0

..

..

SOURCE PROGRAM LIBRARY FACILITY
COpy Statement • • • _ • • ..
Extended Source Program Library
Facility • .. • •
BASIS Card •
INSERT Card _ _ • •
DELETE Card

.313
.313
.316
.316
.316
.316

DEBUGGING LANGUAGE
.. 318
READY/RESET TRACE Statement
.318
EXHIBIT Statement • _ _ _ •
.318
ON 4096

I
I

6-16
12-22
18-28
24-34
30-40
36-46
26+480*

I
I
I
I

I
I

I
I
I

6-16
12-22
14-22
14-22
14-22
14-22
14-22

I
I
I
I
I

I

I
I

8-26
16-36
24-46
32-56
40-66
48-76

I
I

26+496*

I
I

I

I

8-26
16-24
16-24
16-24
16-24
16-24

I
I

16-24

I

I

I

I

I
I
I

I
I

I
I

r--------------~-------------~-------------~---------- ---~-------------~

I*Bytes needed to invoke object-time subroutine, plus size of
I
IL__
subroutine
itself.
___________________________________________________________________
JI
~

Figure I.

Moves and Comparisons -- System/360 vs. System/370

Figure I gives comparative figures without right justification for
fixed-length and variable-length MOVE statements, and for fixed-length
and variable-length comaprisons.
Figure II gives comparative figures for Shift And Round Decimal
generation; the savings shown are made for each such operation in the
object program.
The MEMORY SIZE clause can be used to document the actual equipment
configuration needed to run the object program.
The SEGMENT-LIMIT clause is discussed in the

Seg~entation

Chapter.

DOS/VS COBOL Considerations iii

Except for the computer-name entry and the SEGMENT-LIMIT clause, the
OBJECT-COMPUTER paragraph is treated as documentation.

t-----------------------T-----------------------T----------------------,

I
I

Function

I
I

System/360
Bytes ~eeded

I
I

System/370
Bytes Needed

I
I

~-----------------------+-----------------------+----------------------~

I
I
I

Rounding
Left Scaling
Right Scaling

I
I
I

39 + literal*
6 + literal*
12

I
I
I

6
6
6

I
I
I

~-----------------------~-----------------------~----------------------~

I*As used for deciwal point alignment the literal varies in length withl

I size of data-item, number of decimal positions defined, and/or
I
scaling positions defined.
IL______________________________________________________________________
JI
Figure II.

Shift And Round Decimal (SRP) -- System/360 vs. System/370

SPECIAL-NAMES PARAGRAPH
The SPECIAL-NAMES paragraph as discussed in the Environment Division
chapter applies to DOS/VS COBOL without change.

VSAM FILE PROCESSING
VSAM (Virtual storage Access Method) is a high-performance access
method of DOS/VS for use with direct access storage. VSAM provides
high-speed retrieval and storage of data, flexible data organization,
ease of conversion from other access methods, and ease of use -including simplified job control statements, data protection against
unauthorized access, central control of data management functions,
device independence (freedom from consideration of block sizes, control
information, record deblocking, etc.), and cross-system compatibility.
Access Method Services, a multi-function utility program is used to
define a VSAM data set, and optionally load records into it, convert an
existing indexed or sequential data set to VSAM format, and perform
other tasks as well. Access Method Services is described in DOS/VS
Access Method services, Order No. GC33-5832.
VSAM allows key-sequenced and entry-sequenced data sets; records can
be fixed or variable in length.
In a key-seguenced data set (KSDS), records are stored in the
ascending collating sequence of some embedded key field.
For indexed
files of this type, records can be retrieved sequentially in key
sequence; they can also be retrieved randomly according to the
particular value of the key.
In an entry-seguenced data set (ESDS), the records are stored in the
order in which they are presented for inclusion in the data set. New
records are stored at the end of the data set. In COBOL, record
retrieval for sequential files of this type must be sequential.
VSAM files may be written on the following mass storage devices:
2314, 2319, 3330, 3340.
For V5AM file processing in COBOL, there are special language
considerations in the Environment, 0ata, and Procedure Division.
iv

ENVIRONMENT DIVISION

FILE-CONTROL PARAGRAPH

The File-Control paragraph names the VSAM file, associates it with an
external medium, and allows specification of other file-related
information.

r----------------------------------------------------------------------,

I

I

General Format 1 -- Sequential VSAM Files

~----------------------------------------------------------------------~

I

FILE-CONTROL.
{SELECT [OPTIONAL] file-name
ASSIGN TO system-name-i [system-name-2]
[RESERVE integer [AREA ]
AREAS
[ORGANIZATION IS SEQUENTIAL]
[ACCESS MODE IS SEQUENTIAL]
[PASSWORD IS data-name-i]
[FILE STATUS IS data-narne-2J.}
L_~---------------------------------------------------

_________________ J

r----------------------------------------------------------------------,

I

General Format 2 -- Indexed VSAM Files
I
~----------------------------------------------------------------------~
FILE-CONTROL.

-

{SELECT file-name
ASSIGN TO system-name-i [system-name-2]
[RESERVE integer [AREA ]
AREAS
ORGANIZATION IS INDEXED
SEQUENTIAL}
[ACCESS MODE IS. RANDOM
]
{ DYNAMIC
RECORD KEY IS data-name-3
[PASSWORD IS data-name-i]
[FILE STATUS IS data-name-2].}
______________________________________________________________________ J

Each file described by an FD entry or SD entry in the Data Division
must be described in one and only ppe Fj)e-Control entrr;
The key word FILE-CONTROL may appear only once, at the beginning of
the File-Control paragraph. The word FILE-CONTROL must begin in Area A,
and be followed by.aperiod followed by a space.
DOS/VS COBOL Considerations

v

Each File-Control entry m~st begin with a SEL~CT clause followed
riy an ASSIGN clause. The order in wnich the other clauses
appear is not significant, except that for indexed VSAN files the
PASSWORD clause, if specified, must iwmediately follow the RECORD KEY
cla~se.
Each File-Control entry must end with a period followed by a
space.
in~ediately

Each data-name in the File-Control entry may be qualified; it may not
be subscripted or indexed. ~ach data-name must be at a fixed
displacement from the beginning of the data description entry in whicIl
it appears; that is, it must not appear in the entry after an OCCURS
DEPENDING ON clause.

SELECT Clause
The SELEC1 clause is used to name each file in the program. Each
file described with an FG entry or SD entry in the Data Division must be
named once and only once as a file-name following the key word SELEC1.
FORMAT 1: The OPTIO~AL clause must rie specified for input files that
are not necessarily present each time the object program is executed.
If file-name represents a sort file, only the ASSIGN clause may be
written following the SELECT clause.

ASSIGt"J Clause
The ASSIGN clause associates the file with an external storage
medium.
System-name specifies a system logical unit, and, optionally, a
device class, a device number, the file organiZ,q.tion, and the external
name.
System-name has the following structure:
." "
SYSnnn[-class] [-device] [-organization] [-nameLThe SYSnnn field is required, and nnn must be a three-digit number
from 000 through 240 inclusive.
This number represents the symbolic
unit to which the file is assi~ned.
The class and device fields are included for compatibility only; for
VSAM files, these fields are treated as documentation.
The organization field is required for seqnential VSAM files.
entry must be AS.

The

-

The organization field must not be specified for indexed VSAM files.
The name field is an optional three-character" through s~ven~6haracter
field, specifying the external naI:(l~ by which the file is known to the
system.
If name is not specified, the symbolic unit (SYSnnn) 1S used as
the external name.
The name field ITust be specified if more than one
file is assigned to the same symbolic unit.

RESERVE Clause
The RESERVE clause is
vi

treat~d

as documentation.

ORGANIZATION Clause
The ORGANIZATION clause specifies the logical structure of the file.
The file organization is established at the time the file is defined and
cannot subsequently be changed~
FORMAT 1:
~QUENTIAL

If the ORGANIZATION clause i s omitted, ORGANIZATION
is assumed.

When ORGANIZATION SEQUENTIAL is specified or assumed, the records in
the file are positioned sequentially in the order they were created.
Once established, the position of the file records does not change.
FO~ffiT

2: When ORGANIZATION INDEXED is specified, each logical record
in the file contains an embedded RECORD KEX which is associated with an
index, and each record is identified through its RECORD KEY value.
AIter records have been updated n or have been added to or deleted froIT
the file, the position of the records may have changed.

ACCESS MODE Clause
The ACCESS MODE clause specifies the manner in which records in the
file are to be processed.
When the ACCESS MODE clause is omitted, ACCESS MODE SEQUENTIAL is
assumed.
When ACCES~ MODE SEQUENTT~tis specified or assumedi' the records are
processed sequentially. That is, the next logical record in the file is
the next45rocessedo .
When QRGANIZATION IS SEQUENTIAL is specified or assumed, the records
in the file are grocessed in the seqnence established when the file was
created-pr extended~

When~RGANIZATION

IS INDEXED is specified, the records in the file
are "Q,rocessed in tbe seQuence Of ascendiPQ record key values.
FORMAT 2: For indexed VSAM files, ACCESS MODE RANDOM and ACCESS MODE
DYNAMIC can also be specified.
When ACCESS MODE RANDOM is specified, the sequence in which records
are processed is determined by the sequence in which record keys are
presented. The desired record is accessed by placing the value of its
key in the RECORD KEY data item before the associated input/output
statement is executed.
When ACCESS MODE DYNAMIC is specified, records in the file are
processed either sequentially and/or randomly. The form of the specific
input/output request determjnes the aCCess mode.

RECORD KEY Clause (Format

~)

The RECORD KEY clause ~pecifies the data item within the recor~ which
contains the key for that record. A RECORD KEY must be specified for an
indexed VSAM file.
Data-name-3 is the RECORD KEY data itemo Data-name-3 must be defined
as a fixed length alphanumeric or unsigned external-decimal numeric data
item within a record description entry associated with file-name.
Data-name-3 is treated as an alphanumeric item.
DQS/VS COBOL Considerations vii

VSAMPASSWOEP/:e-'TLE . STATUS. Cl(i.u.s~sII';';O-CONTROL (POS/VS}

The value contained in data-name-3 must be unique among records in
the file.
The data description of data-name-3 and its relative location in the
record must be the same as that specified when the file was defined.
PASSWORD Cla.use
The PASSWORD clause controls object-time access to the file.
Data-name-l is the password data item; it must be defined in the
working-Storage Section as an alphanumeric itemo The first 8 characters
are used as the password: a shorter field is padded with blanks to 8
characters. The password data item must be equivalent to the one
externally specified.
When the PASSWORD clause is specified, at object time the password
data item must contain the valid password for this VSAM file before the
file can be successfully openedo
(See nStatus Keyn in the following
Common Processing Facilities description.)
FILE STATUS Clause
The FILE STATUS clause allows the user to monitor the execution of
each ,input/output request for the file ..
Data-name-2 ~s the Status Key data item. Data-name-2 must be defined
in the Data Division as a two-character a~phanumeric or unsigned
external-decimal numeric item. Data-name-2 must not be defined in ~
~e sect~n or t~ Repo~t ~ection. Data-name:2 is t~ated as ~n­
alphanumerlc TIem.
When the FILE STATUS clause is specified, a value is moved into the
Status Key by the system after each input/output request that explicitly
or implicitly refers to this file.
The value indicates the status of
the execution of the statement.
(See nStatus Key" in the following
Common Processing Facilities description.)
ENVIRONMENT DIVISION -- I-O-CONTROL PARAGRAPH
The I-O-CONTROL paragraph specifies the special input/output
techniques to be used in the program. The I-O-CONTROL paragraph and its
associated clauses are optional.

r----------------------------------------------------------------------,
General Format -- VSAM Files
I

I

~-----------------------~----------------------------------------------~

I

I
I
I
I
I

I-

I
]
[RERUN ON system-name EVERY integer RECORDS
I
I
OF file-name-i]
I
J
I
I
[~ [RECORD] AREA
l
I
I
IL______________________________________________________________________
FOR file-name-2 [file-name-3J ••• J
Jl
I-a-CONTROL.

.ue

•

The key word I-a-CONTROL must begin in Area A and be followed by a
period and a spacen

viii

RERUN Clause
System-name is specified as described in the Environment Division
chapter; the checkpoint file must he a standard sequential file (it may
~t ~ ~ sequential ~AM t!k).
The device field may not specify 3540.

".,

File-name may specify a VSAM file.

SAME Clause
The SAME RECORD AREA clause for VSAM files is implemented as
described in the Environment Division chapter.
For VSAM files, the SAME AREA clause has the same meaning as the SAME
RECORD AREA clause.

DATA DIVISION -- FD ENTRY
In the FD entry for a VSAM file. the RECORD CONTAINS clause is
implemented as described in the Data Division chapter.
The BLOCK CQNTA~S, DATA RECORDS, and VALUE OF clauses,
as documentation for VSAM files.

~e

treated

fil!~~ RECORDING MODE and REPORT cl~s m~t ~t b~ sp~ified f~ V~l

There are special considerations for the LABEL RECORDS clause.

LABEL RECORDS Clause

The LABEL RECORDS clause specifies whether standard labels are
present or omitted, and serves only as documentation.

r----------------------------------------------------------------------,
Format
I

I

t---------------------------------------------------------------------~
:

~ {RECORD IS

I

} {STANDARD{

f

I
RECORDS ARE
OMITTED
I
IL ______________________________________________________________________ JI
For VSAM files, ~tber the STANDARD or the OMITTED option may be
specified.
Either option is treated as documentation.
The LABEL RECORDS clause is required in every FD entry.

PROCEDURE DIVISION
For VSAM files, there are several Common Processing Facilities that
apply to more than one input/output statement. These Corrmon Processing
Facilities are discussed before the descriptions of the separate
input/output verbs.
DOS/VS COBOL Considerations

ix

Common Processing Facilities

,fCURRENT ~ECORD POINTER: Conceptually, the Current Record Pointer
specifies the next record to be accessed by a sequential request. The
setting of the Current Record Pointer is affected only by the OPEN.
START, and READ statements. The concept of the Current Record Pointer
~o m~aning for random access or for output files.
------..

---

- -----

-----.

"STATUS KEY:
If the FILE STATUS clause is specified in the File Control
Entry, a value is placed into the specified Status Key (the 2-character
data item named in the FILE STATUS clause) during execution of any
request on that file; the value indicates the status of that request.
The value is placed in the Status Key before execution of any Error
Declarative or INVALID KEY/AT END option associated with the request.
The first character of the Status Key is known as Status Key 1; the
second character is known as Status Key 2. Combinations of possible
values and their meanings are shown in Figure III. See the DOS/VS
Proqrammer"s Guide for more information.

x

~lsta~!~u!ey

1 :::::::----------

I

~~~u!ey

0

I Successful

1

2 Meaning

---------~

r---

1

,0

INo Further

I

I Information

I

I

I

t------------+:~~::=~~~~-l:-~~-~-+------------+:~~~=~:~~~~-----------~
,
1
IAt End (no next
I
0
INo Further
I
Ilogical record, or
I
Ian OPTIONAL file not"
I available at OPEN
I

I
I

I

,

~--------~---+~~~::----~-~~~-~---t------------~----------------------~
2
!Invalid Key
!
I
1
ISequence Error
!

!
I
I
I
I
I
I
I

I
I
I

•

~------------t----------------------~

,

2

I

I Duplicate Key

~------------t----------------------~

I

I

3

I

I No Record Found

~------------t----------------------~

I
I
I

I
I

4

I
I

IBoundary Violation

I (indexed VSAM file)

~------------t---------------------t------------+----------------------~

I
,
I

3

IPermanent Error

I (data check, parity

Icheck, transmission
I
terror)
I '

I '

I

Q

I

I
I

INo Further

I Information

~------------t----------------------~

I
I
I

4

I

1

I

'Boundary Violation
I (sequential VSAM
I file)

I

IPassword Failure

]

I

~----------t~--------------------t------------t----------------------~

9

IBM-defined

r------------t----------~-----------~

I

2

I

ILogic Error

~------------+----------------------~

i

3

I

I

jResource Not
I Available

1

~------------t----------------------~

I
I
I

4

INo Current Record
IPointer For
ISequential Request

I

t

]

r------------t--------~------------~
5
IInvalid or Incomplete j

J

1

I

IFile Information

~------------t----------------------~

I
6
INo DLBL card
1
t------------+---------------------+------------t----------------------~
I
Z
I User-defined
I
1-9
IReserved for user
J
IL- ___________ I _____________________ I ____________
A-Z
I purposes
_____________________ JI
~

~

~

Figure III. ~tatus Key Values and Their Meaning~

DOS/VS COBOL Considerations

x.i

vs~comrno'n ,P rocee;s ing'" ~acili t:iee;'(DOS/V§J
INVALID KEY CONDITION: The INVALID .KEY condition can occur during
execution of a START, READ, WRITE, REWRITE, OR DELETE statement.
(Io'or
details of the causes ~th~ndition, see documentation for those
statements.) When the ItNALID KEY condition is recognized, the
following actions are taken in the following order:

1.

If the FILE-STATUS clause is specified, a value is placed into the
Status Key to indicate an INVALID KEY condition.

2.

If the INVALID KEY option is specified in the statement causing the
condition, control is transferred to the INVALID KEY
imperative-statement. Any EXCEPTION/~OR declarative procedure
specified ~ t.b.l§ We ~ n£,t. executed.

3.

but'

If the INVALID KEY option is not spgcJfjed, but an EXCEPTION/ERROR
declarative Rrocedure is specified for the file,~
_EXCEPTION/ERROR prQcedure is executed.

When an INVAL~D KEY condi tion occu~s I ,the input/Qutput statement whicp
caused the condition is unsuccessful.
INTO/FROM IDENTIFIER OPTION:
and WRITE statements.

This option is valid for READ, REWRITE,

-

The INTO identifier option makes a READ statement equivalent to
~

READ
MOVE

file-name
record-name TO identifier

After successful execution of the READ statement, the current record
becomes available both in the record-name and identifier.
The FROM identifier option makes a REWRITE or WRITE statement
equivalent to
MOVE

identifier TO record-name

REWRITE}
record-name
{ WRITE
After successful execution of the WRITE or REWRITE statement, the
current record may no longer be available in record-nam~~ ~s1ill
~available in identifier.
.
-

-.;;jc:=;;;;;;;;;;;;:;;:;;;:=-

In all cases, identifier must be the name of an entry in the
Working~Storage Section, the Linkage Section, or of a record description
for another previously opened file.
Record-narne/file-name and
identifier must not refer to the same storage area.

.

.

EXCEPTION/ERROR Declarative
The EXCEPTION/E~ROR rieclarative specifies pro6edures f~r input/output
exception or error handling that are to be executed in addition to the
standard system procedures.
DOS/VS COBOL Considerations

xi

r----------------------------------------------------------------------,
I

I

Forma.t

t-----------------:...."~----~----~-----....:---.::..-----..:...--...,;--....:~------------------~

EXCEPTION)
\ PROCEDURE
,ERROk)

f

S~ANDARD

USE AFTER
----

)

~
1' l e-name-~

ON

tLl1e-name- 2'J

rc'-

INPUT
OUTPUT

If

1-0
EX~'END

___

~

_________________________________ .::.. ____

~

___________________________ J

A USE statement, when present, must immediately follow a sectiQ.:Q..
header in the Declaratives Section (see "Declaratives" in the Procedure
Division chapt~r). A USE statement must be followed py a period
followed ny a spacie. The remainder of the §ection must consist of one
or more procedural paragraphs that specify the proccedur~s to be uied.
tge USE statement itself is not an executable statement; it merely
defines Ehe conditlons tor execUtiop of the procedural paragraphs.
The words EXCEP~IaN and ERROR are synonymous and may be used
interchangeably.
----'.,..

.

When the file-name option is specified, the procedure is executed
only for the filets) nawed. Appearance of a file-name must not cause
simultaneous requests for the execution of more than one EXCEPTIO~/ERROR
procedure. No file-name can refer to a sort file.
When the INPUT option is specified, the
files opened in INPUT mode.
all

proce~ure

is executed for all

When the OUTPUT option is specified, the procedure is executed for
f~les opened ~n the OUTPUT mode.

When the 1-0 option is specified, the"procedure is executed for all
files opened~ 1:0 moje.
When the EXTEND option is specified, the procedure is
all files opened in EXTEND mode.

ex~cuted

for

!be ~XCg:TI..QNa-:R.!WB. p..£~e~u.Ee_ ~s_ e~e;,c~t~d;..
• Either after completing the standard system input/output error
routine, .£!
• Upon recognition of an IiNALID KLY or AT END condition when an
INVALID KEY or AT END option has not been specified in the
input/output "statement, 2.!
• Upon recognition of an IBM-defined condition which causes status key
1 to be set to 9.

to

After execution of the EXCEPTION/ERROR procedure, control is returned
the invoking rou~.

The EXCEPTION/ERROR procedures are activated when an input/output
error occurs during execution of a ~, WRITE, ~E, START, or
DELETE~statement.~~

If an OPEN statement is issued ~ file ~~in-!De 0Ben stijtQs,
the EXCEPTION/ERROR procedures are actlvated; when the executlon of an
OPEN statement is unsuccessful due to any other cause, the
EXCEPTION/ERROR procedures are not activated.
xii

If a file is in the OPEN status, and the execution of a CLOSE
statement is unsuccessful, the EX~EPTION/E~ROR procedures are activated.
If the file is in a closed status and a CLOSE statement is issued, the
E~CEPTION/~RROR procedures are not activated.
Within a declarative procedure, there must be no references to
nondeclarative procedures.
In nondeclarative procedures, tnere must be
no references to declarative procedur-es,.except that P.LRFORM statements
may refer to procedure-names associated with a declarative procedure.

OPEN Statement
The OPEN statement initiates the processing of VSAl'-'l files.

r----------------------------------------------------------------------,

I

I

Format

t----------------------------------------------------------------------~

1

I
I
I
~INPU~
file-name-l
[file-name-2] •..
I
I
OPEN OUTPUT file-name-l
[file-name-2] ••.
...
I
1-0
file-name~l
[file-name-2] •.•
I
I
I
EXTEND file-name--l {file-name-2] .••
.
I.
Il ______________________________________________________________________ JI
At least one of the options INPU~', OUTPUT, 1-0, or EXTBND must be
specified; there may be not more than one instance of each option
specified in one OPEN statement, although more than one file-name may De
specified with each option.
The INPUT, OUTPUT, 1-0, and EXTEND options
may appear in the any order.
Each file-name designates a file upon which the OPEN statement is to
operate. Each file-name mus be deflned in an FD entry in the Data
Qivision, and must not name a sort file. The FD entry or the file must
be equivalent ~~nformati~p~ied when the file was defined.
The successful execution of an OPhN statement determines the
availability of the file and results in that file being in open mode.
Before successful execution of the OPEN statement for a given file, no
statement can be executed which refers explicitly or implicitly to that
file.
The successful execution of the OPEN statement makes the
associated record area available to the program; it does not obtain or
release the first data record.
The INPUT option permits opening the file for input operations.
The 1-0 option permits opening the file for both input and output
operations.
The INPUT and 1-0 options are valid only for files which contain or
which have contained records, whether or not the files still contain any
records when the OPEN statement is executed.
(That is, even if all the
~cQrds jn a file have been deleted, that fjle can still be opened INPUT
or I-a) The INPUT and 1-0 options must not be specified when the file
has not been already created.
The OUTPUT option permits opening the file for output operations.
This option can be specified when the file is being created.
(The
OUTPUT option must not be specified for a file which contains records,
or which has contained records tnat have been deleted.>
The EXTENR option
file for output operations.
MODE SEQUE
. 1 s
..
When
EXTEND is specl ied, execution of th~ OPEN statement prepares the file
for the addition of records irrroediately following the last record in the

i!JI ACCESS

DOS~VS COBOL Considerations

xiii

file.
Subsequent WRITE statements add records to the file, as if the
file had been opened OUTPUT. The EXTEND option can be specified when a
file is being created; it can also be specified for a file which
contains records, or which has contained records that have been deleted.

-

/
The OPEN mode, the ACCESS MOP?, and the fjJe QRGANIZATION determine
~ the valid input/output statements for a given VSAM file. Figure IV
shows permlssible combinations.
----------------------T-----------------------T---~-------------------,

I
I

File Organization I
nd OPEN mode 1

1

INDExED

1

SEQUENTIAL

I

1

1

~-----T------T---T------+-----T------T---T------~

1ACCESS mode

1

land I/O verb

I INPUTIOUTPUTI

1 SEQUENTIAL

I
I
I

I
I

I

I RANDOM
I

I
I

I
I
I

t

I DYNAMIC
I

I
I

I
I
I

OPEN
READ
WRITE
REWRITE
START
DELETE

I

PIP

P

I
II P
1 -

P

II -

I

1
I
I
I
I
I
1-01 EXTEND 1INPUT I OUTPUT I 1-0 I EXTEND 1

PIP

P

I
1

- I
P 1
P I
P I

P

I
I
I
I
I
I
I

P

P

P

-

P

I
I
I
I
I
I
I

P

P

P

-

P

P

-

.1.

OPEN
READ
WRITE
REWRITE
START
DELETE

1

P

I
II P
I I -

-

1 -

P

I

OPEN

PIP

READ
WRITE
REWRITE
START
DELETE

P

I
II P

P

II -

1 -

P
P
P

I
I
I
I
I
I
I
~

I
I
P I
P I
P I
P I
P I
P

IP indicates that this input/output statement is permissible for this
I combination of File Organization, Access Mode and OPEN Mode

I
I

I
I
1- indicates that this input/output statement is not permissible for
I
IL______________________________________________________________________
this combination'of File Organization, Access Mode, and OPEN Hode
JI
Figure IV.

OPEN Statement Options and Permissible I/O Statements

A file may be opened for INPUT, OUTPUT, 1-0, or EXTEND in the same
program. After the first execution of an OPEN statement for a given
file, each subsequent execution of an OPEN statement must be preceded by
the successful execution of a CLOSE statement without the LOCK option.
Execution of an OPEN INPUT or OPEN 1-0 statement sets the Current
Record Pointer to the first record existing in the file.
For indexed
files, the record with the lowest key value is considered the first
record in the file.
If no records exist in the file, the Current Record
Pointer is set so that the first Format 1 READ statement executed
results in an AT END condition.
If the PASSWORD clause is soecified in the File-Control entry, the
password data item must contain the valid password before the OPEN
statement is executed.
If the valid password is not present, the OPEN
statement is unsuccessful.
If the FILE STATUS clause is specified in the Fiie-Control entry, the
associated Status Key is updated when the OPEN statement is executed.
xiv

If an OPEN statement is issued for a file already in the open status ff
the EXCEPTION/ERROR procedure (if specified) for this file' is executed.

START Statement
The START statement provides a means for logical positioning within
an indexed file for subsequent sequential retrieval of records.

r----------------------------------------------------------------------,
~~~
I

I

r----------------------------------------------------------------------~

I
I
I
I
I
I

I

J

I
1

EQUAL TO

J

I
I

GREATER THAN
START file-name [KEY IS

1

data-name]

I
>
]
I
1
I
NOT LESS THAN
I
I
I
I
NOT <
I
I
I
I
[INVALID KEY imperative-statement]
I
Il ______________________________________________________________________ JI
When the START statement is executed 6 the associated file must be
open in INPUT or 1-0 mode.
Fi~e-name must name an indexed V5AM file with sequential or dynarric
access.
File-name must be defined in an FD entry in the Data Division.
File-name ~ n~ ~ t~ n~e 2!. ~s~ ~.

When the KEY option is not specified w the EQUAL TO relational
operator is implied. When the START statement is executed, the EQUAL TO
comparison is made between the current value in the RECORD KEY and the
corresponding key field in the file's records. The Current Record
Pointer is positioned to the logical record in the file who~,e key field
satisfies the comparison.
' ~
When the KEY option is specified, data-name may be either
• The RECORD KEY for this file, or
• Any alphanumeric data item subordinate to the RECORD KEY whose
leftmost character position corresponds to the leftmost character
position of the RECORD KEY (that iSg a generic key).
When the START statement is executed, the comparison specified in the
KEY relational operator is made between data-name and the key field in
the file's records. If the operands are of unequal s~ze. the comparison
proceeds as if the key field were truncated on the right to the length
of the data-name. All other numeric and nonnumeric comparison rules
apply. The Current Record Pointer is positioned to the first logical
record in the file whose key field satisfies the comparison.
If the comparison is not satisfied by any record in the file, an
INVALIp KEY condition exists, and the position of the Current Record
Pointer is undefined.
(See "INVALID KEY Condition" in the preceding
Common processing Facilities Section.)
If the FILE STATUS clause is specified in the File-Control entry, the
associated Status Key is updated when the START statement is executed.
DOS/VS COBOL Considerations

xv

@AD Sta temen1)
For sequential access, the READ statement makes available the next
logical record from a VSAM file.
For random access, the READ statement
makes available a specified record from a VSAM file.

r----------------------------------------------------------------------,

I

Format 1
]
~----------------------------------------------------------------------i

I
I
I
READ file-name
[NEXT] RECORD [INTO identifier]
)
I
1
I
[AT END imperative-statement]
I
IL ______________________________________________________________________ J]

r----------------------------------------------------------------------,
Format 2
I

I

~----------------------------------------------------------------------i

I
I

READ file-name RECORD [INTO identifier]

I

J

I
I
[INVALID KEY imperative~statement]
I
IL______________________________________________________________________ J1

J

When the READ statement is executed, the associated file must be open
in INPUT or 1-0 mode.
File~name must te defined in an FD entry in the Data Division.
File-name ~t ~t ~ t..h-e ~e £!. ~s..2Et ~

The INTO identifier option is described in the preceding Common
Processing Facilities Section.
Following the unsuccessful execution of a READ statement w the
contents of the associated record area and the position of the Current
Record Pointer are undefined.
If the FILE STATUS clause is specified in the File-Control entry. the
associated 5tatus Key is updated when the READ staterr.ent is executed.
FORMAT l;~~When ACCESS MODE SEOUENTIAL is specified or assumed for a
VSAM file, thlS format must be used. For such files the statement makes
available the next logical record from the file.
For indexed VSAM
files, the NEXT option need not be specified; for sequential VSAM files
the NEXT option must not be specified.
When ACCESS MODE DYNAMIC is specified for indexed VSAM files, the
NEXT option must be specified for sequential retrieval. For such files.
the READ NEXT statement makes available the next logical record from the
file.
Before a Format 1 READ statement is executed. the Current Record
Pointer must be positioned by the successful prior execption of an OPEN~
START, or READ statement. When the Format 1 READ statement is executed.
the record indicated by the Current Record Pointer is made available.
For sequential VSAM files, the next record is the succeeding record in
logical sequence.
For a sequentially accessed indexed VSAM file. the
next record is that one having the next higher RECORD KEY in collating
sequence.
If the position of the Current Record Pointer is undefined when a
Format 1 READ stateIT1ent is issued, the execution of the staterrent is
unsuccessful.

If, when a Format 1 READ statement is executed, no next logical
record exists in the file, the AT END condition exists. The execution
of the READ statement is considered unsuccessful.
When the AT END condition is recognized, the following actions are
taken in the following order:
1.

If the FILE-STATUS clause is specified in the File-Control entry,
the Status Key is updated to indicate the AT END condition.

2.

If the A'I' Er-iD option of the READ statement is specified, control is
transferred to the AT END imperative-statement.

3~

If the AT END option is not specified r and a USE AFTER
EXCEPTION/ERROR procedure for this file is specified, either
explicitly or implicitly, the USE Frocedure is execut~d.

For files with SEQUENTIAL organization, when the AT END condition
been recognized, a READ statement for this file must not be executed
until a successful CLOSE statement followed by a successful OPEN
statement have been executed for this file.
For files with INDEXED organization, when the AT END condition is
recognized, a Format 1 READ statement for this file must not be executed
until one of the following has been successfully executed:
• A CLOSE statement followed by an OPEN statement
• A Format 2 READ statement (dynamic access)
• A START statement
If a sequential VSM-.1 file with the OPTIONAL clause is not present at
the time the file is opened, execution of the first READ statement
causes the AT END condition to occur. Standard end-of-file procedures
are not performed.
FORMAT 2: This format must be used for indexed VSAM files in random
access mode, and for random record retrieval in the dynamic access mode.
Execution of a Format 2 READ statement causes the value in the RECORD
KEY to be compared with the values contained in the corresponding key
field in the file's records until a record having an equal value is
found. The Current Record Poin'ter is positioned to 'this record, which'
is then made available.
If no record can be so identified, an INVALID KEY condition exists,
and execution of the READ statement is unsuccessful.
(See nINVALID KEY
Condition n in the preceding Common Processing Facilities Section.)

(WRITE stateme~
The WRITE statement releases a logical record to an OUTPUT, 1-0, or
EXTEND file.

r----------------------------------------------------------------------,
Format
I

I

~----------------------,--------:...:------------,-----.------:.---------------~

I
' I
I
h~ITE record-name [FROM identifier]
I
I
I
I
[INVALID KEY imperative-statement]
I
IL___________________________________________________________ . ___________ JI

DOS/VS COBOL Considerations

xvii

when the WRITB statement is executed, the associated file must be open
in OUTPUT, 1-0, or EXTENG mode.
Record-name must De the ndme of a logical record in the File Section
of the Data Division. Record-naITe may be qualified.
Record-name must
not be associatej with a sort file.
The maximum record size for the file is established at the time the
file is created, and must not subsequently be chanced.
Execution of the wRITE statement releases a logical record to the
file associated with record-name.

t7

After the WRITE s ~te ent is executed, tne~l~o~·~"-Q~e~c~o~r~d~=i~s~n~o
record-name,

~~ ~a2!e~

Tne associated file is named in a SAME RECORD AR~A clause (in which
case the record is also available as a record of the other files
named in the SAME RECORD AREA clause), or
The WRITE statement is unsuccessful due to a boundary violation.
In either of these two cases, the logical record is 3till available in
record-name.

~lIf

the FROM identifier option is specified, then after the WRITE
is executed, the information is still available in identifier,
even though it may not be in record-name.
(See "INTO/FROM Identifier
8ption" in the preceding Common Processing Facilities Section.)

s~tement

Record Pointer is not affected b

execution of the

The number of character positions required to store tne record in a
VSAM file mayor may not be the same as the number of character
positions defined by the logical description of that record in the COBOL
program.
If the FILE STATUS clause is specified in the File-Control entry, the
associated Status hey is updated when the WRITE statement is executed.
SEQUENTIAL VSAM FILES:

~ IN~D

W

op.tion m..1!§.t

~

~

specif ied.

When an attempt is made to write beyond the externally-defined
boundaries of the file, the execution of the WRITE statement is
unsuccessful, and an EXCEPTION/ERROR condition exists. The contents of
record-name are unaffected. If an explicit or implicit bXCEPTION/ERROR
procedure is specified for the file, the procedure is then executed; if
no such procedure is specified, the results are undefined.
INDEXED VSAM FILES: Before the WRITE statement is executed, tne
contents of the RECORD KEY must be set to the de~ired value. Note that
the value contained in any specific RECORD KEY must be unique 'within the
records in the file.
When the WRITE statement is executed, the contents of the RECORD KEY
are utilized so that sUbsequent access to the record can be based on the
RECORD KEY.
If sequential a~~ mode is specified.. or implied, records must be
released to the file·
ascending order of RECOR~ KEY.
If random or dynamic access is specified, records may be released in
any program-specified order.
IIWALID KEY Option: The INVALID KEY condition exists when any of the
following conditions occur:
xviii

1

.. .- ' I

Jtlt.e.r

• For an OUTPUT or. EXTEND f£le in $equential access mode~ when the
value of the RECORD KEY is not greater than the value of tne RhCOHD
KEY for the previous record.
• For an 1-0 or OUTPUT file in random or dynamic access mode, when the
value of the RECORD KEY is equal to the value of a RECORD KEY for an
already existing record.
• When an attempt is made to write beyond the externally-defined
boundaries of the file.
When the INVALID KEY condition is recognized, the execution of the WRITE
statement is unsuccessful, the contents of record-name' are unaffectEo.,
and the Status Key, if specified, is set to a value to indicate the
cause of the condition.
(See "INVALID KEY Condition" and "Status Key"
in the preceding Common Processing Facilities Section.)

~WRITE Stateme~
The REWRITE statement logically replaces an existing record in a VSll·:
file.

r----------------------------------------------------------------------,

I

I

Format

~----------------------------------------------------------------------~

I
I
I
REWRITE record-name [FRON identifier]
I
I
I
I
[INVALID KEY imperative-statement]
I
Il _____________________________________________________ - - - - _____________ j I
~

When the REWRITE statement is executed, the associated file must be
-

c=7
2Een in 1-0 mode.

Record-name must be the name of a logical record in the File Section
of the Data Division. Record-name must not be associated with a sort
file. Record-name may be qualified.
Execution of the REWRITE ,statement replaces ,.·an exist.ing record in the
ile with the information contained in record-name.
For a sequential
VSAM fi~, the number qf character positions in record-name ~e9ual
he number of character positions in the record being replaced.
For an
indexed VSAM flle, the number of character positions in record-name need
the number of character positions in the record being
---After successful execution of a REWRITE statement, the logical record
is no longer available in record-name unless the associated file is
named in a SAME RECORD AREA clause (in which case the record is also
available as a record of the other files named in the SAME RECORD AREA
clause).
The Current Record Pointer is not affected by execution of the
REWRITE statement.
If the FILE STATUS clause is specified in the File-Control entry, the
associated Status Key is updated when the REWRITE statement is executed.
For files in the sequential access mode, the last prior input/output
statement executed for this file must be a successfully executed READ
statement. When the REWRITE statemept is executed, the record retrieved
by that READ statement is logically replaced.
DOS/VS COBOL Considerations

xix

.. ,

"

SEOUENTIAL FILES: The INVALID KEY option ~ IJ.21 ~ specified for this
type of file.
An EXCEPTION/ERROR declarative procedure may be
specified.
INDEXED FILES: For an indexed file in the sequential access mode, the
record to be replaced by the REWRITE statement is identified by the
current value of the RECORD KEY.
When the REWRITE statement is
executed, the RECORD KEY must contain the value of the RECORD KEY for
the last-retrieved record from the file.
For an indexed file in random or dynamic access mode, the record to be
replaced is the record identified by the value of the RECORD KEY.
The INVALID KEY condition exists when:
• The access mode is sequential, and the value contained in the RECORD
KEY of the record to be replaced does not equal the RECORD KEY of
the last-retrieved record from the file •
• The value contained in the RECORD KEY does not equal that of any
record in the file.
If either condition exists, the execution of the REWRITE statement is
unsuccessful, the updating operation does not take place, and the data
in record-name is unaffected.
(See "INVALID KEY Condition" in the
preceding Com~on Processing Facilities Section.)
DELETE Statement
The DELETE statement logically removes a record from an indexed VSAM
file.

r----------------------------------------------------------------------,

I

Format

I

~----------------------------------------------------------------------~

I
I
I
DELETE file-name RECORD
I
I
I
I
[INVALID KEY imperative-statement]
I
IL ______________________________________________________________________ JI
When the DELETE statement is e*ecuted, the %ssocjated fi.e must be
open in 1-9 mode
File-'name'must be defined in an FD entry in the Data Division" and
must be the name of an indexed VSAM file.
For a file in sequential access mode, the INVALID KEY option must not
be specified.
For a file in random or dynamic access mode, the INVALID KEY option
may be specified.
For a file in sequential access mode, the last prior input/output
statement must be a successfully executed READ statement. When the
DELETE statement is executed, the system logically removes the record
retrieved by that READ statement. The current record pointer is not
affected by execution of the DELETE statement.
For a file in random or dynamic access mode, when the DELETE
statement is executed, the system logically removes the record
identified by the contents of the associated RECORD KEY data item.
If
the file does not contain the record specified by the key, an INVALID
KEY condition exists.
(See "INVALID KEY Condition" in the preceding
Common Processing Facilities section.)

xx

After successful execution of a DELETE statement, the record is
logically removed from the file and can no longer be accessed.
Execution of the DELETE statement does not affect the contents of the
record area associated with file-name.
If the FILE STATUS clause is specified in the File-Control entryu the
associated Status Key is updated when the DELETE statement is executed.

~SE State~
The CLOSE statement terminates the processing of VSAM files.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------i

I

1

I
~ file-name-l [WITH LOCK]
]
I
,
I
I
[file-name-2 [WITH LOCK]]
..
L
Il ______________________________________________________________________ JI
A CLOSE statement may be executed only for a file in an open mode.
After successful execution of a CLOSE statement. the record area
associated with the file-name is no longer available.
Unsuccessful
execution of a CLOSE statement leaves availability of the record area
undefined.
Each file-name designates a file upon which the CLOSE statement is to
operate.,
When the WITH LOCK option is not specified, standard system closing
procedures are performed. This file may be opened again during this
execution of the object program a
When the WITH LOCK option is specified. standard system closing
procedures are performed; the compiler ensures that this file cannot be
opened again during this execution of this object program.
After a CLOSE statement is successfully executed for the file, an
OPEN statement for that file must be executed before any other
input/output statement can refer explicitly or implicitly to the file.
If a CLOSE statement is not executed for an open file before a STOP
RUN statement is executed, results are unpredi~table.
If an input sequential VSAM file is described in the File-Control
entry as OPTIONAL and the file is not present during this execution of
the object program, standard end-of-file processing is not performed ..
If the FILE STATUS clause is specified in the File-Control entryu the
associated Status Key is updated when the CLOSE statement is executed.
If the file is in an open status and the execution of a CLOSE
statement is unsuccessful, the EXCEPTION/ERROR procedure (if specified)
for this file is executed.

(MERGE FACILITY1
The Merge Facility gives the COBOL user access to the merging
capabilities of the Program Product DOS/vS Sort-Merge (Program Number
5746-SM1). Through COBOL, the user can combine two or more identically
DOS/VS COBOL Considerations

xxi

ordered input files into one output file according to keyes) contained
in each record. More than one merge operation can be performed during
one execution of the COBOL program. Special processing of output
records can also be specified.
There are special considerations in the Environment Division. the
Data Division. and the Procedure Division for the Merge Facility.

ENVIRONMENT DIVISION
Each input file and the resulting merged output file must
described in a separate File-Control entry. and each must be
sequential file, or a VSAM file with sequential access. The
must have a separate File-Control entry, as described in the
paragraphs.

be
a standard
merge file
following

File-Control Entry forferge F11e¢)
The File-Control entry names the merge file and associates it with a
storage medium.

r----------------------------------------------------------------------,
General Format
I

I

~----------------------------------------------------------------------i

I
)
I
{SELECT file-name
J
I
]
I
ASSIGN TO system-name-l [system-name-21 •••• }...
J
IL_______________________________________- - - - - -_________- - - - - - - - - -______ JI
Each File-Control entry for a merge file must begin with a SELECT
clause. and be immediately followed by an ASSIGN clause. There may be
no other clauses.
SELECT Clause: The SELECT clause names each merge file in the program.
Each file described by an SD entry in the Data Division must be named
once and only once as a file-name following the key word SELECT.
ASSIGN Clause: The ASSIGN clause is required. System-name has the same
rules of formation as it has for sort work files; however, the fixed
SYSnnn and name fields (SYSOOl and SORTWK1. etc.) are treated as
documentation:- (See "Assignment of Sort Work units" in the Sort Feature
chapter.)
If an ASCII-collated merge is to be performed, C must be specified in
the organization field.
(See "Appendix E: ASCII Considerations.")

I-O-Control Paragraph
The optional I-a-Control Paragraph specifies the storage area to be
shared by different files.

xxii

r------------------------------------------------------~---------------,

I

General Format
]
~----------------------------------------------------------------------~

I

II

SAME

{~g:;-MERGEl

I

I

AREA FOR

RECORD

]

I
I
I
file-name-l [file-name-2] ••• •
I
IL_____________________________________ ----------------________________ -JI
When the SAME SOR~ AREA or SORT-MERGE AREA clause is specified, at
least one file-name specified must name a sort or merge file.
Files
that are not sort or merge files may also be specified. The following
rules apply:
• More than one SAME SORT AREA or SORT-MERGE AREA clause may be
specified; however, a sort or merge file must not be named in more
than one such clause.
• If a file that is not a sort or merge file is named in both a SAME
AREA clause and in one or more SAME SORT AREA or SORT-MERGE AREA
clauses, all of the files in the SAME AREA clause must also appear
in all of the SAME SORT AREA or SORT-MERGE AREA clausesG
• Files named in a SAME SORT AREA or SORT-MERGE AREA clause need not
have the same organization or access.
• Files named in a SAME SORT AREA or SORT-MERGE AREA clause that are
not sort or merge files do not share storage with each other unless
the user names them in a SAME AREA or SAME RECORD AREA clause.
The SAME SORT AREA or SORT-MERGE AREA clause specifies one storage
area available for merge operations by each named merge file.
That is,
the storage area allocated for one merge operation is available for
reuse in another merge operation.
The function of the SAME SORT AREA or SORT-MERGE AREA clause is to
optimize the assignment of storage areas to a given MERGE statement.
The system handles storage assignment automatically; hence, the SORT
AREA or SORT-MERGE AREA options, if specified, are treated as
documentation ..
when the SAME RECORD AREA option is specified, the named files,
including any sort or merge files, share only the area in which the
current logical record is processed.
Several of the files may be open
at the same time, but the logical record of only one of these files can
exist in the record area at one time.

DATA DIVISION
In the Data Division, the user must include file desc~iption entries
for each merge input file and for the merged output file, merge-file
description entries for each merge file, and record description entries
for each.

cJier~-Fiii)DescriPtion

Entry

A merge-file description entry must appear in the File section for
each merge file named in a File-Control entry.
DOS/VS COBOL Considerations

xxiii

SD Entry for

r~erqe

(DOS/VS)

r----------------------------------------------------------------------,
General Format
I

I

r---------------------------------------------------------------------~

SD

merge-file-name

J
I

[RECORD CONTAINS [integer-l TO] integer-2 CHARACTERS]

1

J

~

[DATA

rtECORD
{

IS

}

data-name-i [data-name-2] ••• ]

RECORDS ARE

[SORT-OPTION IS data-name-3].

J
]

I
I

1

I

----------------------------------------------------------------------~

The level indicator SD identifies the beginning of the merge-file
description. and must precede the merge-file-name.
The clauses following merge-file-name are optional. and their order
of appearance is not significant.
One or more record description entries must follow the merge-file
description entry. but no input/output statements may be executed for
the merge file.
Merge-File-Name: The merge-file-name must be the same as that specified
in the merge file File-Control entry. It is also the name specified as
the first operand in the MERGE statement.
RECORD CONTAINS Clause: The size of each data record is completely
defined in the record description entry; therefore. this clause is never
required. When it is specified. the same considerations apply as in its
Data Division description.
DATA RECORDS Clause: This clause names the 01-level data records
associated with this SD entry.
This clause is never required. and the
compiler treats it as documentation. When it is specified. the same
considerations apply as in its Data Division description.
SORT-OPTION Clause: This clause specifies that at object time an OPTION
control statement for the Sort/Merge program will be specified in the
data-name-3 area. Rules for specification are given in the DOS/VS Sort
Feature description later in this chapter.

PROCEDURE DIVISION
The Procedure Division contains a MERGE statement describing the
merge operation, and optional output proceduresu The procedure-names of
the output procedures are specified within the MERGE statement. More
than one MERGE statement can be specified, appearing anywhere except in
the declaratives section or in an input or output procedure for a SOR~
or MERGE statement.

C3 Statemen~
The MERGE statement combines two or more identically sequenced files
using specified keyes). and makes records available to an output file in
merged order.

xx~v

r----------------------------------------------------------------------,

I
I
I .-Ib
Format
I
~-~-------------------------------------------------------------------~
~

-

ON

file-naffie-l
ASCENDING ~
{ DESCENDING/

KEY

data-name-l [data-name-2]

(ASCENDING )
\ KEY data-name-3 [data-name-4]
~ DESCENDING j

[ON~

USING file-name-2 file-name-3 [file-name-4]

..•

•.. ] ••.

•••

GIVING file-name-5

}

{ OUTPUT PROCEDURL IS section-name-l [THRU section-name-2]

No file-name specified in the MERGE statement nlay be open at the time
the statement is executed. The files 'are automatically opened and
closed by the merge operation; all implicit functions are performed,
such as execution of system procedures or any associated declarative
procedures.
No file-name may be specified more than once in one Ivll:.RGi: statement.
Only one file-name from a mUltiple file reel may appear in one
statement.

~E;RGE

FILE-NAME-l:
This file-name represents the merge file, and must be
described in an SD entry in the Data Division.
ASCENDING/DESCENDING KEY Option:, These options specify whether records
are to be merged in ascending or descending sequence, based on one or
more merge keys.
Each data-name represents a KEY data item, and must be described in
the record description(s) associated with the SD entry for file-name-l,
the merge work file. The following rules apply:
• if file-name-l has more than one associated record description
entry, the KEY data items need be described in only one such record
description
• each data-name may be qualified; it may not De subscripted or
indexed (that is, it may not contain or be contained in an entry
that contains an OCCURS clause)
• KEY data items must be at a fixed displacement from the beginning of
the record (that is, no KEY data item may follow an OCCURS DEPENDING
ON clause in the record description)
• a maximum of 12 keys may be specified; the total length of all keys
must not exceed 256 bytes
• all key fields must be located within the first 4092 bytes of the
logical record
The KEY data items are listed in order of decreasing significance, no
matter how they are divided into KEY phrases.
Using the format as an
example, data-name-l is the most significant key, and records are rr,ersed
in ascending or descending order o~ that key; data-name-2 is the next
most significant key; within data-name-l, records are merged on
DOS/VS COBOL Considerations

xxv

data-name-2 in ascending or descending order.
Within data-name-2,
records are merged on data-name-3 in ascending or descending order;
within data-name-3, records are merged on data-name-4 in ascending or
descending order, etc.
When ASCENDING is specified, the merged sequence is from the lpwest
to the highest value of the contents in the KEY data item accoiding to
the collating sequence used.
When DESCENDING is specified, the merged sequence is from the highest
to the lowest value of the contents in the KEY data item according to
the collating sequence used.
Figure V gives the collating sequence used for each category of KEY
data item.

r------------------------------T---------------------------------------,
KEY Category
I Collating Sequence
I

I

~------------------------------+---------------------------------------~
I

I
I
I

Alphabetic
Alphanumeric
Alphanumeric Edited
Numeric Edited

I

I

I

I

I

EBCDIC (non-algebraic and unsigned)

I

I
I

~------------------------------+---------------------------------------~

IL ______________________________
Numeric
Algebraic (signed)
i I _______________________________________
JI

Figure

V.

KEY Item Categories and Collating Sequences

The rules for comparison are those for the relation condition (see
"Relation Condition II in the Conditions chapter of the Procedure
Division). If two or more KEY data items test as equal, the merge
operation makes the records available in the order that the input
file-names are specified in the USING option.
USING Option: All file-names listed in the USING option represent
identically ordered input files that are to be merged. Two through
eight file-names may be specified.
GIVING Option: File-name-5 is the name of the merged output file.
When
this option is specified, all merged records made available from the
merge operation are automatically written on the output file.
OUTPUT PROCEDURE Option: When this option is specified, all output
records from the merge operation are made available to the user (through
a RETURN statement) for further processing.
When an output procedure is specified, control passes to the
procedure during execution of the MERGE statement. Before entering the
output procedure, the merge operation reaches a point at which it can
provide the next merged record when requested. The RETURN statement in
the output procedure is a request for the next merged record.
(See the
RETURN statement description in the Sort Feature chapter.) An output
procedure must contain at least one RETURN statement to make merged
records available for further processing.
Control may be passed to an output procedure only when a related
MERGE statement is being executed.
The output procedure must not form part of any other procedure.
If section-name-l alone is specified, the output procedure must
consist of one contiguous Procedure Division section.
If section-name-l THRU section-name-2 is specified, the output
procedure consists of two or more contiguous Procedure Division
sections; section-name-l specifies the first such section;
section-name-2 specifies the last such section.
xxvi

",

<

~.."

" •

..'

"

•

, ;

.:,':.f •

~:~~~":~~R ""t?~cis~~s~"~~: _J J)q.s/v~)
Control must not be passed to the output procedure unless a related
MERGE or SORT statement is being executed, because RETURN statements in
the output procedure have no meaning unless they are controlled by a
MERGE or SORT statement. The output procedure may consist of the
processing requests necessary to select, modify, or copy the records
being made available, one at a time, from the merge operation. The
following restrictions apply:
• There may be no explicit transfers of control outside the output
procedure. ALTEH, GO TO, and PERFORM statements within the
procedure must not refer to procedure-names outside the output
procedure. However, an implicit transfer of control to a
declarative procedure is allowed.
• No SORT or MERGE statements are allowed.
• The remainder of the Procedure Division must not transfer control to
points inside the output procedure; that is, ALTER, GO TO, and
PERFORM statements in the remainder of the Procedure Division must
not specify procedure-names within an output procedure.
The compiler inserts an end-of-processing transfer at the end of th~
last output procedure section. When end-of-processing is recognized,
the merge operation is terminated, and control is transferred to the
next statement following the MERGE statement.
SEGMENTATION RESTRICTIONS: The MERGE statement may be specified in a
segmented program.
However, the following restrictions apply:
• If the MERGE statement appears in the fixed portion, then any
associated output procedure must be:
- completely within the fixed portion, or
- completely within one independent segment
• If the MERGE statement appears in an independent segment, then any
associated output procedure must be:
- completely within the fixed portion, or
- completely within the same independent segment as the
statement
3886 OCR PROCESSING

L

Df)c."",e n r

~£RGE

J

re. .tle.r

The IBM 3886 OCR (Optical Character Reader) Model 1 is a general
purpose online unit record device that satisfies a broad range of data
entry requirements. The 3886 OCR can significantly reduce time and ccst
factors, by eliminating input steps in both new and existing
applications; a keying process is no longer necessary, since the 3886
OCR can read and recognize data created by numeric hand printing,
high-speed computer printing, typewriters, and preprinted forms.
The IBM 3886 OCR uses several new technologies which make it a
compact, highly reliable, modular device. A powerful microprogrammed
recognition and control processor performs all machine control and
character recognition functions, and enables the 3886 OCR to perform
sophisticated data and blank editing.
The 3886 OCR accepts documents from 3 x 3 to 9 x 12 inches in size.
Under program control, it can read documents line-by-line, transmitting
their contents line-by-line to the CPU. Additional facilities, all
under program control, include: document marking, line marking,
document ejecting (with stacker selection), and line reading (of current
line).
DOS/VS COBOL Considerations

xxvii

DOS/VS COBOL support for the 3886 OCR is through an object-time
subroutine in the COBOL lihrary, invoked through COBOL CALL statements.
By means of parameters passed to the subroutine, the following
operations are provided: open and close the file, read a line, wait for
read completion, mark a line, mark the current document, eject the
current document, and load a format record. After each operation, a
status indicator is passed back to the COBOL program, so that any
exceptional condition can be tested.
Through a fixed format OCR file information area in the
Working-Storage or Linkage Section, the COBOL user defines storage for
the OCR parameters. Of these parameters, the COBOL programmer is
responsible for providing a file identifier, a format record identifier,
an operation code, and (depending on the operation) a line number, line
format number, mark code, and stacker number. After completion of each
operation a status indicator is returned; after completion of a read
operation, header and data records are also returned.
DOS/VS provides two macro instructions for defining documents.
The
DFR macro instruction defines attributes common to a group of line
types. The DLINT macro instruction defines specific attributes of an
individual line type. The DFR and associated DLINT macro instructions
are used in one assenbly to build a format record module. The format
record must be link-edited into the core image library so that it can be
loaded into the 3886 OCR when the file is to be processed. The forRat
record indicates the line types to be read, attributes of the fields in
the lines, and the format of the data records to be processed.
Additional information on the IBM 3886 OCR can be found in the following
publications:
IBM DOS/vS COBOL Compiler and Library Programmer's Guide, Order
No. SC28-6478
IBM 3886 Optical Character Reader
General Information Manual, Order No. GA21-9146
Input Document Design Guide and Specifications, Order No. GA21-9148
DOS/VS Program Planning Guide for IBM 3886 Optical Character
Reader Modell, Order No. GA21-S099
DOS/VS Supervisor and I/O Macros, Order No. GC33-S373

FIPS FLAGGER
The FIPS (Federal Information Processing Standard) is a compatible
subset of full American National standard COBOL, X3.23-1968. The FIPS
itself is subdivided into four levels: low, low-intermediate,
high-intermediate, and full.
Any program written to conform to the FIPS
must conform to one of those levels of FIPS processing. Processing
modules included in Full American National Standard COBOL, and those
included in the four levels of the FIPS, are shown in Figure VI.
xxviii

r-------------T----------T-----------------T----------------T----------,

I American
I National

I
I
I
I
I
I
I
I
I
IFull FIPS 1High-intermediate I Low-intermediate I Low FIPS
I

I
I

I standard

I COBOL

I Processing

I
1
J

1

IProcessinglFIPS Processing IFIPS Processing IProcessingl
\ Modules
jModules
I Modules
1
~-------------+----------+-------~---------+----------------+----------~
I 2NUC 1112
I 2NUC 1,2 I
2NUC 1,2
l
2NUC 1,2
I 1NUC 1,2 I
I (Nucleus)
I
I
I
)
1

I Modules

I Modules

I
I 3TBL 1" 3
I (Table
I
Handling)
I

I
I
I 3TBL 1,3 I
I
I
I
I
I
I

I 2SEQ 1,,2
I 2SEQ 1,2 I
(Sequential I
I
Access)
I
I

I
I
I
I
I
I
I
I

2TBL 1,3

1
I

2TBL 1,3

J

2SEQ 1,2

1
I
1

2SEQ 1,2

I
I 1 TBL 1, 3
I
i
I
I lSEQ 1,2

I
l
1
1
I

1

I
I
1
1
1
I
I
I
I ]
2RAC 0" 2
I 2RAC 0, 2 I
2RAC 0, 2
~
2RAC 0, 2
l
]
(Random
I
I
I
I
1
Access)
I
I
1
1)
I
1
I
I ]
2SRT 017 2
I 2SR'T 0,2 I
lSR'l' 0,2
J
11
I (Sort)
I
I
t i l
I
I
I
I
I
J
I 2RPW 0",2
I
I
l
I
I
I (Report
I
I
~
I
l
I
Writer)
I
I
!
I
I
I
I
I
]
I
1
I 2SEG 0,2 I
lSEG 0,2
I
lSEG 0,2
I
f
I 2SEG 0",2
I (Segmenta- I
I
1
I ]
I
tion)
I
I
J
I
1
I
I
I
I
I
1
I 2LIB 0,,2
! 2LIB 0,2 I
1LIB 0,2
I
lLIB 0,2
I
I
IL_____________
(Library)
I__________ I_________________ 1________________ I__________ JI
~

Figure VI.

~

J

~

~

The Four Levels of FIPS Processing

The FIPS Flagger identifies source clauses and statements that do not
conform to the Federal standard. Four levels of flagging, to conform to
the four levels of the FIPS, are provided. The following lists identify
COBOL source elements flagged for each levelQ
FULL FIPS FLAGGING: When flagging for the full FIPS level is specified,
the following elements of the COBOL source, if specified, are
identified.
GLOBAL ITEMS
Single quote instead of double
Floating Point Literals
special
Special
Special
Special
Special
Special
Special
Special
Special
Special
Special

Register
Register
Register
Register
Register
Register
Register
Register
Register
Register
Register

LINE-COUNTER
PAGE-COUNTER
CURRENT-DATE
TIME-OF-DAY
COM-REG
SORT-RETURN
SORT-FILE-SIZE
SORT-CaRE-SIZE
SORT-MODE-SIZE
NSTD-REELS
WHEN-COMPILED

Comment Lines with * in Column 7
The SUPPRESS option of the COpy statement
DOS/VS COBOL Considerations xxix

IDENTIFICATION DIVISION Items
ID abbreviation for IDENTIFICATION
Accepting Identification Division Paragraphs in any order
Accepting Program Name in quotes
ENVIRONMENT DIVISION Items
Optional CONFIGURATION SECTION and Paragraphs
SOl through S05 Function~names in SPECIAL-NAMES paragraph
Allowing any order for optional SELECT clauses
w, R, or I as Organization indicator in System-name
Ootional omission of IS in-ACCESS MODE IS Clause
Optional omission of IS in ACTUAL KEY IS Clause
ACTUAL-KEY clause for sequential access of a direct file
ACTUAL-KEY clause for sequential creation of a direct File
NOMINAL KEY Clause in FILE-CONTROL paragraph
RECORD KEY Clause in FILE-CONTRCL Paragraph
TRACK-AREA Clause in FILE-CONTROL Paragraph
The COpy statement in the FILE-CONTROL paragraph
Short form of RERUN ON Clause
Interchangeable use of REEL and UNIT in RERUN ON Clause
APPLY Clause in I-O-CONTROL paragraph
Allowing I-O-CONTROL paragraph clauses in any order
RESERVE integer AREAS clause (as distinguished from the RESERVE
ALTERNATE AREAS clause)
ORGANIZATION clause
ACCESS MODE DYNAMIC clause
PASSWORD clause
FILE STATUS clause
SAME SORT-MERGE AREA clause
DATA DIVISION Items
REPORT SECTION of DATA DIVISION
RD level indicator
The DATA RECORDS clause for a REPORT FD
LINKAGE SECTION of DATA DIVISION
Allowing unequal level numbers to belong to the same group
RECORDING MODE Clause of FD entry.
REPORT Clause of FD Entry
LABEL RECORDS CLAUSE on Sort File Description
SORT-OPTION clause on Sort File Description
Optional BLOCK CONTAINS for DIRECT Files when RECORDING MODE IS S
Accepting name of preceding entry when using multiple redefinition
External Floating-point picture
The SIGN Clause
Allowing the SYNCHRONIZED Clause at the 01 level
COMPUTATIONAL-1 option of the USAGE Clause
COMPUTATIONAL-2 option of the USAGE Clause
COMPUTATIONAL-3 option of the USAGE Clause
COMPUTATIONAL-4 option of the USAGE Clause
Nested OCCURS DEPENDING ON clauses
Allowing SYNCHRONIZED with USAGE IS INDEX
The COpy statement in the Working-Storage Section
DISPLAY-ST option of the USAGE Clause and associated PICTURE
Use of VALUE Clause as Comments in File Section for other than
Condition-name entries
COpy REDEFINES in Working-Storage Section

xxx

PROCEDURE DIVISION Items
USING clause on PROCEDURE DIVISION
THEN used to separate statements
Allowing omission of section header at beginning of Procedure
Division
The START statement
The REWRITE statement
The TRANSFORM statement
The GENERATE statement
The INITIATE statement
The TERMINATE statement
The
The
The
The
The
The
The
The
The

DEBUG statement
READY TRACE statement
RESET TRACE statement
ON statement
EXHIBIT statement
CALL statement
ENTRY statement
GO BACK statement
EXIT PROGRAM statement

The
The
The
The
The
The

USE AFTER STANDARD EXCEPTION sentence
READ NEXT statement
DELETE statement
MERGE statement
EXTEND option for the OPEN statement and Error Procedures
SERVICE RELOAD statement

The unary plus operator
Allowing omission of the space following the unary operator
OTHERWISE in IF statements
The GO TO MORE-LABELS statement
GIVING option of USE sentence
USE BEFORE REPORTING sentence
Allowing omission of the INVALID KEY option for READ and WRITE
statements
The AT END-OF-PAGE or EOP option of the WRITE statement
The WRITE AFTER POSITIONING statement
The FROM SYSIPT or CONSOLE option of the ACCEPT statement
The UPON CONSOLE, SYSPUNCH w SYSPCH. or SYSLST option of the DISPLAY
statement
The BASIS statement
The INSERT statement
The DELETE statement
The
The
The
The

EJECT
SKIPl
SKIP2
SKIP3

statement
statement
statement
statement

HIGH-INTERMEDIATE FIPS FLAGGING: When flagging for the
high-intermediate FIPS level is specified, all elements included in the
preceding list are flagged, plus the following additional COBOL source
elements:
GLOBAL ITEMS
The REPLACING option of the COPY statement
DOS/VS COBOL Considerations

xxxi

ENVIRONMENT DIVISION
SEGMENT-LIMIT clause in OBJECT-COMPUTER paragraph
SORT option of SAME Clause
DATA DIVISION
The ASCENDING and DESCENDING KEY option of the OCCURS clause
The DEPENDING ON option of the OCCURS clause
PROCEDURE DIVISION
All sections with the same priority number must be together
All segments with priority number 1-49 must be together
The SEARCH statement
More than one SORT statement
The FROM option of the RELEASE statement
The INTO option of the RETURN statement
LOW-INTERMEDIATE FIPS FLAGGING: When flagging for the low-intermediate
FIPS level is specified, all elements included in the preceding lists
are flagged, plus the following additional COBOL source elements:
ENVIRONMENT DIVISION
The OR option of the SELECT sentence
DATA DIVISION
SD level indicator
PROCEDURE DIVISION
One or more SORT statements
Only one STOP RUN statement in the non-declarative portion
The RETURN statement
The RELEASE statement
LOW FIPS FLAGGING: When flagging for the low FIPS level is specified,
all elements included in the preceding lists are flagged, plus the
following additional COBOL source elements:
GLOBAL ITEMS
Comma and semicolon as punctuation
Datanames which begin with non-alphabetic character
continuation of words and numeric literals
Figurative constant
Figurative constant
Figurative constant
Figurative constant
Figurative constant
Figurative constant
Figurative constant
The COpy statement

ZEROES
ZEROS
SPACES
HIGH-VALUES
LOW-VALUES
QUOTES
ALL literal

IDENTIFICATION DIVISION
DATE-COMPILED Paragraph

xxxii

ENVIRONMENT DIVISION
RESERVE ALTERNATE AREAS Clause in File-Control Paragraph (SELECT
sentence)
OPTIONAL in SELECT Clause
ACTUAL KEY Clause in File-Control Paragraph
FILE-LIMITS ARE Clause
Data-name instead of literal in FILE-LIMIT IS clause
Multiple extents in FILE-LIMIT IS clause
RANDOM option in ACCESS MODE IS Clause
RECORD and file-name-2 option of SAME Clause
MULTIPLE FILE TAPE Clause in I-O-CONTROL Paragraph

DATA DIVISION
Level numbers 11 - 49
Level numbers 1 - 9 (i-digit)
Level number 66 RENAMES clause
Level number 88 Condition Name
Nesting of REDEFINES Clause
VALUE Clause as Condition-name entry
Integer-l TO option of BLOCK CONTAINS (RECORD or CHARACTER) Clause
Data-name option on LABEL RECORDS Clause
Data-name option of VALUE OF Clause
Multiple Index-names for OCCURS clause

PROCEDURE DIVISION
+, -,

*, /,

and

**

>, <, and = in relationals
Connectives OF, IN, " D, AND, OR, and NOT
DECLARATIVES, END DECLARATIVES and USE sentence
Qualification of names
priority number on Section header
The COMP~TE verb
The SEEK Statement
The Sign condition (POSITIVE, NEGATIVE, or ZERO)
Condition-name condition
Compound conditions
Nested IF statements
CORRESPONDING option (ADD, SUBTRACT, and MOVE)
Multiple results of ADD and SUBTRACT statements
REMAINDER option of DIVIDE statement
GO TO without object (used with ALTER)
Multiple operands of ALTER statement
UNTIL Condition and VARYING form of PERFORM
REVERSED and NO REWIND options of OPEN statement
Multiple file-names in OPEN statement
INTO option of READ statement
INVALID KEY option of READ statement
FROM option of WRITE statement
ADVANCING identifier LINES/mnemonic/name form of WRITE
The FROM option of the ACCEPT statement
The UPON option of the DISPLAY statement
The WITH NO REWIND or LOCK option of the CLOSE statement
Multiple file-names in a CLOSE statement
Three levels of subscripting
Multiple Index-names/identifier in SET statement
The UP BY and DOWN BY option of the SET statement

DOS/VS COBOL Considerations

xxxiii

MISCELLANEOUS FILE PROCESSING CONSIDERATIONS
The following ite~s, concerning standard sequential, direct, and
indexed file processing, as well as the sort feature, apply only for
DOS/VS COBOL.

File Processing Summary -- New Devices
The file processing techniques available for the DOS/VS COBOL devices
are summarized in Figure VII.

r-----------------T----------------T-----------------T-----------------,
I ACCESS
I Organization
I

IDOS Organization I Device

~-----------------+----------------+-----------------+-----------------~

I 5425
[SEQUENTIAL]
I
I
DTFPR
I 3203/5203,
(SEQUENTIAL]
I 5425
I
DTFDU
I 3540
[SEQUENTIAL]
I
I
DTFSD
I 3340
[SEQUENTIAL]
I
I
DTFDA
I 3340
[SEQUENTIAL]
I
DTFDA
I 3340
RANDOM
I
DTFIS
I 3340
[SEQUENTIAL]
I
DTFIS
3340
RANDOM
_________________
iI ________________
i _________________
i
DTFCD

Figure VII.

Standard
Sequential

Standard
Sequential
Standard
Sequential
Standard
Sequential
direct
direct
indexed

ASSIGN Clause
For the new DOS/VS COBOL devices. system/name has the following
formats:
For the 3203/5203 printers:
3203}
{

-S[-name]

5203

For the 5425 multifunction card unit:

SYSnnn-UR-5425

{~}

-

[-name J

(See the ASSIGN Clause description for the 2560 MFCM for the meaning of
each field .. )
xxxiv

J

I
I
I
I
I
I
I
I
I
I
J

I
I
]

I
indexed
_ ________________
JI

File Processing Summary -- DOS/VS COBOL Devices

SYSnnn-UR-

J

I

For the 3540 diskette input/output unit:
SYSnnn- { DDT
A} -3540-S[-name]
For the 3340 mass storage disk facility:

SYSnnn-

[-name]

DOS/VS COBOL Considerations

xxxiv.i

~lause
When the 3340 device is specified for a direct file. and actual track
addressing is used, the first 8 bytes of the ACTUAL KEY may be specified
as follows:

r-----------T-----------T-----------T-----------T-----------,

I

PACK
I
CELL
I CYLINDER I
HEAD
I RECORD
I
I-~---------+-----------+-----------+-----------+-----------~

I

M

I

B

B

IC

ci

H

H

I

R

I

r----------+-----------+-----------+-----------+-----------t----------~
I
Byt e I
1\ 2
3
I4
51
6
7
I
8
l

i

I
I

I
I

I
I

I 3340
I
I (Mod 35) I

J

I

I Device

I i i
J
1
I

r----------+-----------+---------~-+-----------+-----------+-----------~
0-221
I 0
0 I 0-347
I
0~11
10--255
I

I

I

I

~----------+-----------+-----------+-----------+-----------+-----------~
I 3340
I
0-221
I 0
0 I 0-695
I
0-11
] 0- 255
I
I (Mod
70) I ___________ I ___________ I ___________ I ___________ 1___________ JI
________
l_~

~

~

~

~

~

APPLY WRITE-VERIFY Clause
For the 3540 diskette input/output unit. this clause has no meaning,
and must not be specified.

"

APPLY CYL-OVERFLOW Clause
For a 3340 mass storage facility, when-the APPLY CYL-OVERFLOW clause
is specified, the maximum number of tracks that can be reserved for
overflow records is 10. If the clause is not specified, 2 tracks are
reserved for overflow records.

BLOCK CONTAINS Clause
For a file on the 3540 diskette input/output unit, when the BLOCK
CONTAINS clause is specified, the RECORDS option must be used.

LABEL RECORDS Clause
For a file on the 3540 diskette input/output unit, LABEL RECORDS ARE
STANDARD must be specified.

ERROR Declarative
When the GIVING option is specified for a file on the 3540 diskette
input/output unit, the error bytes in data-name-l contain the
information shown in Figure VIII.
(For the 3340 device, the contents of
the error bytes are the same as for other mass storage files.)
DOS/VS COBOL Considerations xxxv

r---------------------------------T------------------------------------,

I

Error Byte

I

Meaning

I

~---------------------------------+------------------------------------~

I

1
I
data check
J
~-~-------------------------------+------------------------------------~
I
2
I
equipment check
I
~---------------------------------+------------------------------------~
Il _________________________________
3 thru 8
j ____________________________________
unused
JI
~

Figure VIII.

..ACCEPT

Error Bytes for 3540 -- GIVING Option

Literal statement

When FROM CONSOLE is specified, the input data can be typed in either
capital or small letters, or a combination of the two.
The program
accepts the data as capital letters.

OPEN Statement
A file that resides on the 3540 diskette input/output unit may be
opened only in the INPUT or OUTPUT mode; the REVERSED and WITH NO REWIND
options may not be specified.

WRITE Statement
For a file on the 3540 diskette input/output unit, the INVALID KEY
option must not be specified.
For a file on the 5425 MFCU, the System/370 Card Device
considerations as described in the WRITE Statement of the Procedure
Division chapter apply, with the following additional rules:
• For the print feature, the ADVANCING/POSITIONING options are not
allowed; single spacing is automatically provided.
• For the print feature, there may be only one WRITE statement issued
for each card.
• The print feature allows a maximum of 32 characters per line and 3
or 4 lines per card, for a maximum of 128 characters.
• For the punch feature, in the WRITE AFTER ADVANCING staterrent for
stacker selection, function-names SOl through S04 may be specified.
• For the punch feature, in the WRITE AFTER POSITIONING statement for
stacker selection, V, W, X, Y may be specified for stac~ers 1
through 4, respectively.

CLOSE Statement
For a file on the 3540 diskette input/output unit, only the CLOSE
file-name and CLOSE file-name WITH LOCK options are validq
When the CLOSE statement is executed, standard close file procedures
are performed, and the diskette is fed out of the input/output unit.
When the WITH LOCK option is specified, the compiler ensures that this
file cannot be opened again during this execution of the object program.
xxxvi

Page of GC28-6394-4, -5, -6 revised 12/Q3/76 by TNL GN26-0887

1:_ _ltl.:::~:::9.jji.I¥I_ _.I.';@il.J.II.Jf
Sort Feature
The in~ut and/or output file can be either a standard sequential file
or a sequentially accessed VSAM file.
Up to a input files may be
specified in the USING option.
The sort-file-description entry may be specified as follows:

r----------------------------------------------------------------------,
Format
I

I

~---------------------------------------------------------------------~
SD sort-file-name
~

I
I
I

i
~

[RECORDING MODE IS mode)

II

I
I
I
I
II

I

[DATA

{RECORD IS

}

data-name-l

[data-name-2] ••• ]

~

RECORDS ARE

~

~

[RECORD CONTAINS [integer-l TO] integer-2 CHARACTERS]
[LABEL

1!

{RECORD IS}

{STANDARDf

~
)'

RECORDS ARE

'- OMITTED ,

I

i

1

J

1L ______________________________________________________________________
[SORT-OPTION IS data-name-3].
JU

The SORT-OPTION clause specifies that at object time an OPTION
control statement for the Sort/Merge program will be specified in the
data-name-3 area.
Data-name-3 must be a field defined in the WORKING-STORAGE section.
A full description of the SORT-OPTION clause can be found in the
DOS/VS COBOL Programmer's Guide, SC28-6478.
The other clauses of the sort-file-description entry are implemented
as described in the Sort Feature chapter.
5425 Combined Function Processing
The descriptions in Appendix G apply, with the following special
considerations:
In the SPECIAL-NAMES paragraph, function-names SOl through S04 may be
specified for stacker selection of 5425 punched output.
ASSIGN clause considerations for the 2560 MFCM apply also for the
5425 MFCU.
For the
specified,
maximum of
specified,

5425 print function WRITE statement, line control may not be
and there may be only one WRITE statement issued per card. A
32 characters per line, and 3 or 4 lines per card may be
for a maximum logical record size of 128 characters.

For the punch function, SOl through S04 (for stacker selection 1
through 4, respectively) may be specified in the WRITE ADVANCING
statement.
For the punch function, V, w. X~ Y (for stacker selection 1 through
4, respectively) may be specified in the WRITE AFTER POSITIONING
statement~

DOS/VS COBOL Considerations

xxxvi.i

FEATURES OF THE DOS FULL COBOL

PROGRfu~

?RODUCT COMPILERS

Features of the DOS Full COBOL Program Product Compilers

11

DOS FULL AMERICAN NATIONAL STANDARD COBOL VERSION 3:
Product Compiler includes the following features:
Release 3:

this Program

The following features are included in this release:

• Additional System/370 Device Support -- including the following:
(1) 2560 Multifunction Card Machine MFCM) -- for 80-column
cards. Read/punch/print/select features, and combined
function processing are supported. Without the combined
function processing feature, the 2560 MFCM can be used as a
backup reader or as a punch.
(2) 3504 Reader with OMR (Optical Mark Read) feature -- the
compiler can use the 3504 without the OMR feature as the
SYSIP~ device.
(3) 3881 Optical Mark Reader (OMR) -- which reads hand-written
or machine-printed marks on paper documents. When equi~ped
with the optional BCD feature, the 3881 OMR can also read
binary coding.

12

• Enhanced Corrpiler Output -- including dateg start-time of
compilation and program-id on every source listing page.
Compiler statistics are also available, and the date and time of
compilation are carried as constants in the object module, so
that the object module can be associated with an output listing.
• Maintainability Improvements -- the installation can set the
compiler default options by cataloging them into the source
statement library.
Base Compiler Features: the following features are continued from
Release 1 and Release 2.
• Improvements in Object Code to save main storage:
(1)

Optirrized Object Code
which results, when specified, in
up to 30% space saving in object program generated code
and global tables as compared with Version 2. The space
saved depends on the number of referenced procedure-names
and branches, and on 01-level data names.

(2)

System/370 Support can be requested, to take advantage of
the System/370 instruction set. When such support is
requested, Systero/370 instructions particularly suited to
COBOL prograrnrninq are generated to replace the equivalent
object-time subroutines and instructions needed when
running under System/360. The System/370 instructions
save up to 12% of generated object program spac~, plus the
space no longer needed by the subroutines.

(4)

Improvements in the MOVE Statement and in Comparisons -when a MOVE statement or a comparison involves a one-byte
literal, generated code for the move and the comparison
has been improved.
This saves object program space.

• Alphabetized Cross-Reference Listing (SXREF) -- for easier
reference to user-specified names in a progrruu. SXREF performs
up to 25 times faster than previous Version 2 source-ordered
cross-reference (XREF). Version 3 XREF performance is improved
by at least the same amount. The larger the source program, the
more that performance is improved. Total compilation time is up
to 2 times faster.

Features of the DOS Full COBOL Program Product Compilers

12.1

• Debugging Facilities that are more powerful and flexible
(1)

Symbolic Debug Feature -- which provides a symbolic
formatted dump at abnormal termination, or a dynamic dump
during program execution.

(2)

Flow Trace QQtion -- a formatted trace can be requested
for a variable number of procedures executed before
abnormal termination.

(3)

Statement Number~io~ -- provides information about the
COBOL statement being executed at abnormal termination.

(4)

Expanded CLIST and SYM -- for more detailed information
about the Data Division and Procedure Division.

(5)

Relocation Factor -- can be requested to be included in
addresses on the object code listing for easier debugging.

(6)

Working-Stora~e Location and Size -- When CLIS~ and SYM
are in effect, the starting address and size of
Working-Storage are printed.

• System/370 Device SU2£ort -- the following devices can be
specified:
3211 -- lS0-character printer
2319, 3330

mass storage (direct access) facilities

3410, 3420

tape utility devices

3505, 3525

advanced unit-record devices

• ASCII Support -- allows creation and retrieval of tape files
written in the American National Standard Code for Information
Interchange (ASCII).

:.;"" sepafa:tely,:,'~H·9~;ed",~:utn&:i:a"'"b~i~':WYPe" .• ,":~,:;~;f;~~.:;m~r~!,,;~~~ii)j~~;,:,;IlH~exzi~,'

:;:,gCiZit;a:;:Cl¢,scr'~Ptiqp;:~,:.;Tl!l¢::.£ii,
<

1-1eaning
digit
letter
space
plus sign
minus sign (hyphen)
asterisk
stroke (virgule, slash)
equal sign
currency sign
comma
semicolon
period (decimal point)
quotation mark
left parenthesis
right parenthesis
"greater than" symbol
"less than" symbol

· . ,t.;;fI}iF,i&:f

cOlliot~~ce tli··)~::"stand;~~::cter
wi

s·et·····I·~ ···desired, the·pr·o·grammer must specify the quotation mark (")

through a CBL card at compile time.
If the quotation mark is thus
specified, the apostrophe (I) may not be used.
Note: In addition to these 51 characters, the COBOL compiler will
process (e.g., in a VALUE IS clause or in an IF statement) those
mUltiple characters which function as return codes for CICS.

Characters Used in Words

The characters used in words in a COBOL source program are the
following:

o through 9
A through Z
- (hyphen)
A word is composed of a combination of not more than 30 characters
chosen from the character set for words.
The word cannot oegin or end
with a hyphen.
Structure of the Language

37

Character Set
Characters Used for Punctuation

The following characters are used for punctuation:
Character

" ::::9:it:::::m:~f:
(
)

Meaning
space
corruna
semicolon
period
quotation mark
left parenthesis
right parenthesis

The following general rules of punctuation apply in writing a COBOL
source program:

1.

When any punctuation mark is indicated in a format in this
publication, it is required in the program.

2.

A period, semicolon, or comma, when used, must not be preceded by a
space, but must be followed by a space.

3.

A left parenthesis must not be followed irrunediately by a space; a
right parenthesis must not be preceded irrunediately by a space.

4.

At least one space must appear between two successive words and/or
parenthetical expressions and/or literals. Two or more successive
spaces are treated as a single space, except within nonnumeric
literals.

5.

An arithmetic operator or an equal sign must always be preceded by
a space and followed by a space. A unary operator may be preceded
by a left parenthesis.

6.

A comma may be used as a separator between successive operands of a
statement. An operand of a statement is shown in a format as a
lower-case word.

7.

A comma or a semicolon may be used to separate a series of clauses.
For example, DATA RECORD IS TRANSACTION, RECORD CONTAINS 80
CHARACTERS.

8.

A semicolon may be used to separate a series of statements.
example, ADD A TO B; SUBTRACT B FROM C.

38

Part I

Language Considerations

For

Character Set
Characters Used for Editing

Editing characters are single characters or specific two-character
combinations belonging to the following set:
Character
B

o

+

CR
DB

Z

*
$

Meaning
space
zero
plus
minus
credit
debit
zero suppression
check protection
currency sign
comma
period (decimal point)

(For applications, see the discussion of alphanumeric edited and numeric
edited data items in "Data Division.")

Characters Used in Arithmetic Expressions

The characters used in arithmetic expressions are as follows:
Character
+

*

/

**

Meaning
addition
subtraction
multiplication
division
exponentiation

Arithmetic expressions are used in the COMPUTE statement and in
relation conditions (see "Procedure Division" for more details).

Characters Used for Relation-conditions

A relation character is a character that belongs to the following
set:
Character

>
<

Meaning
greater than
less than
equal to

Relation characters are used in relation-conditions (discussed in
"Procedure Division").

TYPES OF WORDS
A word is composed of a combination of not more than 30 characters
chosen from the character set for words. The word cannot begin or end
with a hyphen.
Structure of the Language

39

Words
The space (blank) is not an allowable character in a word; the space
is a word separator. Wherever a space is used as a word separator, more
than one may be used.
A word is terminated by a space, or by a period, right parenthesis,
comma, or semicolon.

Reserved Words
Reserved words exist for syntactical purposes and must not appear as
user-defined words. However, reserved words may appear as nonnumeric
literals, i.e., a reserved word may be enclosed in quotation n~rks.
When used in this manner, they do not take on the meaning of reserved
words and violate no syntactical rules.
There are three types of reserved words:
1.

Key Words. ~ key word is a word whose presence is required in a
COBOL entry. Such words are upper case and underlined in the
formats given in this publication.
Key words are of three types:
a.

Verbs such as ADD,

b.

Required words, which appear in statement and entry formats,
such as the word TO in the ADD statement.

c.

words that have a specific functional meaning, such as ZERO,
NEGATIVE, SECTION, TALLY, etc.

RE~D,

and ENTER.

2.

Optional Words. within each format, upper case words that are not
underlined are called optional words because they may appear at the
user's option. The presence or absence of each optional word in
the source. program does not alter the compiler's translation.
Misspelling of an optional word, or its replacement by another word
of any kind, is not allowed.

3.

Connectives.

There are three types of connectives:

a.

Qualifier connectives, which are used to associate a data-name
or paragraph-name with its qualifier. The qualifier
connectives are OF and IN (see "Methods of Data Reference").

b.

series connectives, which link two or more consecutive
operands. The series connective is the comma (,).

c.

Logical connectives that are used in compound conditions.
logical connectives are AND, OR, ~ND NOT, and OR NOT (see
"Conditions").

The

Note: Abbreviations (such as PIC for PICTURE) are allowed for some
reserved words; the abbreviation is the equivalent of the complete word.
For the formats in which they are allowable, such abbreviations are
shown in the format.
The reserved. words THRU and THROUGH are
equivalent. In statement formats, wherever the reserved word THRU
appears, the word THROUGH is also allowed.
40

Part I -- Language Considerations

Page of GC28-6394-4, -5, -6 revised 12/03/76 by TNL GN26-0887

There are three types of names used in a COBOL program:
1.

A data-name is a word that contains at least one alphabetic
character and identifies a data item in the Data Division.rhe
following are formed according to the rules for data-names:
file-names
index-names
mnemonic-names
record-names
report-names
sort-file-names
sort-record-names

2.

A condition-name is a name given to a specific value, set of
values, or range of values, within the complete set of values that
a particular data item may assume. The data item itself is called
a conditional variable.
The condition-name must cOhtain at least
one alphabetic character (see "Data Division" and the discussion of
"Special-Names" in "Environment Division").

3.

A procedure-name is either a paragraph-name or a section-name.
A
procedure-name may be composed solely of numeric Characters.
Two
numeric procedure-names are equivalent if, and only if, they are
composed of the same number of digits and have the same value (see
"Procedure Division").
The following are formed according to the
rules for procedure-names:
library-names
program-names
Note: The first 8 characters of a file-name must be unique to
duplicate names.

I avoid

Special-Names
Special-names are used in the SPECIAL-NAMES paragraph of the
Environment Division. The term special-name refers to a mnemonic-name.
A mnemonic-name is a programmer-defined word that is associated in the
Environment Division with a function-name:
function-names are names
with a fixed meaning, defined by IBM.
In the Procedure Division, mnemonic-name can be written in place of
its associated function-name in any format where such substitution is
valid.
The formation of a mnemonic-name follows the rules for formation
of a data-name (see "Special-Names" in "Environment Division").

CONSTANTS
A constant is a unit of data whose value is not subject to change.
There are two types of constants: literals and figurative constants.

Literals
A literal is a string of cnaracters whose value is determined by tne
set of characters of which the literal is composed.
~very literal
belongs to one of two categories, numeric and nonnumeric.
Structure of the Langua;e

41

Page of GC28-6394-4, -5, -6 revised 12/03/76 by TNL GN26-0887
Literals
NUMERIC

LITE~ALS:

ana-Iloatlng~point.

There are two types of numeric literals:

fixed-point

A fixed-point numeric literal is defined as a string of characters
chosen from the digits 0 through 9, the plus sign, the minus sign, and
the decimal point. The literal -0 is treated by the compiler as a +0.
Every fixed-point numeric literal:
1.

must contain from 1 through 18 digits.

2.

must not contain more than one sign character.
If a sign is used,
it must appear as the leftmost character of the literal.
If the
literal is unsigned, the literal is positive.

3.

must not contain more
treated as an assumed
literal except as the
no decimal point, the

than one aecimal point.
The decimal point is
decimal point, and may appear anywhere in the
rightmost character. If the literal contains
literal is an integer.

(See discussion of fixed-point numeric items in "Data Division.")

If the literal conforms to the rules for the formation of numeric
literals, but is enclosed in quotation marks, it is a nonnumeric
literal.
NONNUMERIC LITERALS: A nonnumeric literal is defined as a string of any
allowable characters in the Extended Binary Coded Decimal Interchange
Code (EBCDIC) set, excluding the quotation mark character. A nonnumeric
literal may be composed of from 1 through 120 characters enclosed in
quotation marks. Any spaces within the quotation marks are part of the
nonnumeric literal and, therefore, are part of the value. All nonnumeric literals are in the alphanumeric category.

T"li _ _ ..L
UJ.. L.

r

T
J...

Language

Figurative Constants
Figurative constants

A figurative constant is a constant to which a specific data-name has
been assigned. These data-names are reserved words. Such a data-name
must not be enclosed in quotation marks when used as a figurative
constant. The singular and plural forms of a figurative constant are
equivalent and may be used interchangeably.
A figurative constant may be used in place of a literal wherever a
literal appears in a format.
There is one exception to this rule:
if
the literal is restricted to numeric characters: only the figurative
constant ZERO (ZEROES, ZEROS) is allowed.
The fixed data-names and their meanings are as follows:
Represents the value 0, or one or more
occurrences of the character 0, depending on
context.

SPACE
SPACES

Represents one or more blanks or spaces.

HIGH-VALUE_
HIGH-VALUES

Represents one or more occurrences of the
character that has the highest value in the computer's
collating sequence. The character for HIGH-VALUE is
the hexadecimal 'FF'.

LOW-VALUE
LOW-VALUES

Represents one or more occurrences of the
character that has the lowest value in the computer's
collating sequence. The character for LOW-VALUE is
the hexadecimal '00'.

QUOTE
QUOTES

Represents one or more occurrences of the
quotation mark character. The word QUOTE (QUOTES)
cannot be used in place of a quotation mark to enclose
a nonnumeric literal.

ALL literal

Represents one or more occurrences of the string of
characters composing the literal. The literal must be
either a nonnumeric literal or a figurative constant
other than the ALL literal.
When a figurative
constant is used, the word ALL is redundant and is
used for readability only.

Structure of the Language

43

Special Registers
SPECIAL REGISTERS
The compiler generates storage areas that are primarily used to store
information produced with the use of special C8BOL features; these
storage areas are called ~2~~!~1-register~.
TALLY
The word TALLY is the name of a special register whose implicit
description is that of an integer of five digits without an
operational sign, and whose implicit USAGE is COMPUTATIONAL.
The
primary use of the TALLY register is to hold information produced by
the EXAMINE statement.
References to TALLY may appear wherever an
elementary data item of integral value may appear (see the "EXAMINE
Statement" in "Procedure Division").

LINE-COUNTER
LI~E-COUNTER

Writer.

is a numeric counter that is generated by the Report
(For a complete discussion, see "Report writer.")

PAGE-COUNTER
PAGE-COUNTER is a numeric counter that is generated by the Report
writer.
(For a complete discussion, see "Report Writer.")

CURRENT-DATE
CURRENT-DATE is an 8-byte alphanumeric field, valid only as the
sending field in a MOVE statement. The format of these eight bytes
is MM/DD/YY (month/day/year) or DD/1'Iil.'1/YY (day/month/year).

TIME-OF-DAY
TIME-OF-DAY is a 6-byte external-decimal field, valid only as the
sending field in a MOVE statement.
The format is HHMIvi8S (hour,
minute, second).

COM-REG
COM-REGis an Ii-byte alphanumeric field.
This field corresponds
to bytes 12 through 22 of the DOS Communication Region.
COM-REG is
valid only as the sending or receiving field in a fl<10VEstatement,~
When COM-REGis used as the receiving field in a MOVE statement, the
sending field must be 11 bytes in length.
.

the

44

(The use of CURRENT-DATE,' TIME-OF-DAY, and COM-REG is explained in
Programrner:'sGuidesla~cited in "Preface").)

Part I

Language Considerations

"jj>",;ibi:iia~y':::fi~ldYho/h8s:~','Il~e-rUf{l;t~i~i :,?:~9",ahd5~hds€:

jtl{:neelS'il1"

:,'an,,;illPut,:,'~:il~'.w:i:th,.:nc:fn$tarida>I.':4;'.1.~bels.:::,.·:'Tt1~s,::fie1:~·;i~::iti'i,t:,iaJ.ll.y.','set,;

:!t.o'

.zero.·.' 'N~Tn~'I~E~':::LS;: :t~s:teQ:' ,~aclr,tiime",ap,:"QP,EN:~tatem~X1t;> '~,s',:: .:.:':" :.: :', .::" ':

• 6!~~~.;~~:,~~1~~~~~~nu~~~~~~1~~;J'~l!~~~!@f:d6~~~i,!'i;'

::']I:fi.··i.t::J~:';~e~o,.::t',I:1;e.'::riuriip~~::ot::;~:e'~:+,s':;::fr~:::t.i;l~·.·(f;i;'+~:iJ.is.;g~t~r:mi:ne:q::if~~m··:tn~r:

'~~~i~~::~~~~~;.,·;,\·::'

"

"':

,,:;;' ' :;:;:;;;;

;',::'::.'.:~-,' :;;;"':.~,' '":>::::_'_,,,',::;,~,;<::,<:: """

Structure of the Language

45

COBOL Program Structure
ORGANIZATION OF THE COBOL PROGRAM

Every COBOL source program is divided into four divisions. Each
division must be placed in its proper sequence, and each must begin with
a division header.
The four divisions, listed in sequence, and their functions are:
• IDENTIFICATION DIVISION, which names the program.
• ENVIRONMENT DIVISION, which indicates the machine equipment and
equipment features to be used in the program.
• DATA DIVISION, which defines the nature and characteristics of data
to be processed.
• PROCEDURE DIVISION, which consists of statements directing the
processing of data in a specified manner at execution time.
Note:
In all formats within this publication, the required clauses and
optional clauses (when written) must appear in the sequence given in the
fo~mat, unless the associated rules explicitly state otherwise.

Structure of the COBOL Program

PROGRAM-ID.

program-name.

[comment-entry] •.. ]

[AUTHOR.

[INSTALLATION.

[comment-entry] •.• ]

[DATE-WRITTEN.

[comment-entry] ••• ]

[DATE-COMPILED.
[SECURITY.
[REMARKS.

[comment-entry] •.• ]

[comment-entry] .•. ]
[comment-entry] ••• ]

ENVIRONMENT DIVISION.
ICONFIGURATION SECTION.
SOURCE-COMPUTER.

entry

OBJECT-COMPUTER.

entry

[SPECIAL-NAMES.

entryll

[INPUT-OUTPUT SECTION.

46

FILE-CONTROL.

{entry} •••

[I~O-CONTROL.

entry]]

Part I

Language Considerations

COBOL Program Structure
DATA DIVISION.
[FILE SECTION.
{file description entry
{record description entry} ••• } ••• ]
[WORKING-STORAGE SECTION.
[data item description entry] ••.
[record description entry] ••• ]

[REPORT SECTION.
{report description entry
{report group description entry} ••• } ••• ]
PROCEDURE DIVISION
[[DECLARATlVES.
{section-name ShCTION.
{paragraph-name.

USE Sentence.

{sentence} ••. } ••• } •••

END DECLARATIVES.]
{section-name SECTION [priority].]
{paragraph-name.

{sentence} ••• } ••• } •••

Organization of the COBOL Program

47

Qualification
METHODS OF DATA REFERENCE

Every name used in a COBOL source program must be unique, either
because no other name has the identical spelling; or because it is made
unique through qualification, subscripting, or indexing.
An identifier is a data-name, unique in itself, or made unique by the
syntactically correct combination of qualifiers, subscripts, and/or
indexes.

QUALIFICATION

A name may be made unique if the name exists within a hierarchy of
names and the name can be singled opt by mentioning one or more of the
higher levels of the hierarchy.
The higher levels are called
qualifiers.
Q~alification is the process by which such a name is made
unique.
Qualification is applied by placing after a data-name or a
paragraph-name one or more phrases, each composed of a qualifier
preceded by IN or OF.
IN and OF are logically equivalent. Only one
qualifier is allowed for a paragraph-name.
Enough qualification must be mentioned to make the name unique;
however, it may not be necessary to mention all levels of the hierarchy.
For example, if there is more than one file whose records contain the
field EMPLOYEE-NO, yet there is but one file whose records are named
MASTER-RECORD, EMPLOYEE-NO OF MASTER-RECORD would sufficiently qualify
EMPLOYEE-NO.
EMPLOYEE-NO OF MASTER-RECORD OF MASTER-FILE is valid but
unnecessary (see discussion of level indicators and level numbers in
"Data Division").
The name associated with a level indicator is the highest level
qualifier available for a data-name.
(A level indicator (FD, SD, RD)
specifies the beginning of a file description, sort file description, or
report description.) A section-name is the highest (and the only)
qualifier available for a procedure-name (see discussion of procedurenames in "Procedure Division"). Thus, level indicator names and
section-names must be unique in themselves since they cannot be
qualified.
The name of a conditional variable can be used as a qualifier for any
of its condition-names. In addition, a conditional variable may be
qualified to make it unique.
The rules for qualification follow:
1.

Each qualifier must be of a successively higher level, and must be
within the same hierarchy as the name it qualifies.

2.

The same name must not appear at two levels in a hierarchy.

3.

If a data-name or a conaition-name is assigned to more than one
data item in a source program, the data-name or condition-name must
be qualified each time reference is made to it in the Procedure,
Environment, or Data Division (except in the REDbFINES clause
where, by definition, qualification is unnecessary).
(See the
REDEFINES clause in "Data Division.")

48

Part I -- Language Considerations

Subscripting/Indexing
4.

A paragraph-name must not be duplicated within a section.
When a
paragraph-name is qualified by a section-name, the word SECTION
must not appear. A paragraph-name need not be qualified when
referred to within the section in which it appears.

5.

A data-name cannot be subscripted when it is being used as a
qualifier.

6.

A name can be qualified even though it does not need qualification;
if there is more than one combination of qualifiers that ensures
uniqueness, then any of these combinations can De used.

Altnough user-cerlnea data-names can be duplicated within the Data
Division and Procedure Division, the following rules should be noted:
1.

No duplicate section-names are allowed.

2.

No data-name can be the same as a section-name or a paragraph-name.

3.

Duplication of data-names must not occur in those places where the
data-names cannot be made unique by qualification.

SUBSCRIPTING
subscripts can be used only when reference is made to an individual
element within a list or table of elements that nave not been assigned
individual data-names (see "Table Handling").

INDEXING
References can be made to individual elements witnin a table of
elements by speci=ying indexing for that reference. An index is
assigned to a given level of a table by using an INDEXED BY clause in
the definition of the table.
~ name given in the INDEXED BY clause is
known as an index-name and is used to refer to the assigned index (see
"Table Handling").

Methods ot Data Reference

49

Page of GC28-6394-4, -5, -6 revised 12/03/76 by TNL GN26-0887
Reference Format
USE OF THE COBOL CODING FORM

The reference format provides a standard method for writing COBOL
source programs. The format is described in terms of character
positions in a line on an input/output medium. Punched cards are the
initial input medium to the COBOL compiler. The compiler only accepts
source programs written in 80-column reference format (see Figure 5)
and produces an output listing of the source program in the same
reference format. 81-column input is not accepted.

r--------------------------------------------------------------------------------,
II.,

COBOL Coding Form

I SYSTEM

PAGE

OF

GRAPHIC

PROGRAM

CARD FORM#
PROGRAMMER

DATE

PUNCH

*!
i

I
I
I
I
I
I
I

!

I
I
I
I
I
I

~--------------------------------------------------------------------------------~

I

Columns 1-6 represent the sequence number area.
I
Column
7
is the continuation area.
I
Columns 8-11 represent Area A}
Used for writing COBOL source statements.
I
I
Columns 12-72 represent Area B
I
Il ________________________________________________________________________________
Columns 73-80 are used to identify the program.
JI

I
I

Figure

5.

Reference Format

The rules for spacing given in the following discussion of the
reference format take precedence over any other specifications for
spacing given in this publication.

SEQUENCE NUMBERS
A sequence number, consisting of six digits in the sequence number
area, is used to identify numerically each card image to be compiled by
the COBOL compiler. The use of sequence numbers is optional.
If" sequence numbers are present, they must be in ascending order.
~n
error message is issued when source language input is out of sequence.

AREA A-AND AREA B
Area A, columns 8 through 11, is reserved for the beginning of
division headers, section-names, paragraph-names, level indicators, and
certain level numbers. Area~ occupies columns 12 through 72.
50

Part I -- Language Considerations

Subscripting/Indexing
4.

A paragraph-name must not be duplicated within a section.
When a
paragraph-name is qualified by a section-name, the word SECTION
must not appear. A paragraph-name need not be qualified when
referred to within the section in which it appears.

5.

A data-name cannot be subscripted when it is being used as a
qualifier.

6.

A name can be qualified even though it does not need qualification;
if there is more than one combination of qualifiers that ensures
uniqueness, then any of these combinations can De used.

Although user-defined data-names can be duplicated within the Data
Division and Procedure Division, the following rules should be noted:
1.

No duplicate section-names are allowed.

2.

No data-name can be the same as a section-name or a paragraph-name.

3.

Duplication of data-names must not occur in those places where the
data-names cannot be made unique by qualification.

SUBSCRIPTING
Subscripts can be used only when reference is made to an individual
element within a list or table of elements that nave not been assigned
individual data-names (see "T~ble Handling").

INDEXING
References can be made to individual elements witnin a table of
elements by specifying indexing for that reference. An index is
assigned to a given level of a table by using an INDEXED BY clause in
the definition of the table. A name given in the INDEXED BY clause is
known as an index-name and is used to refer to the assigned index (see
"Table Handling").

Methods of Data Reference

49

Reference Format
USE OF THE COBOL CODING FORM

The reference format provides a standard method for writing COBOL
source programs. The format is described in terms of character
positions in a line on an input/output medium.
Punched cards are tht
initial input medium to the COBOL compiler. The compiler accepts source
programs written in reference format (see Figure 5) and produces an
output listing of the source program in the same reference format.

r--------------------------------------------------------------------------------,
COBO L Coding Form

~--------------------------------------------------------------------------------~

I
Columns 1-6 represent the sequence number area.
I
I
Column
7
is the continuation area.
I
I
Columns 8-11 represent Area A}
Used for writing COBOL source statements.
I
I
Columns 12-72 represent Area B
I
Columns 73-80 are used to identify the program.
IL________________________________________________________________________________
JI
Figure

5.

Reference Format

The rules for spacing given in the following discussion of the
reference format take precedence over any other specifications for
spacing given in this publication.

SEQUENCE NUMBERS
~ sequence number, consisting of six digits in the sequence number
area, is used to identify numerically each card image to be compiled by
the COBOL compiler. The use of sequence numbers is optional.

If sequence numbers are present,
issued when source

must be in ascending order.
ut is out of s

~n

""'j-'~i~I-Cj.To'~r'~I~~'~,~Il:

ARE~

~

AND AREA B

Area A, columns 8 through 11, is reserved for the beginning of
division headers, section-names, paragraph-names, level indicators, and
certain level numbers.
Area~ occupies columns 12 through 72.
50

Part I -- Language Considerations

Reference Format
Division Header
The division header must be the first line in a division. The
division header starts in Area A with the division-name, followed
space and the word DIVISION, and a period.
may appear on the same line as the division
header.

Section Header
The name of a section starts in Area A of any line following the
division header. The section-name is followed by a space, the word
SECTION, and a period. If program segmentation is desired, a space and
a priority number may follow the word SECTION. No other text may appear
on the same line as the section-header, except USE and COpy sentences.
Note: Although USE and COpy may appear in the Declaratives portion of
the Procedure Division, only USE is restricted to the Declaratives
portion. COpy may be used elsewhere in the COBOL program.

Paraqraph-names and paragraphs
The name of a paragraph starts in Area A of any line following the
division headere It is followed by a period followed by a space.
A para~raph consists of one or more successive sentences. The first
sentence in a paragraph begins anywhere in Area B of either the same
line as paragraph-name or the· immediately following line. Each
successive line in the paragraph starts anywhere in Area B.

Level Indicators and Level Numbers
In those Data Division entries that begin with a level indicator, the
level indicator begins in Area A followed in Area B by its associated
file-name and appropriate descriptive information.
In those data description entries that begin with a level number 01
or 77, the level number begins in Area A followed in Area B by its
associated data-name and appropriate descriptive information.
In those data description entries that begin with level numbers 02
through 49, 66, or 88, the level number may begin anywhere in Area A or
Area B, followed in Area B by its associated data-name and descriptive
information.

CONTINUATION OF LINES
Any sentence or entry that requires more than one line is continued
by starting subsequent line(s) in Area B. These subsequent lines are
called continuation lines. The line being continued is called the
continued line. If a sentence or entry occupies more than two lines,
all lines other than the first and last are both continuation and
continued lines.
Use of the COBOL Coding Form

51

Reference Format
CONTINUATION OF NONNUMERIC LITERALS
When a nonnumeric literal is continued from one line to another, a
hyphen is placed in column 7 of the continuation line, and a quotation
mark preceding the continuation of the literal may be placed anywhere in
Area B.
All spaces at the end of the continued line and any spaces
following the quotation mark of the continuation line and preceding the
final quotation mark are considered part of the literal.

CONTINUATION OF WORDS AND NUMERIC LITERALS
When a word or numeric literal is continued from one line to another,
a hyphen must be placed in column 7 of the continuation line to indicate
that the first nonblank character in Area B of the continuation line is
to follow the last nonblank cparacter on the continued line, without an
intervening space.
In the case of numeric literals the last nonblank
character of the continued line must not be a period or comma.

A blank line is one that contains nothing but spaces from column 7
through column 72, inclusive.
A blank line may appear anywhere in the
source program, except immediately preceding a continuation line .

.f:i{l

i~.

,of,',

':-.'::: :.:? ilt~·::'';~·· ~.;

~.::.;"

;. ,,:,.~;i

.:..;".<

Explanatory ~.nt."_Yi1"'fF';"'~:'~;':'.i;,.~~:::wi,*!a':':;.).'~,~,
produced on the',sollr¢e';'l~$'*";f~'~~.'l've':;n();"'oe"r P\lt:p().Ut,~
(Als 0, see

,

tne NOTE statement in "Compiler Directing Statements" in "Procedure
Division").

52

Part I -- Language Considerations

Format Notation
FORMAT NOTATION

Throughout this publication, basic formats are prescribed for various
elements of COBOL. These generalized descriptions are intended to guide
the programmer in writing his own statements. They are presented in a
uniform system of notation, explained in the following paragraphs.
Although it is not part of COBOL, this notation is useful in describing
COBOL.
1.

All words printed entirely in capital letters are reserved words.
These are words that have preassigned meanings in COBOL.
In-all
formats, words in capital letters represent an actual occurrence of
those words.
If any such word is incorrectly spelled, it will not
be recognized as a reserved word and may cause an error-in the
program.

2.

All underlined reserved words are required unless the portion of
the format containing them is itself optional.
These are ~gy
words.
If any such word is missing or is incorrectly spelled, it
is considered an error in the program.
Reserved words not
underlined may be included or omitted at the option of the
programmer. These words are used only for the sake of readability;
they are called optional words and, when used, must be correctly
spelled.

3.

The characters +, -, <, >, =, when appearing in formats, although
not underlined, are required when such formats are used.

4.

All punctuation and other special characters (except those symbols
cited in the following paragraphs) represent the actual occurrence
of those characters.
Punctuation is essential where it is shown.
Additional punctuation can be inserted, according to the rules for
punctuation specified in this publication.

5.

Words that are printed in lower-case letters represent information
to be supplied by the programmer. All such words are defined in
the accompanying text.

6.

In order to facilitate references to them in text, some lower-case
words are followed by a hyphen and a digit or letter.
This
modification does not change the syntactical definition of the
word.

7.

Certain entries in the formats consist of a capitalized word(s)
followed by the word "Clause" or "Statement." These designate
clauses or statements that are described in other formats, in
appropriate sections of the text.

8.

Square brackets ([ ]) are used to indicate that the enclosed item
may be used or omitt~d, depending on the requirements of the
particular program. When two or more items are stacked within
brackets, one or none of them may occur.

9.

Braces ({ }) enclosing vertically stacked items indicate that one
of the enclosed items is obligatory.
53

Format Notation
10.

The ellipsis ( •.. ) indicates that the immediately preceding unit
may occur once, or any number of times in succession. A unit means
either a single lower-case word, or a group of lower-case words ana
one or more reserved words enclosed in brackets or braces.
If a
term is enclosed in brackets or braces, the entire unit of which it
is a part must be repeated when repetition is specified.

11.

Comments, restrictions, and clarifications on the use and meaning
of every format are contained in the appropriate portions of the
text.

54

Part I -- Language Considerations

PART II -- IDENTIFICATION AND ENVIRONMENT DIVISIONS

• IDENTIFICATION DIVISION

• ENVIRONMENT DIVISION -- FILE PROCESSING SUMMARY

• ORGANIZATION OF THE ENVIRONMENT DIVISION

• ENVIRONMENT DIVISION -- CONFIGURATION SECTION

• ENVIRONMENT DIVISION -- INPUT-OUTPUT SECTION

55

PROGRAM-ID Paragraph
IDENTIFICATION DIVISION

The Identification Oivision is the first division of a COBOL program.
It identifies the source program and the object program. A source
program is the initial problem program; an object program is the output
from a compilation.
In addition, the user may include the date the program is written,
the date the compilation of the source program is accomplished, etc., in
the paragraphs shown.
Structure of the Identification Division
{tDEN~TIFICATIPN DIVISION.}

PROGRAM-ID.
[AUTHOR.

program-name.

[comment-entry] ••• ]

[INSTALLATION.

[comment-entry] ••• ]

[DATE-WRITTEN.

[comment-entry] ••. ]

[DATE-COMPILED.
[SECURITY.
[REMARKS.

[comment-entry] ••• ]

[comment-entry] •.• ]
[comment-entry] .•• ]

Specific paragraph-names 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. If included, they must be presented in the order shown.
~JIII.j
The Identification Division must begin with the reserved words
IDENTIFICATION DIVISION followed by a period. Each comment-entry may be
any ~ombination of characters from the EBCDIC set, organized to conform
to sentence and paragraph structure.

PROGRAM~ID

Paragraph

The PROGRAM-ID paragraph gives the name by which a program is
identified.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------~

I
I
PROGRAM-ID. program-name.
I
I
I ________________________________________ - - - - - - - - - - - - - _________________ JI
L
Identification Division

57

DATE-COMPILED Paragraph
The PROGRAM-ID paragraph contains the name of the program and must be
present in every program.
Program-name identifies the object program to the control program.
Program-name must conform to the rules for formation of a
procedure-name.
program-name are
used as the
therefore be
unique as a program-name.
since the system expects the first character of program-name to be
alphabetic, the first character, if it is numeric, will be converted as
follows:

o

to J

1-9 to A-I
Since the system does not include the hyphen as an allowable
character, the hyphen is converted to zero if it appears as the second
through eighth character of the name.
Note: For additional information concerning program-name when using the
Sort feature, the Segmentation feature, or the CATALR option, see the
Programmer's Guide.

DATE-COMPILED Paragraph
The DATE-COMPILED paragraph provides the compilation date on the
source program listing.

r----------------------------------------------------------------------,I

I

~r~t

~----------------------------------------------------------------------~

I
I
I
DATE-COMPILED.
[comment-entry]
I
Il ______________________________________________________________________ JI

The paragraph-name DATE-COMPILED causes the current date to be
inserted during program compilation. If a comment-entry is present,
even though it spans lines, it is replaced in its entirety with the
current date.

58

Part II -- Identification and Environment Divisions

Data Organization
ENVIRONMENT DIVISION -- FILE PROCESSING SUMMARY

In COBOL, all aspects of the total data processing problem that
depend on the physical characteristics of a specific computer are given
in one portion of the source program known as the Environment Division.
Thus, a change in computers entails major changes in this division only.
The primary functions of the Environment Division are to describe the
computer system on which the object program is run and to establish the
necessary links between the other divisions of the source program and
the characteristics of the computer.
The exact contents of the Environment Division depend on the method
used to process files in the COBOL program. Before the language
elements used in the Environment Division can be discussed meaningfully,
some background in the file processing techniques available to the COBOL
user must be given.
Each combination of data organization and access met~od specified in
the COBOL language is defined as a file-processing technique. The
file-processing tecnnique to be used for a particular file is determined
by the data organization of that file and whether the access method is
sequential or random. Figure 6 summarizes the file-processing
techniques.

DATA

ORGANIZATIO~

Three types of data organization are made available to Disk Operating
System COBOL users:
sequential, direct~~. The means of
creating or retrieving logical records in a file differ, depending on
which type of data organization exists (organization being the structure
of data on a physical file).
Each type of data organization is
incompatible with the others.
Organization of an input file must be the
same as the organization of the file when it was created.

Sequential Data Organization
When sequential data organization is used, the logical records in a
file are positioned sequentially in the order in which they are created
and are read sequentially in the order in which they were created (or in
sequentially reversed order if the REVERSED option of the OPEN statement
is written for tape files).
Such a file organization is referred to in
this publication as standard sequential organization.
This type of data organization must be used for tape or unit-record
files and may be used for files assigned to mass storage devices.
No
key is associated with records on a sequentially organized file.

Direct Data Organization
When direct data organization is used, the positioning of the logical
records in a file is controlled by the user through the specification of
an ACTUAL KEY defined in the Environment Division. The ACTUAL KEY has
two components. The first is a track identifier which identifies the
relative or actual track at which a record is to be placed or at which
the search for a record is to begin. The second component is a record
Environment Division -- File Processing Summary

59

Access Methods
identifier, which serves as a unique logical identifier for a specific
record on the track.
Files with direct data organization ~ust be
assigned to ~ass storage devices.

ACCESS b"£THODS
Two access methods are available to users of DOS COBOL:
access and random access.

sequential

Sequential access is the method of reading and writing records of a
file in a serial manner: the order of reference is implicitly determined
by the position of a record in the file.
Random access is the method of reading qnd writing records in a
programmer-specified manner; the control of successive references to the
file is expressed by specifically defined keys supplied by the user.

ACCESSING A SEQUENTIAL FILE
A standard sequential file may be accessed only sequentially, i.e.,
records are read or written in order. Records can be created and
retrieved; for standard sequential files on mass storage devices,
records can also be updated.

ACCESSING A DIRECT FILE
Direct files may be accessed both sequentially and randomly.
Records
can be retrieved sequentially; they can be created, retrieved, updated,
or added randomly.
'

Sequential Access
When reading a direct file sequentially, records are retrieved in
logical sequence; this logical sequence corresponds exactly to the
physical sequence of the records.

'." .T+r~~~e,AcTUAL;:ISE:y, ~j.~~~~~,ist ~~ei~;f;ieq~:~tle:lt~y~ ~f~o~ia t'ed wi tht-he
~~c0l"~1,i~~ ~ t>~f.F:'P'~lt~; ~P~~if;~lld~,~l}r~~~i\~~ib:'~;t;t~t~~!UALKEY, clause,
for e"ch READ stateQ\e,t:, exe9utfed+
60

'J,

.'"

"','

< ,,:;, ~'::f

Part II -- Identification and Environment Divisions

Access M.ethods
Random Access
When accessing a direct file randomly, the ACTUAL KEY clause is
required.
The system uses the ACTUAL KEY to determine which track a particular
record is on and to locate the record on that track.
If the record is
found, the data portion of the record is read, or, for a rewrite
operation, replaced by a new record.
If during a READ operation, the
desired record cannot be found on the specified track, an invalid key
condition is said to exist.

~~~=St~r~~eB~!~~~-;~!~~~±r~~~~~~~1:~~~~~~···.

th~",' s~~~t~m~,~a,rp~'~s"'t:he,,ent:ire~~(l~PdE;~:':~,q~::,~e'i,':r~:cq~:"~~~:i~"t;;

:r~~~~J:d 'cann':sequeritiiiaL1,;(

',,;;;:,(;,'':~tt~\i,J¥'

i~' ~~"to '~;,cess ')~k:,;:nd~(f~tl:i1t1l~:': 1;1!iE:t:~'$:peqlt(t~~~~1'

?~Ji;~eln~:~itJ,h~n'1the: data x~~or;d ttn,a.p ;Oqn~ ltne kjeYf,f~Fld~hefIi¢~~~l: :'"

iF±]~t-!\+-~±--C;iJ;;,lZ:±~tLL_~J:~i~ff
r0:--'::~~,,' '~;!,-0T~ ;,':,;: ;,"-~T:0~:' nTTTr,
i·;t~ , I ' ,,~, iKiEY::IS' :d:'ata.-.;name:"

cy"r::j

,<:"1"

>:,',""',"

t,

< ,I

',;,

,

;; ~ ,{;

'~

:

;

~ ~'

',;

,,1

::

~""" ~~ '~,()$: ,KEY',:c~a:\1S~; mus:t~ 1b~ ·~peqi!fli.JeJ~',,~d.i::.:', ;;:"

~,,,<:,,,;

,1,.

]f'
$'

~

/

' A , f l.le
~

~

y

WI; th

,

Y;,

,':>':::,:,,;';;:,',';:';":"";

unblocked l;'ecordS
<

<

~'

~

~

,

',

,,'

~:,':2.'
~

,

t>;J.
;,
'

, r~-~~-~-'~----~-~";'-~"'7-':""--~'~:";'-:--:-:':-:---:-:':':--':--'-:-""":"-:-~~:-~---~":'''''-~7'~-~--",,--,- ...

.,

':

Format. ,

, '

':

",t;';'--..,.-~--...;.- ... ---,------------:-..;.-..".----:,-~---,---,...~---:.....;.-:---:...--..;,- __ -.;-'"'"':--;-~, .... -..;.-4

:

~'

'I

,

:

TRACK-AREA IS integer CHARACTERS

;l__ ~____________________ . ;. __________________________________ ~ __ ~ ______ . ;.
The size of the area may be defined to hold from one 'to all the
blocks on a track including their count and key fields.
Integer must be at least 24 + N (40 + RECORD KEY length + black
.siz.e), where N is any number from 2 to the maximum number of blocks
track. If N equals 1, then integer must be 24 + 50 + RECORD KEY lengtll
+ block size.
Integer must not exceed 32,767.
(See IBM System/360 DiS,;
O~rating System:
Data Management Concepts, Form C24-3427).
_ ~1
Environment Division -- Input-Output Section

83

RERUN Clause
I-a-CONTROL PARAGRAPH
The I-a-CONTROL paragraph defines some of the special techniques to
be used in the program. It specifies the points at which checkpoints
are to be established, the core storage area which is to be shared by
different files, the location of files on multiple-file reels, and
optimization techniques. The I-a-CONTROL paragraph and its associated
clauses are an optional part of the Environment Division.

r----------------------------------------------------------------------,

I

General Format
I
~----------------------------------------------------------------------~

I
I
I
I-a-CONTROL.
I
I
[RERUN Clause] •••
I
I
[SAME AREA Clause]
I
[MULTIPLE FILE TAPE Clause]
I
I
I
~:~~~."fl •
I
IL______________________________________________________________________ JI

RERUN Clause
The presence of a RERUN clause specifies that checkpoint records are
to be taken.
A checkpoint record is a recording of the status of a
problem program and main storage resources at desired intervals. The
contents of core storage are recorded on an external storage device at
the time of the checkpoint and can be read back into core storage to
restart the program from that point.

r----------------------------------------------------------------------,
I
Format 1
I
~----------------------------------------------------------------------~

I
I
I
RERUN ON system-name
I
I
I
I
EVERY integer RECQRDS OF file-name
I
IL______________________________________________________________________ JI

The system-name in the RERUN clause specifies the external medium for
the checkpoint file, the file upon which checkpoint records are to be
written.
It has the following structure:
SYSnnn-class-device-organization[-name]
84

Part II -- Identification and Environment Divisions

SAME Clause
The SYSnnn and ~ fields in the system-name for the checkpoint file
cannot be the same as any specified in any ASSIGN clause.
Checkpoint records are written sequentially, and may be assigned to
any utility or mass storage device (except the 2321). Only one RERUN
clause in a program may use a mass storage device for writing checkpoint
records.
(A complete list of utility and mass storage devices is given
in the description of system-name in the ASSIGN clause.)
Format 1 specifies that checkpoint records are to be written on the
unit specified by system-name for every integer records of file-name
that are processed. The value of integer must not exceed 16;777;215.
More than one Format 1 RERUN clause may be included in a program. If
multiple RERUN clauses are specified, they may be specified either for
the same or for different checkpoint files.

Note: ASCII considerations for the RERUN clause are given in
Appendix E.

The S&~ clause specifies tnat two or more files are to use the same
core storage during processing.

r----------------------------------------------------------------------,
I

I

Format

r----------------------------------------------------------------------~

I
I
I
I

SM1E

I
I
I
I

AREA FOR file-name-1 {file-name-2} •••

I

/

I

L_______ ~--------------------------------------------- _________________ J

A SAME clause with the SORT option is described in "Sort." The
following discussion pertains only to the SAME AREA and SAME RECORD hREA
clauses.
The SAME RECORD AREA clause specifies that two or more files are to
use the same main storage for processing the current logical record.
All of the files may be open at the same time. A logical record in the
shared storage area is considered to be:
• a logical record of each opened output file in this SAME RECORD AREA
clause, and
• a logical record of the most recently read input file in this SAML
RECORD AREA clause.
If the SAME clause does not contain the RECORD option, the area being
shared includes all storage areas assigned to the files; therefore, it
is not valid to have more than one of these files open at one time.
Environment Division -- Input-Output Section

85

MULTIPLE FILE TAPE Clause
More than one SAME clause may be included in a program; however:
1.

A file-name must not appear in more than one SAME AREA clause.

2.

A file-name must not appear in more than one SAME RECORD AREA
clause.

3.

If one or more file-names of a SAME AREA clause appear in a SAME
RECORD AREA clause, all of the file-names in that SAME AREA clause
must appear in that SAME RECORD AREA clause. However. that SAME
RECORD AREA clause may contain additional file-names other than
those that appear in that SAME AREA clause.

The SAME RECORD AREA clause implicitly redefines the logical records
of each file named. This allows the user to write the same record to
more than one file, or to write a record he has just read without any
extra MOVE statement. An extra record area is generated for this
purpose.
The SAME AREA clause saves space generated for record areas.
However, files named in a SAME AREA clause cannot be open at the same
time. thus limiting processing possibilities.
MULTIPLE FILE TAPE Clause
The MULTIPLE FILE TAPE clause is used to indicate that two or more
files share the same physical reel of tape.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------~

I
I
I
MULTIPLE FILE TAPE CONTAINS file-name-l
J
I
I
I
[POSITION integer-i) [file-name-2 [POSITION integer-2]] •••
I
IL______________________________________________________________________ JI

The MULTIPLE FILE TAPE clause is pertinent only when the tape has
nonstandard labels, or when labels are omitted.
It is treated as
comments for a tape that has standard labels.
Regardless of the number of files on a single reel, only those files
that are used in the object program need be specified .•
For purposes of positioning. a physical file is considered to be that
segment of a tape that is terminated by a tape mark. Note that two
consecutive tape marks are considered to terminate two physical files.
If all file-names refer to single physical files and have been listed
in consecutive order, the POSITION option need not be given.
The POSITION inteqer relative to the beginning of the tape must be
given if any file on the tape is not listed. or if a tape contains more
than one physical file" i. e., more than one tape mark. Therefore, if a
tape contains two files. each having one nonstandard header label
86

Part II -- Identification and Environment Divisions

Page of GC28-6394-4, -5. -6 revised 12/03/76 by TNL GN26-0887
APPLY Clause
terminated by a tape mark, their positions would be 1 and 3. If the
labels are not to be processed, the positions may be specified as 2 and
4, and the LABEL RECORDS clause must specify OMITTED.
The compiler will position the tape by skipping past a number of tape
marks equal to POSI~ION number minus one.
Caution: POSITION should be used only for input files. If POSITION is
used for output files, overlay may occur.
More than one MULTIPLE FILE clause may be included in a program.

Environment Division -- Input-Output Section

87

88

l-'art II

Identification and

~nvironment

Divisions

Page of GC28-6394-4, -5, -6 revised 12/03/76 by TNL GN26-0887

Environment Division -- Input-Output section

89

, .

"
PART III -- DATA DIVISION

• DATA DIVISION -- INTRODUCTION

• ORGANIZATION OF THE DATA DIVISION

• FILE DESCRIPTION ENTRY -- DETAILS OF CLAUSES

• DATA DESCRIPTION

• DATA DESCRIPTION -- DETAILS OF CLAUSES

91

I

,J

l
~

External Data

Description

DATA DIVISION -- INTRODUCTION

The Data Division of a COBOL source program contains the description
of all information to be processed by the object program. Two types of
data may be processed by a COBOL program: information recorded
externally on files and information created internally. The second
type, which exists only during the execution of a program, will be
discussed later in this chapter in "Working-Storage Section."

ORGANIZATION OF EXTERNAL DATA
A file is a collection of records. There are two types of records:
physical records and logical records. A physical record is a group of
characters or records which is treated as an entity when moved into or
out of core storage. A logical record is a number of related data
items. It may itself be a physical record, i.e., contained within a
single physical unit, or it may be.one of several logical records
contained wit~in a single physical unit, or it may extend across two or
more physical units.
COBOL source language statements provide the means of describing the
relationship between physical and logical records.
Once this
relationship is established, only logical records are made available to
the COBOL programmer. Hence, in this publication, a reference to
records means logical records unless the term "physical records" is
used.

DESCRIPTION OF EXTERNAL DATA
In the discussion of data description, a distinction must first be
made between a record's external description and its internal content.
External description refers to the physical aspects of a file, i.e.,
the way in which the file appears on an external medium. Fo£ example,
the number of logical records per physical record describes,the grouping
of records in the file.
The physical aspects of a file are specified in
File Description entries.
A COBOL record usually consists of groups of related information
are treated as an entity. The explicit description of the contents
each record defines its internal characteristics. For example, the
of data to be contained within each field of a logical record is an
internal characteristic. This type of information about each field
particular record is grouped into a Record Description entry.

Data Division -- Introduction

that
of
type
of a

93

Data Division --

Structure

ORGANIZATION OF THE DATA DIVISION

The Data Division is divided in~o_fo9rs~cti?ps: the File Section,
the Working-Storage Section, ~~~~~~~~ and the Report
Section.
All data that is stored externally, for example, on magnetic tape,
must be described in the File Section before it can be processed by a
COBOL program. Information that is developed for internal use must be
described in the Working-Storage Section. l:~::-"'-;
_ _ ~~~~~ft~riij~~MIi--',~'
.· . Uh.' •. , ,
The
content and format of all reports that are to
generated
the Report
Writer feature must be described in the Report section.
The Data Division is identified by, and must begin with, the header
DATA DIVISION. The File section is identified by, and must begin with,
the header FILE SECTION. The header is followed by one or more file
description entries and one or more associated record description
entries. The Working-Storage Section is identified by, and must begin
with, the header WORKING-STORAGE SECTION. The header is followed by
data item description entries for nonconti uous
followed b
record descr"
ion entries.
The Report Section is
header REPORT SECTION. The
description entries, and one or more report group
entries.
For the proper formats of Division and Section headers, see nUse of
the COBOL Coding Form" in "Language Considerations."
Structure of the Data Division
DATA DIVISION.
FILE SECTION.
{file description entry
{record description entry} ••• } ••.
WORKING-STORAGE SECTION.
[data item description entry] •••
[record description entry] •.•

REPORT SECTION.
{report description entry
{report group description entry} ••. } ••.
Each of the sections of the Data Division is optional and may be
omitted from the source program when the section is unnecessary.
When
used, the sections must appear in the foregoing sequence.
94

Part III -- Data Division

or

Level Indicator/Number
ORGANIZATION OF DATA DIVISION ENTRIES
Each Data Division entry begins with a level indicator or a level
number, followed by one or more spaces, followed by the name of a data
item (except in the Report Section), followed by a sequence of
independent clauses describing the data item. The last clause is always
terminated by a period followed by a space.

Level-Indicator
The level indicator FD is used to specify the beginning of a file
description entry. When the file is a sort-file, the level indicator SD
must be used instead of FD (see "Sort"). When a report is to be
generated by the Report writer feature, the level indicator RD,
specifying the beginning of a report description entry must be provided
for each report in addition to the FD for the file on which the report
is generated (see "Report Writer"). Figure 11 summarizes the level
indicators.

r---------------T------------------------------------------------------,
Indicator
I
Use
I

I

~---------------+------------------------------------------------------~

I
FD
I
File description entries
I
SD
I
Sort-file description entries
i
I
IL_______________
RD
I ______________________________________________________
Report description entries
JI
~

Figure 11.

Level Indicator Summary

Each level indicator must begin in Area A and be followed in Area B
by its associated file-name-and appropriate descriptive information.
Level indicators are illustrated in the sample COBOL programs found
in Appendix B.

Level Number_
Level-numbers are used to structure a logical record to satisfy 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 reference.
The basic subdivisions of a record, that is, those not further
subdivided, are called elementary items; consequently, a record may
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. A group item consists of a named sequence of
one or more elementary items. Groups, in turn, may be combined into
larger groups. Thus, an elementary item may belong to more than one
Organization of the Data Division

95

Level Number
group. In the following example, the group items MARRIED and SINGLE are
themselves part of a larger group named RETIRED-EMPLOYEES:
02

RETIRED-EMPLOYEES.
03
MARRIED.
04 NO-MALE PICTURE 9(8).
04 NO-FEMALE PICTURE 9(8).
03
SINGLE.
04 NO-MALE PICTURE 9(8).
04 NO-FEMALE PICTURE 9(8).

A system of level numbers shows the organization of elementary items
and group items. Since records are the most inclusive data items, the
level number for a record must be 1 or 01. Less inclusive data items
are assigned higher (not necessarily successive) level numbers not
greater than 49. There are special level numbers -- 66, 77. and 88
which are exceptions to this rule. Separate entries are written in the
source program for each level number used.
A group includes all group and elementary items following it until a
level number less than or equal to the level number of that group is
encountered. The level number of an item which immediately follows the
last elementary item of the previous group must be equal to the level
number of one of the groups to which a prior elementary item belongs.
Standard
01

A.
05
05

C-l.
06 D PICTURE X.
06 E PICTURE X.
C-2.

Level numbers 01 and 77 must begin in Area A, followed in Area B by
associated data names and appropriate descriptive information. All
other level numbers may begin in either Area A or in Area B, followed in
Area B by associated data names and appropr~ate descriptive information.
A single-digit level number is written either as a space followed by
a digit or as a zero followed by a digit. At least one space must
separate a level number from the word following the level number.

Special Level Numbers
Three types of data exist whose level numbers are not intended to
structure a record. They are:
66:

Names of elementary items or groups described by a RENAMES clause
for the purpose of regrouping data items have been assigned the
special level number 66. F9r an example of the function of the
RENAMES clause, see "Data Description."

77:

Noncontiguous Working-Storage items, which are not subdivisions of
other items and are not themselves subdivided, have been assigned
the special level number 77.

96

Part III -- Data Division

File Section
88:

Entries that specify condition-names to be associated with
particular values of a conditional variable have been assigned the
special level number 88.
For an example of level-88 items, see
"Data Description."

Indentation
successive data description entries may have the same format as the
first such entry or may be indented according to level number.
Indentation is useful for documentation purposes, and does not affect
the action of the compiler.

FILE SECTION

The File Section contains a description of all externally stored data
(FO), and a description of each sort-file (SO) used in the program.
The File Section must begin with the header FILE SECTION followed by
a period. The File Section contains. file description entries and
sort-file description entries, each one followed by its associated
record description entry (or entries).

r----------------------------------------------------------------------,
I

General Format
I
~----------------------------------------------------------------------~

I
I
FILE SECTION.
I
I
I
I
I
{file description entry
I
I
I
{record description entry} ••• }...
I
I
L
I ______________________________________________________________________ JI

File Description Entry
In a COBOL program, the File Description
represent the highest level of organization
File Description entry provides inflormation
and identification of a file, and gives the
with that file"

Entries (FD and SD>
in the File Section.
rhe
about the physical structure
record-name(s) associated

For a complete discussion of the sort-file-description entry, see
"Sort."

Record Description Entry
The Record-Description-Entry consists of a set of data description
entries which describe the particular record(s) contained within a
particular file.
For a full discussion of the format and the clauses
required within the Record Description entry, see -Data Description."
Organization of the Data Division

97

Working-Storage Section
WORKING-STORAGE SECTION
The Working-Storage Section may contain descriptions of records which
are not part of external data files but are developed and processed
internally.

The Working-Storage Section must begin with the section header
WORKING-STORAGE SECTION followed by a period.
The Working-Storage
Section contains data description entries for noncontiguous items and
record description entries, in that order.

r----------------------------------------------------------------------,
General Format
I

I

t---------~------------------------------------------------------------1

I
I
I
WORKING-STORAGE SECTION.
I
I
I
[data item description entry]
I
I
I
I
I
[record description entry] •••
I
IL ______________________________________________________________________ JI

Data Item Description Entries

Noncontiguous items in Working-Storage that 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 as noncontiguous elementary items.
Each of these items is
defined in a separate data item description entry that begins with the
special level number 77.

Record Description Entries

Data elements in Working-Storage that bear a definite hierarchical
relationship to one another must be grouped into records structured by
level number •

.

,

'

.," Thte; ~~ge, s,*:tion: d~5'P~:ribes data made available from another
f;i(I~~ITuJi?7fg:~~~~~tf'~age" in "Procedure Division" ) •

98

Part III -- Data Division

Report Sections

REPORT SECTION
The Report Section contains Report Description entries and report
group description entries for every report named in the aEPORT clause.
The Report Section is discussed in "Report Writer."

Organization of the Data Division

99

FD Entry/BLOCK CONTAINS Clause
FILE DESCRIPTION ENTRY -- DETAILS OF CLAUSES

The file description entry consists of level indicator (FD) , followed
by file-name, followed by a series of independent clauses.
The entry
itself is terminated by a period.

r----------------------------------------------------------------------,

I

General Format
I
~----------------------------------------------------------------------~
FD file-name
[BLOCK CONTAINS Clause]
[RECORD CONTAINS Clause]

LABEL RECORDS Clause
[VALUE OF Clause]
[DATA RECORDS Clause]
[REPORT Clause].
______________________________________________________________________ J

The level indicator FD identifies the beginning of a file description
entry and must precede the file-name.
The clauses that follow the name
of the file are optional in many cases, and their order of appearance is
not significant.

BLOCK CONTAINS Clause
The BLOCK CONTAINS clause is used to specify the size of a physical
record.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------~

I
I
fCHARACTERS}
I
I
I
BLOCK CONTAINS [integer-1 rO] integer-2
I
I
lRECORDS
I
IL ______________________________________________________________________ JI

The BLOCK CONTAINS clause is unnecessary when a physical record
contains one and only one complete logical record.
In all other
instances, this clause is required.
100

Part III -- Data Division

BLOCK CONTAINS Clause
The BLOCK CONTAINS clause need not be specified for:
• direct files with F, U, or V mode records

• files containing U-mode records
For these types of files f the compiler accepts the clause and treats it
as comments.
The RECORDS option may be used unless one of the following situations
exists, in which case the CHARACTERS option should be used:
1.

The physical record contains padding (areas not contained in a
logical record)

2.

Logical records are -grouped in such a manner that an inaccurate
physical record size would be implied. Such would be the case
where the user describes a mode V record of 100 characters, yet
each time he writes a block of 4, he writes a 50-character record
followed by three 100-character records.
Had he used the RECORDS
option, the compiler would have calculated the block length as 420.

3.

Logical records extend across physical records; that is, recording
mode is S (spanned).

When the RECORDS option is used, the compiler assumes that the
blocksize provides for integer-2 records of maximum~ize and ~
provides additional space for any re . ed control bYtes.
When the CHARACTERS option is used, the physical record size is
specified in Standard Data Format, i.e., in terms of the number of bytes
occupied internally by its characters, regardless of the number of
characters used to represent the item within the physical record. The
number of bytes occupied internally by a data item is included as part
of the discussion of the USAGE clause. Integer-l and integer-2 must
include ~bytes and control ~ contained in the physical record.
When the CHARACTERS option is used, if only integer-2 is shown, it
represents the exact size of the physical record.
If integer-l and
integer-2 are both shown, they refer to the minimum and maximum size of
the physical record, respectiveli.
Integer-l and integer-2 must be positive integers.,
If this clause is omitted, it is assumed that records are not
blocked.
When neither the CHARACTERS nor the RECORDS option is specified, the
CHARACTERS option is assumed.

Note: ASCII considerations for the BLOCK CONTAINS clause are given in
Appendix E.

File Description Entry -- Details of Clauses

101

RECORD CONTAINS Clause
RECORD CONTAINS Clause
The RECORD CONTAINS clause is used to specify the size of a file's
data records.

r----------------------------------------------------------------------,

I

Format

I

t----------------------------------------------------------------------~

I
I
I
RECORD CONTAINS [integer-1 TO] integer-2 CHARACTERS
I
IL ______________________________________________________________________ JI

Since the size of each data record is completely defined within the
record description entry, this clause is never required.
When the
clause is specified, the following notes apply:
1.

If both integer-1 and integer-2 are shown, they refer to the number
of characters in the smallest data record and the number in the
largest data record, respectively.

2.

Integer-2 should not be used by itself unless all the data records
in the file have the same size. In this case, integer-2 represents
the exact number of characters in the data record.

3.

,The size of the record must be specified in Standard Data Format,
i.e., in terms of the number of bytes occupied internally by its
characters, regardless of the number of characters used to
repLe~ent the ,item within the record.
The number of bytes occupied
internally by a data item is discussed in the description of the
USAGE clause. 'The size" of·· a record is determined according to the
rules for obtai"ning the size of a group item.

Normally, whether this clause is specified or omitted, the record
lengths are determined by the compiler from the record descriptions.
When one or more of the data item description entries within a record
contains an OCCURS clause with the DEPENDING ON option, the compiler
uses the maximum val:ue of the varian.le to calculate the rec~rd ;Length.
However, if more than one entry in a given record description
contains an OCCURS clause with the DEPENDING ON option, and the maximum
values of the variables in these OCCURS clauses do not occur
simultaneously, integer-2, as specified by the user, may indicate a
maximum record size other than the size calculated by the compiler from
the maximum values of the OCCURS clause variables.
In this case, the
user-specified value of integer-2 determines the amount of storage set
aside to contain the data record.
For example, in a school whose total enrollment is 500, an unblocked
file of collective attendance records is being created, each record of
which is described as follows:
01

102

ATTENDANCE-RECORD.
02 DATE PICTURE X(6).
02 NUMBER-ABSENT PICTURe S999 USAGE IS COMP SYNC.
02 NUMBER-PRESENT PICTURE S999 USAGE IS COMP SYNC.
02 NAMES-OF-ABSENT OCCURS 0 TO 500 TIMES DEPENDING ON
NUMBER-ABSENT PICTURE A(20).
02 NAMES-OF-PRESENT OCCURS 0 TO 500 TIMES DEPENDING ON
NUMBER-PRESENT PICTURE A(20).

Part III -- Data Division

Recording Mode
The programmer can save storage by taking advantage of the fact that
NUMBER-ABSENT plus NUMBER-PRESENT will never exceed the school's total
enrollment.
Unless the programmer writes RECORD CONTAINS 10,010
CHARACTERS in the FD entry for the file, the compiler calculates the
record size to be almost twice as large.

Recording Mode
~jp~EID;rNiG",:KQ~if:t~,;t1Ei~~~e,:':lp;<"l)()t:+:u~~Cl::~:tiq,;?,pe~:i;:y,,·.th;e,r~9P~¢li.pg:

the COBOL complIer scans each record
recording mode may be F (fixed),
or S (spanned).

U

Recording Mode F -- All of tne records in a file are the same length and
each is wholly contained in one block. Blocks may contain more than one
record, and there is usually a fixed number of records per block.
In
this mode, there are no record-length or block-descriptor fields.
Recording Mode U -- The records may be either fixed or variable in
length. However, there is only one record per block. There are no
record-length or block-descriptor fields.
Recording~ode

V -- The records may be either fixed or variable in
length, and each must be wholly contained in one block. Blocks may
contain more than one record. Each data record includes a record-length
field and each block includes a block-descriptor field.
These fields
are not described in the Data Division; provision is automatically made
for themQ These fields are not available to the user.
Recording Mode S -- The records may be either fixed or variable in
length and may be larger than a block. If a record is larger than the
remaining space in a block, a segment of the record is written to fill
the block. The remainder of the record is stored in the next block (or
blocks if required). Only complete records are made available ~b the
user. Each segment of a record in a block, even if it is the entire
record, includes a segment-descriptor field, and each block includes a
block-descriptor field.
These fields are not described in the Data
Division; provision is automatically made for them.
These fields are
not available to the user.
For standard sequential files, the compiler determines the recording
mode for a given file to be:
F

if all the records are defined as being the same size and the
size is smaller than or equal to the block size

f:J

if the records are defined as variable in size, or if the RECORD
CONTAINS clause specifies variable size records and the longest
record is less than or equal to the maximum block size

S

if the maximum block size is smaller than the largest record
size

For direct files, the compiler determines the recording mode for a
given file to be:
F

if all the records are defined as being the same size, and the
size is smaller than or equal to the block size

U

if the records are defined as being variable in size, or if the
RECORD CONTAINS clause specifies variable size records and the
longest record is less than or equal to the maximum block size
File Description Entry -- Details of Clauses

103

S

if tne maximum block size is smaller than the largest record
size

Files assigned to the card reader and files with'indexed orgalji{z?"tion
must be F mode 

I
tFILLER
)
I
Il ______________________________________________________________________ JI

File Sections, a data-name or the
following the level number in

A data-name is a name assigned by the user to identify a data item
used in a program. A data-name refers to a kind of data, not to a
particular value; the item referred to may assume a number of different
values during the course of a program.

_1(_

The key !Nord FILLER is used to specify an elementary
item that is never referred to in the program, and therefore need not be
named. Under no circumstances may a FILLER item be referred to
directly. In a MOVE, ADD, or SUBTRACT statement with the CORRESPONDING
option, FILLER items are ignored.
Note: Level-77 and level-Ol entries in the Working-Storage
Section must be given unique data-names, since neither can be qualified.
Subordinate data-names, if they can be qualified, need not be unique.

Data Description Entry -- Details of Clauses

111

REDEFINES Clause
REDEFINES Clause
The REDEFINES clause allows the same computer storage area to contain
different data items or provides an alternative grouping or descripticn
of the same data.
That is, the REDEFINES clause specifies the
redefinition of a storage area, not of the data items occupying the
area.

r----------------------------------------------------------------------,

I

Format

I

r----------------------------------------------------------------------~

I
I
I
level number data-name-1 REDb.FINES data-name-2
I
L
I ______________________________________________________________________ JI

The level numbers of data-name-1 and data-name-2 must be identical,
but must not be 66 or 88.
Data-name-2 is the name associated with the
previous data description entry.
Data-name-l is an alternate name for
the same area.
When written, the REDEFINES clause must be the first
clause following data-name-l.
The REDEFINES clause must not be used in level-01 entries in the File
Section.
Implicit redefinition is provided when more than one level-01
entry follows a file description 8ntry.
Redefinition starts at data-name-2 and ends when a level number less
than or equal to that of data-narne-2 is encountered.
Between the data
descriptions of data-name-2 and data-name-1, there may be no entries
having lower level numbers (numerically> than the level number of
data-name-2 and data-name-1.
Example:
02

02

A.
03 A-l
03 A-2
03 A-3
B REDEFlriJES A

PICTURE
PICTURE
PICTURE
PICTURE

X.
XXX.
99.
X(6).

In this case, B is data-name-l, and A is aata-name-2.
When B redefines
A, the redefinition includes all of the items sUDordinate to A (A-l,
A-2, and A-3).
The data description entry for data-name-2 cannot contain an OCCURS
clause, nor can data-name-2 be subordinate to an entry which contains an
OCCURS clause. An item subordinate to data-name-2 may contain an OCCURS
clause without the DEPENDING ON option. Data-name-l or any items
subordinate to data-name-l may contain an OCCURS clause without the
DEPENDING ON option.
Neither data-name-2 nor data-name-l nor any of
their subordinate items may contain an OCCURS clause with the DEPENDING
ON option.
When data-name-1 has a level number other than 01, i t must specify a
storage area of the same size as data-name-2.

If data-name-l contains an OCCURS clause, its size is computed by
multiplying the length of one occurrence by the number of occurrences.
Note:
In the discussion that follows, i=:he i=:e!m"coITIt:>?tational n refers
to COMPUTAT IONAL ,';.i:,CQ'p.~Wif,~9ijit::~fi-'-Ta~d. COMPutATt6N~t-2' items.
112

Part III -- Data Division

REDEFINES Clause
When the SYNCHRONIZED clause is specified for an item that also
contains a REDEFINES clause, the data item that is redefined must have
the proper boundary alignment for the data item that REDEFINES it.
For
example, if the programmer writes:
02
02

A
B

REDEFINES A

PICTURE X(4).
PICTURE S9 (9) COL-W SYNC.

he must ensure that A begins on a fullword boundary.
When the SYNCHRONIZED clause is specified for a computational item
that is subordinate to an item that contains a REDEFI~~S clause, the
computational item must not require the addition of slack bytes.
Except for condition-name entries, the entries giving the new
description of the storage area must not contain any VALUE clauses.
The entries giving the new description of the storage area must
follow the entries describing the area being redefined, without
intervening entries that define new storage areas. Multiple
redefinitions of the same storage area shouldal~ll~e the, data-n~m~ ()f

.~he entr;::~at~~~~\;R~T~g;tg~~~···jl~
:~:~
tLid!~:it·\,' For example, both of the following are valid uses
of the REDEFINES clause:

tfl""""

02
02
02

A

PICTURE 9999.
REDEFINES A PICTURE 9V999.
C REDEFINES A PICTURE 99V99.
B

Data items within an area can be redefined without their lengths
being changed; the following statements result in the storage layout
shown in Figure 12.
02

N&M..E-2.

02

03 SALARY
PICTURE XXX.
03 SO-SEC-NO PICTURE X(9).
03 MONTH
PICTURE XX.
NAME-1 REDEFINES NAME-2.
03 WAGE
PICTURE XXX.
03 MAN-NO
PICTURE X(9).
03 YEAR
PICTURE XX.

r----------------------------------------------------------------------,
SALARY
SO-SEC-NO
MONTH
NAME-2

WAGE

NAME-1

---

MAN-NO

YEAR

--....--.
~
--~
r--T--T--T--T--T--T--T--T--T--T--T--T--T--'
I I I I I I I I I I I I I I I
I
I
I
I
IL __ LI __ LI __ LI __ LI __ LI __ LI __ LI __ LI __ I I __ LI __ LI __ LI __ JI
L_~L

______________________________________________________________________ J

Figure 12.

Areas REDEFINED without Changes in Length
Data Description Entry -- Details of Clauses

113

REDEFINES Clause
Data items can also be rearranged within an area; the following
statements result in the storage layout shown in Figure 13.
02

02

NAME-2.
03 SALARY
PICTURE XXX.
03 SO-SEC-NO PICTURE X(9).
03 MONTH
PICTURE XX.
NAME-l REDEFINES NAME-2.
03 MAN-NO
PICTURE X(6).
03 WAGE
PICTURE 999V999.
03 YEAR
PICTURE XX.

r----------------------------------------------------------------------,
SALARY
SO-SEC-NO
MONTH
NAME-2

MAN-NO

WAGE

YEAR

NAME-l

Figure 13.

Areas REDEFINED and Rearranged

When an area is redefined, all descriptions of the area remain in
effect. Thus, if Band C are two separate items that share the same
storage area due to redefinition, the procedure statements MOVE X TO B
or MOVE Y TO C could be executed at any point in the program. In the
first case, B would assume the value of X and take the form specified by
the description of B. In the second case, the same physical area would
receive Y according to the description of C.
It should be noted, however, that if both of the foregoing statements are executed successively
in the order specified, the value Y will overlay the value X. However,
-redefinition in itself does not cause any data to be erased and does not
supersede a previous description.
The usage of data items within an area can be redefined.
Altering the USAGE of an area through redefinition does not cause any
change in existing data. Consider the example:
02
02
02

B

C
A

REDEFINES B

PICTURE 99 USAGE DISPLAY VALUE IS 8.
PICTURE S99 USAGE COMPUTATIONAL.
PICTURE S9999 USAGE COMPUTATIONAL.

Assuming that B is on a halfword boundary, the bit configuration of
the value 8 is 1111 0000 1111 1000, because B is a DISPLAY item.
Redefining B does not change its appearance in storage. Therefore, a
great difference results from the two statements ADD B TO A and ADD C TO
A. In the former case, the va~ue 8 is added to A, because B is a
display item.
In the latter case, the value -3,848 is added to A,
because C is a binary item (USAGE IS COMPUTATIONAL), and the bit
configuration appears as a negative number.

ii4

Part III -- Data Division

BL&~K

WHEN ZERO Clause

Moving a data item to a second data item that redefines the first one
(for example, MOVE B TO C when C redefines B), may produce results that
are not those expected by the programmer. The same is true of the
reverse (MOVE B TO C when B redefines C).
A REDEFINES clause may be specified for an item within the scope of
an area being redefined, that is, an item subordinate to a redefined
item. The following example would thus be a valid use of the REDEFINES
clause:
02

02

REGULAR-EMPLOYEE.
03 LOCATION
PICTURE
03 STATUS
PICTURE
03 SEMI-MONTHLY-PAY
PICTURE
03 WEEKLY-PAY REDEFINES SEMI-MONTHLY-PAY PICTURE
TEMPORARY-EMPLOYEE REDEFINES REGULAR-EMPLOYEE.
03 LOCATION
PICTURE
PICTURE
03 FILLER
03 HOURLY-PAY
PICTURE

A( 8)
X(4).
9999V99.
999V999.
e

A(a) •
X(6).
99\199.

REDEFINES clauses may also be specified for items subordinate to
items containing REDEFINES clauses. For example:
02

02

REGULAR-EMPLOYEE.
03 LOCATION
PICTURE
03 STATUS
PICTURE
03 SEMI-MONTHLY-PAY
PICTURE
TEMPORARY-EMPLOYEE REDEFINES REGULAR-EMPLOYEE.
03 LOCATION
PICTURE
03 FILLER
PICTURE
03 HOURLY-PAY
PICTURE
PICTURE
03 CODE-H REDEFINEs HOURLY-PAY

A(a) .
X(4).
999V999.
1\(8).
X(6).
99\199.
9999.

BLANK WHEN ZERO Clause
This clause specifies that an item is to be set to blanks whenever
its value is zero.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------~

I
I
I
BLANK WHEN ZERO
I
IL ______________________________________________________________________ JI

When the BLANK WHEN ZERO clause is used, the item will contain only
blanks if the value of the item is zero.
The BLANK WHEN ZERO clause may be specified only at the elementary
level for numeric edited or numeric items. When this clause is used for
an item whose PICTURE is numeric, the category of the item is considered
to be numeric edited.
This clause may not be specified for level-66 and level-aa data
items.
Data Description Entry -- Details of Clauses

115

JUSTIFIED Clause
JUSTIFIED Clause
The JUSTIFIED clause is used to override normal positioning of data
within a receiving alphabetic or alpnanumeric data item.

r----------------------------------------------------------------------,

I

Format
I
~----------------------------------------------------------------------~

I
I
I {JUSTIFIED}
I
RIGHT
I
JUST
I
Il ______________________________________________________________________ JI

Normally, the rule for positioning data within a receiving
alphanumeric or alphabetic data item is:
• The data is aligned in tne receiving field, beginning at the
leftmost character position within the receiving field.
Unused
character positions to the right are filled with spaces. If
truncation occurs, it will be at the right.
The JUSTIFIED clause affects the positioning of data in the receiving
field as follows:
• When the receiving data item is described with the JUSTIFIED clause
and the data item sent is larger than the receiving data item, the
leftmost characters are truncated.
• When the receiving data item is described with the JUSTIFIED clause
and is larger than the data item sent, the data is aligned at the
rightmost character position in the data item. Unused character
positions to the left are filled with spaces.
The JUSTIFIED clause may only be specified for elementary items.
This clause must not be specified for level-66 or level-aa data
items.

OCCURS Clause
The OCCURS clause is used to define tables and other homogeneous sets
of data, whose elements can be referred to by subscripting or indexing.
The OCCURS clause is described in "Table Handling."

PICTURE Clause
The PICTURE clause describes the general characteristics and editing
requirements of an elementary item.
116

Part III -- Data Division

PICTURE Clause

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------~

I
I
I {PICTURE}
I
IS character string
I
PIC
I
Il ______________________________________________________________________ JI

The PICTURE clause can be used only at the elementary level.
The character string consists of certain allowable combinations of
Characters in the COBOL character set. The maximum number of characters
allowed in the character string is 30. The allowable combinations
determine the category of the elementary item.
There are five categories of data that can be described with a
PICTURE claus~. They are:
1.
2.
3.
4.
5.

Alphabetic
Numeric
Alphanume~ic

Alphanumeric edited
Numeric edited

The Three Classes of Data
The five categories of data items are grouped into three classes:
alphabetic, numeric, and alphanumeric. For alphabetic and numeric, the
class and the category are synonymous. The alphanumeric class includes
the categories of alphanumeric (without editing>, alphanumeric edited,
and numeric edited.
Every elementary item belongs to one of the three classes and to one
of the five categories. The class of a group item is treated at object
t·ime as alphanumeric regardless of the class of the elementary items
subordinate to that group item.
Figure 14 shows the relationship of the class and category for
elementary and group data items.

r--------------------T---------------------T---------------------------,
Level of Item
I
Class
I
Category
I
r--------------------+---------------------t---------------------------1
I
I
Alphabetic
I
Alphabetic
I
II Elementary
r---------------------t---------------------------~
I
Numeric
I
Numeric
i
I
r---------------------t---------------------------1
I
I
I
Alphanumeric
I
I

I
I

I
I

Alphanumeric Edited
I
Numeric Edited
I
r--------------------+---------------------t---------------------------~
I
I
I
Alphabetic
I
I
I
I
Numeric
I
Group
I
Alphanumeric
I
Alphanumeric
I
I
I
I
I
Alphanumeric Edited
I
Numer ic Edited
Il ____________________ I _____________________ I ___________________________
JI
~

Figure 14.

Alphanumeric

I
I

~

Class and Category of Elementary and Group Data Items
Data Description Entry -- Details of Clauses

117

PICTURE Clause
Character String and Item Size
In the processing of data through COBOL statements, the size of an
elementary item is determined through the number of character positions
specified in its PICTURE character string.
In core storage, however,
the size is determined by the actual number of bytes the item occupies,
as determined by its PICTURE character string. and also by its USAGE
(see "USAGE Clause").
Normally, when an arithmetic item is moved from a longer field into a
shorter one, this compiler will truncate the data to the number of
characters represented in the PICTURE character string of the shorter
item.
For example, if a sending field with PICTURE S99999, and containing
the value +12345, is moved to a COMPU'l'ATIONAL receiving field with
PICTURE S99, the data is truncated to +45.

Repetition of Symbols
An integer which is enclosed in parentheses following one of the
symbols

x

A

z

p

9

B

*

o

+

indicates the number of consecutive occurrences of the symbol.
example, if the programmer writes

$
For

A(40)

the four characters (40) indicate forty consecutive appearances of the
symbol A. The number within parentheses may not exceed 32,767.
Note: The following symbols may appear only once in a given PICTURE
clause:
S

v

CR

DB

Symbols Used in the PICTURE Clause
The functions of the symbols used to describe an elementary item are:
A

Each A in the character string represents a character position that
can contain only a letter of the alphabet or a space.

BEach B in the character string represents a character position into
which the space character will be inserted.
~

';?\' ,

-

rep~esent:s ,theex~nent

in ,an
,l'he.,'Et 'occ;.l~pi'~s,: p~ ::byrteqf ,st;o:r:'a;ge',:"

, ,,:~~€"' ~',f ,th~,j~l~~nitary·i t,em •. ,,: The

:.~~t.~,;ti,/·~~;r~~; :~~ef~~~/~~aG!;i:;'~~"T :.:'::;;; "
118

Part III -- Data Division

PICTURE Clause
P

The 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 number that appears in the data item. The scaling
position character P is not counted in the size of the data item.
Scaling position characters are counted in determining the maximum
number of digit positions (18) in numeric edited items or in items
that appear as operands in arithmetic statements.
The scaling position character P may appear only to the left or
right of the other characters in the string as a continuous string
of pes within a PICTURE description. The sign character S and the
assumed decimal point V are the only characters which may appear to
the left of a leftmost string of pes. Since the scaling position
character P implies an assumed decimal point (to the left of the
pes if the pes are leftmost PICTURE characters and to the right of
the pes if the pes are rightmost PICTURE characters), the assumed
decimal point symbol V is redundant as either the leftmost or
rightmost character within such a PICTURE description.

S

The symbol S is used in a PICTURE character string to indicate the
presence (b~t not the representation nor, necessarily, the
position) of an operational sign, and must be written as the
leftmost character in the PICTURE string. An operational sign
indicates whether the value of an item involved in an operation is
positive or negative. The symbol S is not counted in determining
.the size of the e!e
~~~!~g~i

V

The V is used in a character string to indicate the location of the
assumed decimal point and may appear only 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.

X

Each X in the character string represents a character position
which may contain any allowable character from the EBCDIC set.

Z

Each Z in the character string represents a leading numeric
character position; when that position contains a zero, the zero is
replaced by a space character. Each Z is counted in the size of
the item.

9

Each 9 in the character string represents a character position that
contains a numeral and is counted in the size of the item.

o

Each zero in the character string represents a character position
into which the numeral zero will be inserted. The 0 is counted in
the size of the item.
Each comma in the character string represents a character position
into which a comma will be inserted. This character is counted in
the size of the item. The comma insertion character cannot be the
last character in the PICTURE character string.
When a period appears in the character string, it is an editing
symbol that represents the decimal point for alignment purposes.
In addition, it represents a character position into which a period
will be inserted. This character is counted in the size of the
item. The period insertion character cannot be the last character
in the PICTURE character string.
Note: 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.
Data Description Entry -- Details of Clauses

119

PICTURE Clause
These symbols are used as editing sigh control symbols. When
used, each represents the character position into which the
editing sign control symbol will be placed. The symbols are
mutually exclusive in one character string. Each character used in
the symbol is counted in determining the size of the data item.

*

$

Each asterisk (check protect symbol) in the character string
represents a leading numeric character position into which an
asterisk will be placed when that position contains a zero. Each
is counted in the size of the item.

*

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 either by the
symbol $ or by the single character specified in the CURRENCY SIGN
clause in the SPECIAL-N~MES paragraph of the Environment Division.
The currency symbol is counted in the size of the item.

Figure 15 shows the order of precedence of the symbols used in the
PICTURE clause.

The Five categories.of Data
The following is a detailed description of the allowable combinations
of characters for each category of data.
ALPHABETIC ITEMS: An alphabetic item is one whose PICTURE character
string contains only the symbol A.
Its contents, when represented in
Standard Data Format, must be any combination of the 26 letters of the
Roman alphabet and the space from the COBOL character set. Each
alphabetic character is stored in a separate byte.
If a VALUE clause is specified for an alphabetic item, the literal
must be nonnumeric.
ALPHANUMERIC ITEMS: An alphanumeric item is one whose PICTURE character
string is restricted to combinations of the symbols A, X, and 9.
The
item is treated as if the character string contained all XiS. Its
contents, when represented in Standard Data Format, are allowable
characters from the EBCDIC set.
A PICTURE character string which contains all A's or all 9's does not
define an alphanumeric item.
If a VALUE clause is specified for an alphanumeric item, the literal
must be nonnumeric.

120

Part III -- Data Division

PICTURE Clause

-----------------------T------------------------T-----------------------T--------------,
I
FIRST I
I
I
I
SYMBOL I
I
I
I
I
I
I
NON-FLOATING
I
FLOATING
I OTHER
I
I
I INSERTION SYMBOLS
I INSERTION SYMBOLS
I SYMBOLS
I
r-T-T-T-T---T---T----T---+---T---T---T---T---T---+-T-T-T-T-T-T'--'~
I
ISECOND
I I I I I{+}I{+}I{CR}I 1 I{Z}I{Z}I{+}I{+}I
I I IAI I I I ':"1
I SYMBOL
IBIOI,I.I - I - I DB Ics 1 * I * I - I - Ics1Ics119IXISIi1IPIPI,~.a1
r------------T---------- -+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-+r:..;..~
I
B
IXIXIXIXI X I I
IX I X I X I X I X IX IX IXIXI IXI IXI·.·I
r----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-~~~
I
0
IXIXIXIXI X I I
! X ! X ! X ! X I X!X
!X !XIXI !lC! !XL;.:'
NON-FLOATINGr----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-1:'::'1
I,
IXIXIXIXI X I I
IX I X I X I X I X IX IX IXI I IXI IXP,'I
INSERTION r----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-+:_:_,-H
I
IX IXIXI I X I I
IX I X I I X I IX I IXI I I I I I:·;':'; I
SYMBOLS

t{:-~~-=~-t-t-t-t-t---t---t----t---t---t---t---t---t---t---t-t-t-t-t-t-n~~1
~-~-;;-=}--t~t~t~t~t---t---t----t~--t-~-t-~-t---t---t~--t~--t~t-t-t~t~t~tl~1

-r+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-f,~~~
~{=~-~=-~~ ~~~:~:~:~---~---~----~:--~-:-~-:-~---~---~:--~:--~:~-~-~:~:~:~~;~
I I I I I XI
I cs 1
I
I I I I I I I I I I I I I 1>;:\1
r{------

r------------+-------I--+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-+~~~

I
~{~-~~-: --~:~:t:t-~-:-~---t----t:--t-~-~---~---t---~---~---t-~-~-~-~-t-t~i~
IIFLOATING
.•-.: .: :.~
INSERTION I~!~-~~-:l--~~~~~:t~t-:-t---t----t:--t-:-+-:-+---+---+---+---+-+-t-+:+-+:+.:.:.~.;.;.;
+ or - J I XI XI XI I I I
IX I I I X I I I I I I I I I L':'I

ISYMBOLS

r ~-;~-=I--t~t~t~t~t---t---t----t~--t---t---t-~-t-~-t---t---t-t-t-t~t-t~tf~1

r ------ --+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-+~~
IXI XI XI I X I I
I cs 1
I
1 Iii
i x i i i i i i I I;;;' I
I
r----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-f~~~
1
I
I cs
IXIXIXI XI X I I
I I
I I I I X IX I I I PC! IXI·>: I
r------------+----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-t~~
I
9
IXIXIXIXI X I I
IX I X I I X I IX I IXIXIXIXI IXIX·;:I
r----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-f-,~~
I A X
IXIXI I I I I
I I I I I I I IXIXI I I I 1::"<1
r----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-+~~~
OTHER
I
S
I I I I I
I
I
I
I
I
!
!
!
!
! ! ! ! , ! !'~:~; ,
r----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-+~~~
SYMBOLS
I
V
IXIXIXI 1 X I I
IX I X I I X I IX I IXI IXI IXI 1'..::·1
r----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-+;~
I
P
I XIXIXI I X I
I
IX I X I I X I IX I IXI IXI IXI I·: .1
r----------+-+-+-+-+---+---+----+---+---+---+---+---+---+---+-+-+-+-+-+-+~~
I
P
I I I I I XI I
IX I I I
I I I I I IXIXI IXI::I
I
I

h-i~;"7,-:;7",:_:_'l"7,~n1r-:tc-;+r+"':-.--:+"7"7-,:t"7-,-7"t,.,.;7·~t7""7"7t:~-,,.,... ....J,--:--:..,...+::::,t,"7,-,c:+.,...,.,....,..t:±·:Ji-t,-,.+,:±-+7.-8
1!·:T~,:~~t! ;j: :,t ~p ':I~I::X 'I:: :;l:> l;il>:·,:'tt;:·:t; ~ :.:.,p ;:YL:q::Lndr ff~I,:a; HIX:U:ht'~I,i'I
r____________ J.:~~'~.::::.:'.:..::'--''-_'--:L..:.r:~'i"'--i...:.i;...:.:.:.:.'...:.i:...:.:_~.:L.:..:.:.;::::.:.'.:.:i:...::=:.:.'i..:.::.:.'::~.::=::.:i':...:::.::,;i:....:..::.:.'..1.~'--...:..1.::i.:..:.::.:.1;...::.1;:...:.':t::.:.:t..:.;l:...:..1.'.:.;~....:..:..:.~
i

'. t~.,;e....,.a,.b.b
. . ,:.te?. ~.".,a.J.-~ipn.,.,
..f•.o."~' .,U.le..:.c*u.F.,r".~n.'}?lH:,X:~l
.. "i.1.'
. ·":.e..".,:
: .. k:.'<~l:.··•... ".: •.,.,!$.nTr..''.'htg~:':s. ;'.~
. . ~.i!¥\!li):kP··~~.f.'·.~.\c.d.)'8~.
"
"lj.~".'I.':.·~
... ~:ld:iI."'. . 1.d,.f.'.'.. '.'......
' *1
II~.~.C.S
.;. . ,.,.,~S.'
.~
~_
p~~;t,e~;~~~~
iQ .' :t;,,~,m~td."'q~"~~l p~;~:;;Ktq~It7; ~, 't~: i i ' '" i I".'t I

L~:l!3'~:t:~;;~~~,~~V!?::t:(l;~~.:'..:"~.:.:.·, ....,

'::'::::::":.,"'.:'.: ':;

':::'.;,1>",

i......

.'1',1

r---------------------------------------------------------------------------------------~

At least one of the symbols A, X, Z, 9, or *, or at least two of the symbols +, -, or I
cs must be present in a PICTURE string.
I
I
An X at an intersection indicates that the symbolCs) at the top of the colu~ill m3Y, in al
given character~string, appear anywhere to the left of the symbol(s) at the left of thel
row.
I
I
Non-floating insertion symbcls + and -, floating insertion symbols Z, *, +, -, and cs, I
and other symbol P appear twice in the above PICTURE character precedence table. The I
leftmost column and uppermost row for each symbol represents its use to the left of thel
decimal point position. The second appearance of the symbol in the table represents
I
its use to the right of the decimal point position.
I
({}) indicate items that are mutually exclusive
lIBraces
_______________________________________________________________________________________
JI
Figure 15.

Precedence of Symbols Used in the PICTURE Clause

Data Description Entry -- Details of Clauses

121

PICTURE Clause
NUMERIC ITEMS: There are two types of numeric items:
and'floating-p6int items.

fixed-point items

Fixed-Point Numeric Items: Ther~}!.~.~~-,;t:h,Fe(§!, • ~'yP_~S ,9.tJixed-point nUIT,eric
items: external decimal, binary l.~L!1tlf£qill'lWmBl.i~~Il!_i;~ See the
discussion of the USAGE clause for details concerning each.
The PICTURE of a fixed-point numeric item may contain a valid
combination of tne following symbols:

v

9

P

S

Examples of fixed-point numeric items:
PICTURE
9999
S99
S999V9
PPP999
S999PPP

Valid Range of Values
o through 9999
-99 through +99
-999.9 through +999.9
o through .000999
-1000 through -999000 and
+1000 through +999000 or zero

The maximum size of a fixed-point numeric item is 18 digits.
The contents of a fixed-point numeric item, when represented in
Standard Data Format, must be a combination of the Arabic numerals 0
through 9; the item may contain an operational sign. If the PICTURE
contains an 5, the contents of the item are treated as positive or
negative values, depending on the operational sign; if the PICTURE does
not contain an S, the contents of the item are treated as absolute
values.
Note: ASCII considerations for the
Appendix E.

PICTU~E

clause are given in

Floating-point Numeric Items: These items define data whose potenti~l,-':'F
"z;ange of value is too gr~at for fixe~-poin~ pr7sentation. ",Th.e ,~gni.t;~~~,',
'of the :number represented bya float~ng-po~nt ~tem must be grE¥lt;~r :t:h.i:i~:~-'
79 but must not :exceed .72 x 10"16.
'5.;4 x 10;"
:!':>::-~
, .
.
i
. "'
" ",":
·.~f l~

There are two 'types oi fld,ating-point items: internal ;flo~t!iJng;-;p
;;a~d. ~~~~rnalf;l<:>a:ting-PiQ~nt.; t See the discussio~of:th;e:q~,~ ~~~~
'~~tallls concern~ng each.
'
,',- ,\
.'
NdPICTUREclause may ,be
i;tem.' ,

i·,

,

,)

'.

. ; ;:';:\

If a VALUEcla'use isspeci'fied for an elementary nume,:ti'c::il~,:,
li:teral must bent.mteric. ' If lB. VALUE clause: is specifii~ ~fijx[',)a':(: ;
item Qonsisting .0£: elemen;tary:numeric items, the qr,OUpiS'

>:.'

. '. ';, "."".

'I

i<

{~-,..:~+.' ~,t. 1~'FfKPpnent
,.,',

l;

.~< . ~'

: \L~

a-- ~

r;>J;ll~~;

;'j;.

i

~trei;e~ch,;;ele~entLqf t~~,:~t~in~

r;-.!les;~ ~. :":;;;:~.:,~
,.'

122

'!.

~

Part III -- Oata Division

is composed according t,o

,~,~, H~ ;~

PICTURE Clause

,i~:'ll;~~~=qJttla~ ,. ". ..... . . ' .[ .'., .i!l:'iEtpl~.~(t
i

,\;:~'t"Tbe"pI~g

>'"

$:iJ9rl"" ~eSpage,!~ha;act~r,. i~mf ltll~ 'I·np!lm~:r

dt;$tarage,~:,anq,Clre ')i:rtcl~deq:in :tl1~ iPI;J!lIl;t1::lUt.,.;

:lJ"f:T~~,tri~ti£j;$$·:.Jmaied:i~t.~I'y: .:f(>.jJ;oY'lS·~ue "1:ixs t:~~g#,
·three··
symbols::),
.
..
.
, : . : :'. . ". . .'

·'i.~· ..· isreprese:q.tedt1sing.~thef()llo,wing
, ..
, ·r.·
"
. ' .: , .
:.
. .. :
~

';'"

,:~,

'i~
.. ",
~

>f.,

i

'·,i. y(:.

?

'.J,.

':.:'9 ':" ': ' .E~h, ~

,,'

: ',.

.

.1,\

in the ~ntissa",·,ch,(lriiqt~f<$.ti~rig:repJ;'~s,~~t:S.::i~Ai9
\ " ,:.:." int.o,' w1;lich ,,'~ " fl\1lner i'c·:,ctla~~¢t;,e:r.:·wi'l]:.qe,.pla·c,eq·~:. : '~~Oqt !,OIJe'
!:':'.','..\ ';", ~ ):ll'aY 'be, ,p,resen:t' In:','the'',st:I:',i,{lg ..,., ... tClcb:,,~~.g~tt,<·po$i):ii>ri ' ,

,9:

'', ,:'
',' . \h. "

"

'

'",'''';

',';"

", .,".' .: ' ',<

h,

,

"

'.h.'

< •Y < ,

',%i;t~:,~~*ie~~.~$~~iMtl)~1'~~~.....r'·~~i~~'''.''.~~trai'l~tig .. s.yfnbQi ~.:, '
.

.

. :.

.

inqica~~s:~t·he':'eXpqn~itt#: . . ~nd··;romeaia~~l.Y ·;£cillows· t:he
occtipieso?-e",byte of" "·sto~ag,e..
. ..
< •• ; ~~..

~ .. ,

':.;,':,:)?!:r.;, "., .:: ".:.<';,',

~.,

:.

,

'..,

'

,.",' '.,"" "'. ','. ....,>.'.', ." . . ' ,•... ,\.

..

" " , . . . . , . . .',,;

·~;:f=}rgonent:'·.,Tpe.'·.ex:pQn¢llt, . ,.,i~eq,i.~t:~:Ly·.·. ~ql.l:(.)~s:.:,th~,s,e,<::O~d .. ~'·~9n'·cha,i"act.~I:,'~.·:

~~cS,<~~~.:~~~~~~~~'e.I,f~.·~~:~~,,~~?S~'t~·i<'·;:.f. ?;,()j~;.~~~~.,,:~y~.~. . .
,,'

" ,",.

»,', .:<.i-

,

·'<~'.'~'Y'

'.h

, .

~

. . :".h

•. "

'."';;

,~< ..... ,

, .. '

,,,,::>,,,: .. ~~.<,,,,./:,.. ~,~

,~ ..~

___

,

~

,

,~~

,

. ,·,'Bit·e,r.·.n.·,al.·: ·..•' d.'a.t.a~ust. dont o:rrn::tq~·'·the",r~presentaticm .'Sp~cifle, . . . . . ", ........ ' . , . . • . . . . . ,... .
.

items:
PICTURE
-9V99E-99
+999.99E+99
-V9(6)E+99
+.9(10)E-99

Format of External 'Data

Value Expressed

540E-79
+123.45E-14
565656E+45
+.7200000000E 76

+5.40 x 10 79
1-123.45 x 10 1.~
+.565656 X 10 .. 5
+.72 X 10 76

(Note that any of the above PICTURE representations can express
full range of possible values.)
No VALUE clause may be associated with an external floating-point
item.

Data Description Entry --

~etails

of Clauses

123

PICTURE Clause
ALPHANUMERIC EDITED ITEMS: An alphanumeric edited item is one whose
PICTURE character string is restricted to certain combinations of the
following symbols:

x

A

o

B

9

To qualify as an alphanumeric edited item, one of the following
conditions must be true:
1.

The character string must contain at least one B and at least one
X.

2.

The character string must contain at least one 0 and at least one
X.

3.

The character string must contain at least one 0 (zero) and at
least one A. Its contents, when represented in Standard Data
Format, are allowable characters chosen from the EBCDIC set.

USAGE IS DISPLAY is used in conjunction with alphanumeric edited
items.
If a VALUE clause is specified for an alphanumeric edited item, the
literal:must be nonnumeric. The literal is treated exactly as
specified; no editing is performed.
Editinq Rules: Alphanumeric edited items are subject to only one type
of editing: simple insertion using the symbols 0 and B.
Examples of alphanumeric edited items:
Value of Data
ALPHANUMEROl
ALPHANUMEROl
ALPHABETIC
ALPHANUMERIC

PICTURE
OOOX(12)
BBBX(12)
OOOA(12)
X(S)BX(7)

Edited Result
OOOALPHANUMER01
ALPHANUMEROl
OOOALPHABETIC
ALPHA NUMERIC

NUMERIC EDITED ITEMS: A numeric edited item is one whose PICTURE
character string is restricted to certain combinations of the symbols:

B

P

v

z

o

9

*

+

CR

DB

$

The allowable combinations are determined from the order of
precedence of symbols and editing rules.
The maximum number of digit positions that may be represented in the
character string is 18.
The contents of the character positions that represent a digit, in
Standard Data Format, must be one of the numerals.
USAGE IS DISPLAY is used in conjunction with numeric edited items.
If a VALUE clause is specified for a numeric edited item, the literal
must be nonnumeric. The literal is treated exactly as specified; no
editing is performed.
The maximum length of a numeric edited item is 127 characters.
Editing Rules:
124

All types of editing are valid for numeric edited items.

Part III -- Data Division

PICTURE Clause
Types of Editing
There are two general methods of performing editing in the PIcrURE
clause: by insertion or by suppression and replacement.
There are four types of insertion editing:
1.
2.
3.
4.

simple insertion
special insertion
fixed insertion
floating insertion

There are two types of suppression and replacement editing:
1.
2.

zero suppression and replacement with spaces
zero suppression and replacement with asterisks

Insertion Editing
Simple insertion editing is performed using the following insertion
characters:
(comma)

B (space)

o (zero)

The insertion characters are counted in the size of the item and
represent the position in the item into which the character will be
inserted.
Examples of simple insertion editing:
PICTURE
99,999
9,999,000
99B999BOOO
99B999BOOO
99BBB999

Value of Data
12345
12345
1234
12345
123456

Edited Result
12,345
2,345,000
01 234 000
12 345 000
23
456

Special insertion editing is performed using the period (.) as the
insertion character. The result of special insertion editing is the
appearance of the insertion character in the item in the same position
as shown in the character string.
In addition to being an insertion character, the period represents a
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 both the assumed decimal point,. represented by the symbol
V, and the actual decimal point, represented by the period insertion
character, in one PICTURE character string is not allowed.
Examples of special insertion editing:
PICTURE
999.99
999.99
999.99
999.99

Value of Data
1.234
12.34
123.45
1234.5

Edited Result
001.23
012.34
123.45
234.50

Data Description Entry -- Details of Clauses

125

PICTURE Clause
Fixed insertion editing is performed by using the following insertion
characters:
currency symbol
editing sign control symbols

$
+

CR

DB

Only one currency symbol and only one of the editing sign control
symbols can be used in a given PICTURE character string.
Fixed insertion editing results in the insertion character occupying
the same character position in the edited item as i t occupied in the
PICTURE character string.

$

The currency symbol must be the leftmost character position to
be counted in the size of the item, unless it is preceded by
either a + or a - symbol.

+ or -

When either symbol is used, i t must represent the leftmost or
rightmost character position to be counted in the size of the
item.

CR or DB

When either symbol is used, it represents two character
positions in determining the size of the item and must
represent the rightmost character positions that are counted
in the size of the item.

Editing sign control symbols produce results depending upon the value
of the data item as shown in Figure 16.

r---------------------------------T------------------------------------,
I
Result
I

I
I
I
I

~--------------------T---------------~
Editing Symbol in PICTURE
I
Data Item
I Data Item
I
Character String
I Positive or Zero I Negative
I
~---------------------------------+--------------------+---------------~
I
+
I
+
I
I
space
I
I
I
I
CR
I
2 spaces
I
CR
I
I
IL _________________________________
DB
2 spaces
DB
iI ___________________
_ iI _______________
JI

Figure 16.

Editing Sign Control Symbols and their Results

Examples of fixed insertion editing:
PICTURE
999.99+
+9999.99
9999.99$999.99
-$999.99
$9999.99CR
$9999.99DB

126

Value of Data
+6555.556
-5555.555
+1234.56
-123.45
-123.456
+123.45
-123.45

Part III -- Data Division

Edited Result
555.55+
-5555.55
1234.56
$123.45
-$123.45
$0123.45
$0123.45DB

PICTURE Clause
Floating insertion editing is indicated in a PICTURE character string
by using a string of at least two of the allowable insertion characters
$ + or - to represent the leftmost numeric character positions into
which the insertion characters can be floated.
The currency symbol ($) and the editing sign symbols (+ or -) are
mutually exclusive as floating insertion characters in a given PICTURE
character string.
Any of the simple insertion characters (, B 0) embedded in the string
of floating insertion characters, or to the immediate right of this
string, are part of the floating string.
In a PICTURE character string, there are only two ways of
representing floating insertion editing:
1.

Any or all leading numeric character positions to the left of the
decimal point are represented by the insertion character.

2.

All of the numeric character positions in the PICTURE character
string are represented by the insertion character.

The result of floating insertion editing depends upon the
representation in the PICTURE character string:
1.

If the insertion characters are only to the left of the decimal
point, a single insertion character is placed into the character
position immediately preceding the first nonzero digit in the data
represented by the insertion symbol string or the decimal point,
whichever is farther to the left of the PICTURE character string.

2.

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 characters are only to the left of the
decimal point.

To avoid truncation when using floating insertion editing, the
programmer must specify the minimum size of the PICTURE character string
for the receiving data item to be:
1.

The number of characters in the sending item, plus

2.

The number of insertion characters (other than floating insertion
characters) being edited into the receiving data item, plus

3.

One character for the floating insertion character.

Examples of floating insertion editing:
PICTURE
$$$$.99
$$$$9.99
$$,$$$,999.99
++,+++,999.99
$$,$$$,$$$.99CR
$$,$$$,$$$.99DB
++,+++,+++.+++

Value of Data
.123
.12
-1234.56
-123456.789
-1234567
+1234567
0000.00

Edited Result
$.12
$0.12
$1,234.56
-123,456.78
$1,234,567.00CR
$1,234,567.00

Data Description Entry -- Details of Clauses

127

PICTURE Clause
Zero Suppression and Replacement Editing
Zero suppression and replacement editing means the suppression of
leading zeros in numeric character positions and is indicated by the use
of the alphabetic character Z or the character * in the PICTURE
character string. If Z is used, the replacement character will be the
space; if * is used, the replacement character will be *.
The symbols + - * Z and $ are mutually exclusive as floating
replacement characters in a given PICTURE character string.
Each suppression symbol is counted in determining the size of an
item.
Zero suppression and replacement editing is indicated in a PIcrURE
character string by using a string of one or more of either allowable
symbol 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.
Simple insertion or fixed insertion editing characters to the left of
the string are not included.
In a PICTURE character string, there are only two ways of
representing zero suppression:
1.

Any or all of the leading numeric sharacter positions to the left
of the decimal point are represented by suppression symbols.

2.

All of the numeric character positions in the PICTURE character
string are represented by suppression symbols.

If the suppression symbols appear only to the left of the decimal
point, any leading zero in the data which appears in a character
position corresponding to a suppression symbol in the string is replaced
by the replacement character. Suppression terminates at the fi~st
nonzero digit in the data 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 of the data is zero, the entire data item will be spaces
if the suppression symbol is Z, or it will be asterisks (except for the
actual decimal point) if the suppression symbol is *.
If the value of the data is zero and the asterisk is used as the
suppression symbol, zero suppression editing overrides the function of
the BLANK WHEN ZERO clause, if specified.
Examples of Zero Suppression and Replacement Editing:
PICTURE
ZZZZ.ZZ
****.**
ZZZZ.99
****.99
ZZ99.99
Z,ZZZ.ZZ+
*,***.**+
**,***,***.**+
$Z,ZZZ,ZZZ.ZZCR
$B*,***,***.**BBDB

128

Pact III

Data Division

Value of Data
0000.00
0000.00
0000.00
0000.00
00000.00
+123.456
-123.45
+12345678.9
+12345.67
-12345.67

Edited Result
****.**
.00
****.00
00.00
123.45+
**123.4512,345,678.90+
$
12,345.67
$ ***12,345.67 DB

, SIGN"CTause(Version3)
Program Product Information -- Version 3

~J~~~ii~~!;ij~{[~~~t,[jifit1~:;i',/

.

~.'0.~~.:::e.·.·· ';S.tGN:cliii~s~~~\~i)t:~~i;lffjfi:eS(.l't~e,~:iPO~d;tionandinOde.Qf'representation' of
'~L.U 'P~~r,atir~~:l,:,·si}Jp.)f~r.
data,descr:iptionentry.
, ' .. ': .". .. . ,. )' .. . . .' .Ja'n~,ic
t' . " ." .:'
~ ~

i"

.

"

"

"

,

h',·".ll",

.

~<~~

~'~'.;

.

,.~~.

-,'

". r

"

'

<." ~.~;. ,
'-:..>'"''

; ",:. ;"...~

+

'.:'~<:.~ .~~:(.~

'J~ ,
y'

~. ~'. -:~,

' . ( \ ••••

,'::r·"l'--~~';"'~-:"':""'-:;~';"':~";;'~T-:-.Jj~·:",,·--~r,""-:'~~':'""~T:':''-'--:""~'~~:''''-'~~·"'':'"''~';''';':''"'-~'':'''':''~~'~-:-~''''~,~'':'"'--'i

~":~h~·,':'~,~'GN.,'."~1~'~:~':'.'.is',,'::r:e4~ii'i:~A'··'Qtily::.:,'··~he#·.·.'?,h': .·.'~*Pl".ic±t··.·:,d,es·cri1?tiori:,Of" ....the·'
:~p~op,e:~ti~S .• ·.Qf·.,:t,h7·'·opera.ti,onal,':~lgn'iS~.~.necessc1JPi~ . . .,:.,' .. '.:.,,",.:....

.:.';"

:~.:.~he':'nu~e~i~:,:d~'t~ . "de'~·~r.i Pt'io~',eri~ rl:~s., . t~6 'Whi¢h:"'trl~'.·. ~lGN '::dl arise,
. 'iii>~l'ies··'. must;'~"'::'~*pli:6itii or': imp.l:ic:i:tlYj 'be·':,.de'$'(:r'iped: ..a,s
',DISPL-AY:.··,~·, . ",
'
,

.

~

i :

.

y',

'.,:,

."

<:. : .'~,

)'

OSAGE,

' : ., <

,

~S..
'.,.~.

< : ,

':·:()~·~f,:bh~·:siGN:cia't1S,~,'p~ri!l,~i,9~Cl:l,.~;i~Il,>,f6,r-.ttle' ~l~Rleri·c ... cia'ta:· .... ":':"'" '
:·ca.~~Qr:ip;i;c:)#:::~'[rtiy:" to:::wh~'¢:~: ."i:t:Apf?lie,~';..:: 9~.,J9,~"~clC:h' nuine·ti.::·:aat.-?'{', : ..... ::

\·4~s:S·tj:i?:~:d,<)]:1,·~ntr·y,{:lubol?d:l-~i:l.'~'e';'t();,tl;te,::;,gr:oup':to':\tlh:ich,,'i·;,,"applies·~',.':'·•. :.,,:,

':"!£:.::::~~~~':·~Ek~Arr~,·.~HA,R·~~;~·R':,;~;~ti:~~:i~ ':~ot: $~~~'if,~~d, ,,~hen:' ,"
\. :

~
"

The'

ope~~'tional 'si9~ i~

presumed to

b~' a~sOciated

.' " ''-'..,'. "" :,>.:

with the

LE~DI.NGorTRAILING, d~git.'PQsition,,'whiclleveris·specified;'

of

theelementary.numer.ic dat.a .,item.
(In thisinstan:cei
specifica:tion.()f SIC;N,ISTRAILING is. .the eq~i valent ;ofthe,
'standard, action of the cOlT\P~le:r~)'
,
'
• 'Th.~<:!'ha:ta<:!ters'J.n the PICTURE character string is.not counted
in , deterrnihing 'the' size of the item (interms,'or'StandardData
Format characters).
If the SEPARATE CHARACTER option is specified, then:
• The operational sign is presumed to be the LEADING or TRt\_ILING
character position, whichever is specified, of the elementary
numeric data item. This character position is not a digit
position.
• The character S in the PICTURE character string is counted in
determining the size of the data item (in terms of Standard Data
Format characters).
•

+ is the character used for the positive operational signo

• - is the character used for the negative operational sign.
Data Description Entry -- Details of Clauses

129

SYNCHRONIZED Clause
'"

• -At object time if Qne of the characters + or - is not present i,n
the data an error occurs, and the program will termina.te
abnorma~lY ..,
'd:esciipt;iqlientry!wtlosePlcTqRE c0l1;tainstl1e:: ":
if .the !~U~~N
:eq-qr~,: ,an~~q~n.v:erc~i~~ ,i;~ ',,~~c!~s,~a.~y; ~.~~'~:i\ir:'

:S:Lq]n.ect,' !nqm~l:iic;data,.,de~crifltiQnentry;"

tQj~: J(:lQIqpl~~~·iJQiQIF1· ,1~911. '!dqnqtlrlli~driS,t!~qn~~ljSllqtl ,ta'ke!~ iP~~C:if;:

:Qa\U;jJ!Qai.L.~~'\'

' '

i' ~

f,

',V

,

"if""

"

, ' ,"

'

SYNCHRONIZED Clause
The SYNCHRONIZED clause specifies the alignment of an elementary item
on one of the proper boundaries in core storage.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------~

I

I

I

{SYNCHRONIZED}
SYNC

[LEFT]
RIGHT

:

I
I
IL______________________________________________________________________ JI

The SYNCHRONIZED clause is used to ensure efficiency when performing
arithmetic operations on an item.

If either the LEFT or the RIGHT option is specified, it is treated as
comments.
The length of an elementary item is not affected by the SYNCHRONIZED
clause.
When the SYNCHRONIZED clause is specified for an item within the
scope of an OCCURS clause, each occurrence of the item is synchronized.
When the item is aligned, the character positions between the last
item assigned and the current item are known as "slack bytes." These
unused character positions are included in the size of any group to
which the elementary item preceding the synchronized elementary item
belongs.
The proper boundary used to align the item to be synchronized depends
on the format of the item as defined by the USAGE clause.
130

Part III -- Data Division

SYNCHRONIZED Clause
When the SYNCHRONIZED clause is specified, the following actions are
taken:
For a COMPUTATIONAL item:
1.

If its PICTURE is in the range of S9 through S9(4), the item is
aligned on a halfword (even) boundary.

2.

If its PICTURE is in the range of S9(5) through S9(18), the item is
aligned on a fullword (multiple of 4) boundary.
,

"

';po.r~'·: a~c'oMPUTltT:r:~-'1:1
U

I 1-1

i I

I
fA
Slack I
I
Bytes

I

I

I
I

COMP-PAY

1

I COMP- I
I HOURS I
I

1
I

I

I

I

I

I

COMP-NAME
I

I

1

!

!

1
1

I

I
I

I

I

0

0

I

I

I

1

I

I

I

I

I

I

I

J

1

F

F

I
I
i

1

1

I

I

I
I
I
I

1

I

1

I
1

1

1
F

0

0

o = cIoubleword boundary
F = fullword boundary
H = halfword boundary

Figure 17.

Insertion of the Intra-occurrence Slack Bytes
\

In order to align COMP-PAY and COMP-HRS upon their proper boundaries,
the compiler has added two intra-occurrence slack bytes (shown above as
IA-SLACK-BYTES).
However, without further adjustment, the second occurrence of
COMP-TABLE would now begin one byte before a doubleword boundary, and
the alignment of COMP-PAY and COMP-HRS would not be valid for any
occurrence of the table after the first. Therefore, the compiler must
add inter-occurrence slack bytes at the end of the group, as though the
record had been written:
Data Description Entry -- Details of Clauses

133

Slack Bytes
WORK-RECORD.
02 WORK-CODE
02 COMP-TABLE OCCURS 10
03 COMP-TYPE
[03 Ia-Slack-Bytes
03 COMP-PAY
03 COMP-HRS
03 Cor"IP- NAME
[03 Ie-Slack-Bytes

01

PICTURE
TIMES.
PICTURE
PICTURE
PICTURE
PICTURE
PICTURE
PICTURE

x.
X.
XX.
Inserted by compiler]
S9(4)V99 COMP SYNC.
S9(3) COMP SYNC.

xes).

XX.

Inserted by compiler]

so that the second (and each succeeding) occurrence of COMP-TABLE begins
one byte beyond a doubleword boundary.
The storage layout for the first
occurrences of COMP-TABLE will now appear as shown in Figure 18.

I

i

I

...
I.t---------First Occurrence of COMP-TABLE-------il.*I.....- - - - - S e c o n d Occurrence of COMP-TABLE-----....-;
.. ,
I

~~

:

I

~ 81d. I
1::E:;e

18 ~I
I

I

I

IA

Siock
Bytes

I

I

I

I
I

HOURS

I

COMP-NAME

I

I
I

Slack I
Bytes:

I

I

D

D

I

I

I

IE

I COMPCOMP-PAY

I

I

D

o

D = doubleword boundary
F = fullword boundary
H = halfword boundary

Figure 18.

Insertion of Inter-occurrence Slack Bytes

Each succeeding occurrence within the table wili now begin at the same
relative position to word boundaries as the first.

Where SYNCHRONIZED data items defined as COMPUTATIONAL,
follow an entry containing an OCCURS
clause with the DEPENDING ON option, slack bytes are added on the basis
of the field occurring the maximum number of times.
If the length of
this field is not divisible by the ~ required for the computational
data, only certain values of the data-name that is the object of the
DEPENDING ON option will give proper alignment of the computational
fields.
These values are those for which the length of the field times
the number of occurrences plus the slack bytes that have been calculated
based on the maximum number of occurrences is divisible by ~.

~_'<~~~l!i';<~~

For example:
01

134

FIELD-A.
02 FIELD-B
02 FIELD-C
DEPENDING ON FIELD-B.
[02 Slack-Byte
02 FIELD-D

Part III -- Data Division

PICTURE 99.
PICTURE X OCCURS 20 TO 99 TIMES
PICTURE X. Inserted by compiler]
PICTURE S99 COMP SYNC.

D

,

Slack Bytes
In this example, when references to FIELD-D are required, FIELD-B is
restricted to odd values only.
01

FIELD-A.
02 FIELD-B
02 FIELD-C
DEPENDING ON FIELD-B.
[02 Slack-Byte
02 FIELD-D

PICTURE 999.
PICTURE XX OCCURS 20 TO·99 TIMES
PICTURE X.
Inserted by compiler]
PICTURE S99 COMP SYNC.

In this example all values of FIELD-B give proper references to
FIELD-D.

INTER-RECORD SLACK BYTES:

If the file contains blocked logical records

tha
t . are defl.ned
to. be processed
in a bU;~~.~,~.":r:r:. "ff..,,,.,,., 0 0;...~n~.~d
.. " . a,a.H
.n. . "."'~o.>.f.._.~.'~.:l;1.'?t._,e.'.;.l . . ~. .r. _
. ",.c.,.,.•~-',.
.r.':. c.~
,."..S
.:. . ,. .
,. . 5?.,
o.,. . ~.,.t
.
. . . . ~....e
i. . "n
.
entrl.es
as COMPUTATIONAL~;{'~~~~~~:~\t~::":L',
-: ..;
~ ,,_._~_. ~,,_. ~ _,.~.(i
for which the SYNCHRONIZED clause is specified, the user must add any
~er-r~ord slac$ bytes needed for proper alignment.

,x. . . '. _

:1>j.,
..• ,'., •.'.

The lengths of all the elementary data items in the record, including
all intra-record slack bytes, are added. For mode V recorgs, i~
n~e~c~e~s~s~a~r~~t~o~~d~d~~~-u¥-~~~~t~huge~c~o~u~n~t~rJ~l.~e~ld. The total is then
ivided by the highest va·lue of !!! for anyone of the elementary iterrls in
the record.
If r (the remainder) is equal to zero, no inter-record slack bytes
are required.
If £'is not equal to zero, !!! - £ slack bytes are
required. These slack bytes may be specified by writing a level-02
FILLER at the end of the record.
Example: The following example shows the method of calculating both
intra-record and inter-record slack bytes.
Consider the following
record description:
01

COMP-RECORD.
02 A-l
PICTURE
02 A-2
PICTURE
02 A-3
PICTURE
02 B-1
PICTURE
02 B-2
PICTURE
02 B-3
PICTURE

XCS).
X(3).
X (3).
S9999 USAGE COMP SYNCHRONIZED.
S99999 USAGE COMP SYNCHRONIZED.
S9999 USAGE COMP SYNCHRONIZED.

The number of bytes in A-l, A-2, and A-3 total 11. B-1 is a 4-digit
COMPUTATIONAL item and, therefore, one intra-record slack byte must be
added before B-1. With this byte added, the number of bytes preceding
B-2 total 14. Since B-2 is a COMPUTATIONAL item of 5 digits in length,
two intra-record slack bytes must be added before it. No slack bytes
are needed before B-3.
The revised record description entry now appears as:

01

COMP-RECORD.
02 A-l
02 A-2
02 A-3
[02 Slack-Byte-l
02 B-1
[02 Slack-Byte-2
02 B-2
02 B-3

PICTURE
PICTURE
PICTURE
PICTURE
PICTURE
PICTURE
PICTURE
PICTURE

XeS).
X(3).
X(3).
X.
Inserted by compiler]
S9999 USAGE COMP SYNCHRONIZED.
XX.
Inserted by compiler]
599999 USAGE COMP SYNCHRONIZED.
59999 USAGE COMP SYNCHRONIZED.

There are a total of 22 bytes in COMP-RECORD, but from the rules
given in the preceding discussion, it appears that!!! = 4 and ~ = 2.
Data Description Entry -- Details of Clauses

135

USAGE Clause
Therefore, to attain proper alignment for blocked records, the user must
add two inter-record slack bytes at the end of the record.
The final record description entry appears as:
01

COMP-RECORD.
02 A-1
02 A-2
02 A-3
[02 Slack-Byte-1
02 B-1
[02 Slack-Byte-2
02 B-2
02 B-3
02 FILLER

PICTURE
PICTURE
PIC'l'URE
PICTURE
PICTURE
PICTURE
PICTURE
PICTURE
PICTURE

X (5) .
X(3).
X ( 3) •

X.
Inserted by compiler]
S9999 USAGE COMP SYNCHRONIZED.
XX.
Inserted by compiler]
S99999 USAGE COMP SYNCHRONIZED.
S9999 USAGE COMP SYNCHRONIZED.
XX. [inter-record slack bytes added by
user]

USAGE Clause
The USAGE clause specifies the manner in which a data item is
represented in core storage.

r----------------------------------------------------------------------,

I

Format 1

I

t----------------------------------------------------------------------~

I
I

DISPLAY

{~~:~ATIONAL}

:

I
I
I
I
:

[USAGE IS]

l

C
' OMPUTATIONAL-l}',

.COMP-l
COMPUTATIONAL- 2}
CQMP-2'

{~g:~;ATION~.~3}

I
I

I
I
I
I
I

I

I
.DIsiPUY-ST:" :i
I
I
INDE~
I
Il ______________________________________________________________________ JI

The USAGE clause can be specified at any level of data description.
However, if the USAGE clause is written at a group level, it applies to
each elementary item in the group.
The usage of an elementary item
cannot contradict the usage of a group to which an elementary item
belongs.
This clause specifies the manner in which a data item is represented
in core storage. However, the specifications for some statements in the
Procedure Division may restrict the USAGE clause of the operand referred
to.
136

Part III -- Data Division

USAGE Clause
If the USAGE clause is not specified for an elementary item, or for
any group to which the item belongs, it is assumed that the usage is
DISPLAY.
Note: ASCII considerations for the USAGE clause are given in
Appendix E.

DISPLAY OPTION
The DISPLAY option can be explicit or implicit.
It speclIles Lnat
the data item is stored in character form, one character per eight-bit
byte. This corresponds to the form in which information is represented
for initial card input or for final printed or punched output.
USAGE IS
DISPLAY is valid for the following types of items:
• alphabetic
• alphanumeric
• alphanumeric edited
• numeric edited
• external decimal

The alphabetic e alphanumeric, alphanumeric edited, and numeric edited
items are discussed in the description of the PICTURE clause.
External Decimal Items: These items are sometimes referred to as zoned
decimal items.
Each digit of a number is represented by a single byte.
The four high-order bits of each byte are zone bits; the four high-order
bits of the low-order byte represent the sign of the item. The four
low-order bits of each byte contain the value of the digit.
When
external decimal items are used for computations, the compiler performs
the necessary conversions.
The 'maximum length of an external decimal item is 18 digits.
Examples of external decimal items and their internal representation
are shown in Figure 19.

0#'.,

t

.;.

!

I

1

, 'THe value of 'an external :t'loat1ng'-:'point :nurriber~ is :tneman'tTs'sa ,,'
[mJltiplied by the power 'of: ten expressed bY' the exponent. The magnitude
:of a, number represented by a fl,oating~point item must be greater than
'rS.4 ,x (10- 79 ) but must not ~xceed .12 X (10 76 ) .
When used as a numeric operand an external floating-paint number is
lscanned at object time, and converted to the equivalent internal
1floating-point values. In this form, the number is used in arithmetic
:operations.
(See cor4PUT~TIONAL-l and COMPUTATIONAL-2 options.)
Data Description Entry -- Details of Clauses

137

USAGE Clause

The Computational Options
"" '
al;.
, ,_
.
a value to be used in arithmetic
operations and must be nUlr,eric.
If the USAGE of any group item is
described with any of these options, it is the elementary items within
this group which have that USAGE.
The group item itself cannot be used
in computations.
A COMPUTATIONAL

'.

'"

""".'

•• '

,,'

.

,.,'..

•

"..

i~k~~'i!w~1+a item represents

' ... '

.,'

....

,". ',C

.

'

..

'

','

'.<,

"

..

..

.""'

"."

•..

COMPUTATIONAL OPTION: Ttis option is specified for Dinary data items.
such items have a decimal equivalent consisting of the decimal digits 0
through 9, plus a sign.
'l'he amount of storage occupied by a binary item depends on the number
of decimal digits defined in its PICTURE clause:
Digits in PICTURE Clause
1 througn 4
5 through 9
10 througfl 18

Storage Occupied
2 bytes (halfword)
4 bytes (fullword)
8 bytes (2 fullwords
not necessarily
a doubleword)

The leftmost bit of the storage area is the operational sign.
The PICTURE of a COMPUTATIONAL item may contain only g's, the
operational sign character S, the implied decimal pOint V, and one or
rrore PiS.
An exarrple of a binary item is shown in Figure 19.
Note:
The COMPUTATIONAL cption is system dependent and normally is
assigned to representations that yield the greatest efficiency when
perforwing arithmetic operations on that system; for tnis compiler, the
CCMPCTA~IONAL option is binary.
"COt-'lPU'lATIONAL-h cor~PUTA'lIJNiil.L- 2 OPTIONS: 'Tt;ese options are
for internal floating-point·~tems. ,Suchan item is equivalent
:external floating";point item in capability and purpo.se~' ~.~.'Ch,
[.q<:cupY'either q, (j)'t118 byteslo" stQrage.

;< .

!

f<"

.l." i~'

1 :

'!

t.· ~·t ;

,'I:

:,:\, The 'signof :'"tlt1~
!iqrma t ...
.
': i;
t .,;,
(.[

138

i;

I.

j

r !

Tqe, iexponent

."akm?~i~:r':~.

Part III -- Data Division

:f

•

is

USAGE Clause

No PTCTtJRE clause lliayJjeassocia"t.€:d with, a'ninteinal ,floati'Il.,T , ,<~,
are two digits per .byte •.. ~ith.,th,e s,igf\:~onta:i~'~ntiielow:~qrdJe:r:;flqux;t.':
bits of the rightmost~yte.;LSllqh anit~nl 'maiyo,on:tia~'anY"¥ !thle,r idlJ;g;~';1;
o through 9, plus
a sign, :r~epres:ent'ingavalue'n~t:etx;ce'eUin'l ).:8, '~d~iimai1J~'~~,
digits.
"',
" ...'
. "; .'
..
..
I! ~.
' . !

l{

'.' , ; ,

, ,For, internal .d:ecirnalitems.who~e . ?IdTURE ,does 'inoti!contafq :an ~,; the 1~,
sign; positioJl is occupied.b,Y'.a'.hit, 'configur;;tti(>n.'ttiat is interpre:t:ed a~ ,_
pq~'j..ti'v¢·,

but ,that.··:dQes· n·o:~';,r~l?·~~~~I)~. ~l1: ~~,~r·p.~~:9~~

!

'The'-PiCTURE ,of, a COMPUTATIONAL':"3 ·ii:eiIi !lto.}' c?ntaih only ,?~s,
operatiqna'l s'ign character, s~,,'the assumed' decimal po·in-t,\l,. a,nd
mor:e,'P~ s.~',

,EX~mplf=.S,'~~:,int:~in~i;'deci,irta'l". items ani! ,th~ii::\nt'e,rn~i,,~~p'i:e,~~,~'~#,i~i6~:::,;:
•

'

c,

1?·i(;Jl.ri:":~ ,

,', '

~

,

" ' '<:., .

~

Y'
"; . ,>

,~. '··i~~
tOMP~TA~IONAL-,'4 ,;:OPT'ION':.· '.This; ;C>pt'ion"'~fFor:mat,..2)'::'.i'~, ,specifi~':¥pt,'; '. \']:,:'

,~'"sys,teni-: indep~'ndent:,binaryi,tems:.'" ::, For 'th~,~,:compil.e'Z:'T,; ,it', is'··th'e ',:",:,.,,', :':",:

: ,e'quivalent()f'CO,MP~,TAt,IOt~AL.

',

' ,

" ,

" US1\.ti~' .bIsPLAy::':s'T is' di~cusS~'d: in

US~GE

the q·b.?rPt,¢~::· ()rl"!?"~~I:JJl'lg :c.u.r:r:~ncy~
INDEX is discussed in the chapter on Table Handling.

Data Description Entry -- Details of Clauses

139

USAGE Clause

r----------------T---------T---------------T---------------------------,

I

I

Item

Value

I Description

I

Internal Representation* I

~----------------+---------+---------------+---------------------------~

External Decimal

-1234

IZ11 Z21Z31 F41

DI8PLAY
PICTURE 9999

L __

.L __ .L __

I

I

~

byte
DISPLAY
PICTURE 89999

IZ11Z21Z31
.L __ .L __ J. D4
__ J1

L __

~

byte
Note that, internally,
the D4, which represents
-4, is the same bit
configuration as the
EBCDIC character M.
~----------------+---------+----:_-----:-:----:t:-.:--:-----------------------~~

:l,;;'{,"

I

I(Version 3)

I
I
I
I

I DISPLAY
: f!~;
I 'PICTURES9999lf~'l":
I ~J:G~ .LEADI. I1G, 1,~i~J
I I : ; ',~;i~J

,

,

I D11 Z2lZ3jZ41
L __

:

"ll'h'!

.L_-:..L __..L_.... J: '

"-.-'

byt~

; ,

i (

,

I
. J!,,~~;NDi~~ th~a~ i~te::na,1~y;Hfr
,it'ltil~~:
t,: ~. ~Cl~ reprvs~n\..s,;,n..l;'
I ', :ft,fr,U.: "esaJrnebit ;; ;"J;'~k:

'
,
I
II

,..I..

~~r~-,f;

1"

i; : \\~ j'"

l

I" : : '

I

I

I '

It

,,' t~' ;.;;

I
I

1~
I 11

,iI"
;I~;;

,

"rguraticiti ~ast111~T~f'"

"~4~rnn ~1~\':~;';

c

~-ilr.n :3,)1

i

~'

"I • ft,; ~,~:)

~:'I~' ~t14
." . ,

" '.

' .

.

;":

I

~----------------+---------+J~~~~'~--~:!~'ctj'~fJU21]~it~~ _______________,_~~~_:~

I Binary
1

I
I

I

1

1

I
I

I

-1234

ICOMPUTATIONAL 1
PICTURE 899991

I

1

I

I

I . '.' , : 1.:' ';.;,

I
'. I

L(~~'QIl;'-~)l"f"i: I
I~.
·.4H' '.::'" i;.·~;!.' .·.•. 1
~-~~;';UJ..j·"

I
I

I
I

I
1

1·'~J?:~~~L.:,~9,9,:1

I

1

I

I

111111101110010111101
L ____

t

.L ____ L ____ .L ____ J

~

S

byte

Note that, internally,
negative binary numbers
appear 1..n two's
complement form.

1
I
I

I
I

I

I
I

I

t----------------.L---------J.---------------J.--------------------------_~

*Codes used in this column are as follows:
Z = zone, equivalent to hexadecimal F, bit configuration 1111

Hexadecimal numbers and their equivalent meanings are:
F
nonprinting plus sign (treated as an absolute value)
C
internal equivalent of plus sign, bit configuration 1100
D
internal equivalent of minus sign, bit configuration 1101
8

sign position of a numeric field; internally,
1 in this position means the number is negative
o in this position means the number is positive

I

b = a blank
______________________________________________________________________
J
Figure 19.

140

Internal

R~presentation

Part III -- Data Division

of Numeric Items (Part 1 of 2)

USAGE Clause

r----------------T---------T---------------T---------------------------,
I

I

Item

Value

~__:-:-:--:--:-:--:--: __ --:~__:--:l... ---:--:--

IDescription

I

. .....

I ]::llternal.·~.ci~:ti·,.:. ,:,: ,',:.

.

Internal Representatio~* I
---~-----__:-:~---------------~

I

. ,.

I;EXt~ina;l\·, :::. L,,"; Jl~tt2'..,:a4!~+,:~lTj:r;s~y·' ,.; .
I "FlCiat;.iiig:-'Pdinjt'li ' .~.) 1;1 ;\p:rCT:Uf¢·;:
I
' , '
'f} It"
, " :';, 1· '+99'~'~9E:",~9,"
j',

t.~t~~1':1t7~~~ti':~""i'I''''';'·'''•.

'.-~';O-~;- .;.".-~,~*'""~'i""+"~,.,..,

-"'"''J"',--'"-'
......;..;.:.,..;...,.,. ....',......

I ""Flb~t'.i.ng,;;.~9,:l;rl~,1

.

.....--...-..,...;..;...::.;.-....

..,+'_'A~

....;;.;

"":",,,:,:.:;,;f"~~:

I*Codes used in this column are as follows:

'

I
z = zone, equivalent to hexadecimal F, bit configuration 1111
I
Hexadecimal numbers and their equivalent meanings are:
I
F
nonprinting plus sign (treated as an absolute value)
I
C
internal equivalent of plus sign, bit configuration 1100
I
D
internal equivalent of minus sign, bit configuration l1Cl
I
I
sign position of a numeric field; internally,
S
I
1 in this position means the number is negative
I
o in this position means the number is positive
I
I
b = a blank
IL_____________________________________________________________________
_
Figure 19.

Internal Representation of Numeric Items (Part 2 of 2)

Data Description Entry ...... Details of Clauses

141

VALUE Clause
VALUE Clause
The VALUE clause is used to define the initial value of a
Working-Storage item or the value associated with a condition-name.
There are two formats of the VALUE

clause~

r----------------------------------------------------------------------,

I

I

Format 1

r----------------------------------------------------------------------~

I
I
I
VALUE IS literal
I
lI ______________________________________________________________________ JI

r----------------------------------------------------------------------,
I

I

Format 2

~----------------------------------------------------------------------~

I
I
I {VALUE IS }
I
literal-1 [THRU literal-21
I
VALUES ARE
I
I
I
I
[Ii teral-3 [THRU literal-411...
I
Il _____________________ ________________________________________________ JI
~

The VALUE clause must not be stated for any item whose size, explicit
or implicit, is variable.
A figurative constant may be sUbstituted wherever a literal is
specified.
Rules governing the use of the VALUE clause differ with the
particular section of the Data Division in which it is specified.
1.

In the File section~;~' ~~~r the VALUE clause must
be ,used o,nly in,condit,ion-name eptries. ~'.
··,w.~er;'i;"th)i~, . •~ ,','

~Jl1l !a~tioo ;un:;rir-h;.i k116i.~icl

Ii!nl

»~

lFti

.,_U'.f.! , ~;iaInat"·

~,~~.r~;~lPJt~~:,;~~J4t:~~~:lr ;iJ ~~ •.\ Ff rtL·r:t··1fJ·~ttJ
2.

In the Working-Storage Section, the VALUE clause must be used in
condition-name entries, and it may also be used to specify the
initial value of any data item.
It causes the item to assume the
specified value at the start of execution of the object program.
If the VALUE clause is not used in an item's description, the
initial value is unpredictable.

3.

In the Report section, the VALUE clause causes the report data item
to assume the specified value each time its report group is
presented. This clause may be used only at an elementary level in
the Report Section. The Report Section is discussed in detail in
the "Report Writer" chapter.

The VALUE clause must not be specified in a data description entry
that contains an OCCURS clause or in an entry that is subordinate to an
entry containing an OCCURS clause.
This rule does not apply to
condition-name entries.
Within a given record description, the VALUE clause must not be used
in a data description entry that is subsequent to a data description
entry which contains an OCCURS clause with a DEPENDING ON phrase.
142

Part III -- Data Division

Page of GC28-6394-4, -5, -6 revised 12/03/76 by TNL GN26-0887
VALUE Clause
The VALUE clause must not be specified in a data description entry
which contains a REDEFINES clause or in an entry which is subordinate to
an entry containing a REDEFINES clause. This rule does not apply to
condition-name entries.

If the VALUE clause is used in an entry at the group level, the
literal must be a figurative constant or a nonnumeric literal. The
[ VALUE clause then cannot be specified at subordinate levels within
this group.

The VALUE clause cannot be specified for a group containing items
with descriptions including JUSTIFIED, SYNCHRONIZED, or USAGE (other
than USAGE IS DISPLAY).

The following rules apply:
1.

If the item is numeric, all literals in the VALUE clause must be
numeric literals. If the literal defines the value of a
Working-Storage item, the literal is aligned according to the rules
for numeric moves, except that the literal must not have a value
that would require truncation of nonzero digits.

2 ..

If the item is alphabetic or alphanumeric (elementary or group),
all literals in the VALUE clause must be nonnumeric literals. The
literal is aligned according to the alignment rules (see "JUSTIFIED
Clause"), except that the number of characters in the literal must
not exceed the size of the item.

3.

All numeric literals in a VALUE clause of an item must have a value
that is within the range of values indicated by the PICTURE clause
for that item. For example, for PICTURE 99PPP, the literal must be
within the range 1000 through 99000 or zero. For PICTURE PPP99,
the literal must be within the range .00000 through .00099.

4.

The function of the editing characters in a PICTURE clause is
ignored in determining the initial appearance of the item
described. However, editing characters are included in determining
the size of the item.

Format 1 of the VALUE clause must not conflict with other clauses
either in the data description of the item or in the data descriptions
within the hierarchy of this term.
Format 2 of the VALUE clause is used to describe a condition-name.
Each condition-name requires a separate level-SS entry. A Format 2
VALUE clause associates a value, values, or range of values with the
condition-name.
In a condition-name entry, the VALUE clause is required
and is the only clause permitted in the entry.
A condition-name is a name assigned by the user to the values a data
item may assume during object program execution. A condition-name must
be formed according to the rules for data-name formation. The
condition-name entries for a particular conditional variable must follow
the conditional variable. Hence, a level-8S entry must always be
preceded either by the entry for the conditional variable or by another
level-88 entry (in the case of several consecutive condition-names
pertaining to a given item).
Data Description Entry -- Details of Clauses

143

RENAMES Clause
The THRU option assigns a range of values to a condition-name.
Wherever used, literal-1 must be less than literal-2, literal-3 less
than literal-4, etc.
The type of literal in a condition-name entry must be consistent with
the data type of the conditional variable.
In the following example,
CITY-COUNTY-INFO, COUNTY-NO, and CITY are conditional variables; the
associated condition-names immediately follow the level-number 88. The
PICTURE associated with COUNTY-NO limits the condition-name value to a
2-digit numeric literal. The PICTURL associated with CITY limits the
condition-name value to a 3-character nonnumeric literal. Any values
for the condition-names associated with CITY-COUNTY-INFC cannot exceed 5
characters, and the literal (since this is a group item) must be
nonnumeric:
05

05

CITY-COUNTY-INFO.,
VALUE "03NYC".
88 BRONX
VALUE "24NYC" .
86 BROOKLYN
VALUE "31NYC".
88 MANHA'ITAN
VALUE "41NYC".
88 QUEENS
VALUE "43NYC".
88 STATEN-ISLAND
10 COUNTY-NO
PICTURE 99.
VALUE 14.
88 DUTCHESS
VALUE 24.
88 KINGS
VALUE 31.
88 NEW-YORK
VALUE 43.
88 RICHMOND
PICTURE X (3) •
10 CITY
88 BUFFALO
VALUE "BUF".
VALUE "NYC".
88 NEW-YORK-CITY
88 POUGHKEEPSIE
VALUE "POK".
POPULATION

...

Every condition-name pertains to an item in such a way that the
condition-name may be qualified by the name of the item and the item's
qualifiers. The use of condition-names in conditions is described in
"Conditions."
A condition-name may pertain to an item (a conditional variable)
requiring subscripts.
In this case, the condition-name, when written in
the Procedure Division, must be subscripted according to the requirements of the associated conditional variable.
A condition-name can be associated with any elementary or group item
except the following:
1.

A level-66 item

2.

A group containing items with descriptions which include JUSTIFIED,
SYNCHRONIZED, or USAGE other than DISPLAY

3.

An index data item (see "Table Handling")

RENAMES Clause
The RENAMES clause permits alternate, possibly overlapping, groupings
of elementary data.

r----------------------------------------------------------------------,
I
Format
I
t-----------------------------------------------------------------------1

I
I
66 data-name-1 RENAMES data-name-2 [THRU data-name-3J
I
I
Il ______________________________________________________________________ JI

144

Part III

Data Division

RENAMES Clause
One or more RENAMES entries can be written for a logical record.
All RENAMES entries associated with a given logical record must
immediately follow its last data description entry.
Data-name-2 and data-name-3 must be the names of elementary items or
groups of elementary items in the associated logical record and cannot
be the same data name. Data-name-3 cannot be subordinate to
data-name-2.
When data-name-3 is not specified, data-name-2 can be either a group
item or an elementary item. WRen data-name-2 is a group item,
data-name~i is treated as a group item, and when data-name-2 is an
elementary item, data-name-1 is treated as an elementary item.
When data-name-3 is specified, data-name-1 is a group item that
includes all elementary items:
1.

starting with data-name-2 Cif it is an elementary item); or
starting with the first elementary item within data-name-2 (if it
is a group item), and

2.

ending with data-name-3 (if it is an elementary item); or ending
with the last elementary item within data-name-3 (if it is a group
item).

A level-66 entry cannot rename another level-66 entry nor can it
rename a level-77, level-SS, or level-01 entry.
Data-name-1 cannot be used as a qualifier and can be qualified only
by the names of the level-01 or FD entries.

Both, data-name-2 and data-name-3 may be qualified.
Neither data-name-2 nor data-name-3 may have an OCCURS clause in its
data description entry nor may either of them be subordinate to an item
that has an OCCURS clause in its data description entry.
Data-name-2 must precede data-name-3 in the record description; after
any associated redefinition, the beginning point of the area described
by data-name-3 must logically follow the beginning point of the area
described by data-name-2.
For example, the following Working-Storage record is incorrect:
01

66

ERR-REC.
02 GROUP-A.
03 FIELD-1A.
04 ITEM-1A PICTURE XXXX.
04 ITEM-2A PICTURE XXX.
03 FIELD-ZA.
04 ITEM-3A PICTURE XXX.
04 ITEM-4A PICTURE XXX.
02 GROUP-B REDEFINES GROOP-A.
03 FIELD-lB.
04 ITEM-1B PICTURE XX.
04 ITEM-2B PICTURE XXX.
04 ITEM-3B PICTURE XX.
03 FIELD-2B.
04 ITEM-4B PICTURE XX.
04 ITEM-5B PICTURE XX.
04 ITEM-6B PICTURE XX.
NEW-ERR-REC RENAMES ITEM-3A THRU ITEM-2B.

Although ITEM-3A precedes ITEM-2B in the record description, ITEM-2B
logically precedes ITEM-3A in storage. Thus, this example is incorrect.
Data Description Entry -- Details of Clauses

145

RENAMES Clause
The following shows the corrected Working-Storage record:
01

66

CORRECTED-RECORD.
02 GROUP-A.
03 FIELD-1A.
04 ITEM-1A PICTURE XX.
04 ITEM-2A PICTURE xxx~
04 ITEM-3A PICTURE XX.
03 FIELD-2A.
04 ITEM-4A PICTURE XX.
04 ITEM-SA PICTURE XX.
04 ITEM-6A PICTURE XX.
02 GROUP-B REDEFINES GROUP-A.
03 FIELD-lB.
04 ITEM-1B PICTURE XXXX.
04 ITEM-2B PICTURE XXX.
03 FIELD-2B.
04 ITEM-3B PICTURE XXX.
04 ITEM-4B PICTURE XXX.,
NEW-REC RENAMES ITEM-2A THRU ITEM-3B.

In this example ITEM-2A precedes ITEM-3B both in the record
description and logically in storage.
The following example shows how the RENAMES clause might be used in
an actual program:
01

66
66
66

OUT-REC.
02 FIELD-X.
03 SUMMARY-GROUPX.
04 FILE-l PICTURE X.
04 FILE-2 PICTURE X.
04 FILE-3 PICTURE X.
02 FIELD-Y.
03 SUMMARY-GROUPY.
04 FILE-l PICTURE X
04 FILE-2 PICTURE X.
04 FILE-3 PICTURE X.
02 FIELD-Z.
03 SUMMARY-GROUPZ.
04 FILE-l PICTURE X.
04 FILE-2 PICTURE X.
04 FILE-3 PICTURE X.
SUM-X RENAMES FIELD-X.
SUM-XY RENAMES FIELD-X THRU FIELD-Y.
SUM-XYZ RENAMES FIELD-X THRU FIELD-Z.

In the Procedure Division, the programmer may wish, for example, to
do a complete tally of files in each field of the foregoing record. If
all active files are represented by an A and all inactive files are
represented by an I, the statement
EXAMINE SUM-XYZ TALLYING ALL "A"
would accomplish this purpose. The two additional RENAMES entries
(SUM-X and SUM-XY) allow a less inclusive tally, if desired.
(The
EXAMINE statement is discussed in "Procedure Division.")

146

Part III -- Data Division

PART IV -- PROCEDURE DIVISION

• ORGANIZATION OF THE PROCEDURE DIVISION

• ARITHMETIC EXPRESSIONS

• CONDITIONS

• CONDITIONAL STATEMENTS

• DECLARATIVES

• ARITHMETIC STATEMENTS

• PROCEDURE BRANCHING STATEMENTS

• DATA-MANIPULATION STATEMENTS

• INPUT/OUTPUT STATEMENTS

• COMPILER-DIRECTING STATEMENTS

147

Procedure Division -- Description
ORGANIZATION OF THE PROCEDURE DIVISION

The Procedure Division contains the specific instructions for solving
a data processing problem. COBOL instructions are written in statements, which may be combined to form sentences. Groups of sentences may
form paragraphs, and paragraphs may be combined to form sections.
The Procedure Division must begin with the header PROCEDURE DIVISION

The Procedure Division header is followed, optionally, by Declarative
Sections, which are in turn followed by procedures, each made up of
statements, sentences, paragraphs, and/or sections, in a syntactically
valid format. The end of the Procedure Division (and the physical end
of the program) is that physical position in a COBOL source program
after which no further procedures appear.
The statement is the basic unit of the Procedure Division. A
statement is a syntactically valid combination of words and symbols
beginning with a COBOL verb. There are three types of statements:
conditional statements containing conditional expressions (that is,
tests for a given condition), imperative statements consisting of an
imperative verb and its operands, and compiler-directing statements
consisting of a compiler-directing verb and its operands.
A sentence is composed of one or
optionally be separated by semicolons
be terminated by a period followed by a space.

he statements may
A sentence must

Several sentences that convey one idea or procedure may be grouped to
form a paragraph. A paragraph must begin with a paragraph-name followed
by a period. A paragraph may be composed of one or more successive
sentences. A paragraph ends immediately before the next paragraph-name
or section-name, at the end of the Procedure Division, or, in the
Declarative portion, at the key words END DECLARATIVES.
One or more paragraphs form a section. A section must begin with a
section header (section-name followed by the word SECTION, followed by a
period; if program segmentation is desired, a space and a priority
number followed by a period may be inserted after the word SECTION).
The general term procedure-name may refer to both paragraph-names and
section-names.
The Procedure Division may contain both declaratives and procedures.
Declarative sections must be grouped at the beginning of the
Procedure Division, preceded by the key word DECLARATIVES followed by a
period and a space. Declarative sections are concluded by the key words
END DECLARATIVES followed by a period and a space.
(For
more complete
discussion of declarative sections, see "Declaratives.")

a

A procedure is composed of a paragraph or group of successive
paragraphs, or a section or group of successive sections within the
Procedure Division. paragraphs need not be grouped into sections.
If sections are used within the Procedure Division, a section header
should immediately follow the Procedure Division header, except when a
declarative section is included, in which case the section header should
immediatel follow END DECLARATIVES.

Organization of the Procedure Division

149

Procedure Division -- Structure

A section ends immediately before the next section-name or at the end
of the Procedure Division, or, in the Declarative portion of the
Procedure Division, immediately before the next section-name or at the
words END DECLARATIVES, where END must appear in Area A.
If program segmentation is used, the programmer must divide the
entire Procedure Division into named sections. Program segmentation is
discussed in "Segmentation."
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 in this
chapter indicate some other order.
Structure of-the Procedure Division
PROCEDURE DIVISION
[[OECLARATIVES.
{section-name SECTION.
{paragraph-name.

USE Sentence.

{sentence} ••• } ••• } •.•

END DECLARATIVES.]
{section-name SECTION [priority].]
{paragraph-name.

{sentence} ••• } ••• } •••

CATEGORIES OF STATEMENTS
There are three categories of statements used in COBOL: conditional
statements, imperative statements, and compiler-directing statements.
A conditional statement is a statement containing a condition that is
tested (see "Conditions") to determine which of the alternate paths of
program flow is to be taken.
An imperative statement specifies that an unconditional action is to
be taken by an object program. An imperative statement may also consist
of a series of imperative statements.
A compiler-directing statement directs the compiler to take certain
actions at compile time.

150

Part IV -- Procedure Division

Statement Categories
CONDITIONAL STATEMENTS

..

COBOL statements used as conditional statements are:
IF

ADD
COMPUTE
SUBTRACT
MULTIPLY
DIVIDE
GO TO
READ
SEARCH
RETURN
WRITE

!

READ

}

....

}

(ON SIZE ERROR)
(DEPEt~Dlr{G

ON)

(AT END)
(AT END-OF-PAGE)
(INvALID KEY)

WRITE

IIII.'!I.
PERFORM
SEARCH

(UNTIL)
(WHEN)

,a."

_ _ 7 ,• •

The options in parentheses cause otherwise imperative statements to
be treated as conditionals at execution time. A discussion of these
options is included as part of the description of the associated
imperative statement.

IMPERATIVE STATEMENTS
COBOL verbs used in imperative statements can be grouped into the
following categories and subcategories:
A.

DECLARATIVES
USE

B.

PROCEDURAL
1. Arithmetic
ADD
COMPUTE
DIVIDE
MULTIPLY
SUBTRACT
2. Procedure Branching:
GO TO
ALTER
PERFORM
STOP
EXIT
3. Data-ManiEulation
MOVE
EXAMINE

Organization of the Procedure Division

151

Statement categories
4.

ACCEPT
DISPLAY
CLOSE
5. Report Writer
GENERATE
INITIATE
TERMINATE
6. Table Handling
SEARCH
SET
7. Sort
SORT
RETURN
RELEASE

Note:
Report Writer, Table Handling, and Sort statements
are-discussed in separate chapters.

COMPILER-DIRECTING STATEMENTS
COBOL verbs used in compiler-directing statements are:
COPY
ENTER
NOTE
The COpy statement is discussed in "Source Program Library

152

Part IV -- Procedure Division

Arithmetic Operators
ARITHMETIC EXPRESSIONS

Arithmetic expressions are used as operands of certain conditional
and arithmetic statements...
\

An arithmetic expressi6n may consist of any of the following:

1.

an identifier described as a numeric elementary item

2.

a numeric literal

3.

identifiers and literals, as defined in items 1 and 2, separated ny
arithmetic operators

4.

two arithmetic expressions, as defined, in items 1, 2, and/or 3,
separated by an arithmetic operator

5.

an arithmetic expression, as defined in items 1, 2, 3, and/or 4,
enclosed in parentheses
Any arithmetic expression may be preceded by

11111111••• a

unary -

ARITHMETIC OPERATORS
There are five arithmetic operators that may be used in arithmetic
expressions.
Each is represented by a specific character or character
combination that must be preceded by a space and followed by
except that a unary operator must not be
ceded
follows a left
renthesis.
Arithmetic Ooerator
+

*
**

/

Meaning
addition
subtraction
multiplication
division
exponentiation

Parentheses may be used in arithmetic expressions to specify the
order in which elements are to be evaluated.
Expressions within parentheses are evaluated first.
When expressions
are contained within a nest of parentheses, evaluation proceeds from the
least inclusive to the most inclusive set.
When parentheses are not used, or parenthesized expressions are at
the same level of inclusiveness, the following hierarchical order is
implied:
1.

unary -

3.

**
* and

4.

+ and -

2.

/

When the order of consecutive operations on the same hierarchical
level is not completely specified by parentheses, the order ~f operation
is from left to right.
Arithmetic Expressions

153

Arithmetic Symbol Pairs
Figure 20 shows permissible symbol pairs. A symbol pair in an
arithmetic expression is the occurrence of two symbols that appear
sequence.

i~

----------------T------------T------------T-----------T-------T-------,
Second I
i i i
i
i

I
I
I
I First
I Symbol

Symbol I

I
I Variable
I
I (identifier I
I or literal) I

* / **

+ -

I
I
I
I

unary -

I
I
I
I

(

I
I
I
I

)

I
I
I
I

[~~~:~~~;~;~~~~~~l~~~~:~~~~~~~l~~~~~~~~~~~~~~~:~~~l~~~~~~~l

* / ** + I
p
I
I
pip
I
I
~----------------+------------+------------+-----------+-------+-------~

I

I
I

I

I

I

I

I

I

unary I
p
I
I
I
p
I
I
~----------------+------------+------------+-----------+-------+-------~
I
(
I
p
I
I·p
I
p
I
I

r------)---------t----=-------t-----~------~-~---=---t---~---1

~----------------L-----~-----L------------~-------L--- ____ ~

I p indicates a permissible pairing
I
IL ______________________________________________________________________
- indicates that the pairing is not permitted
JI
Figure 20.

Permissible Symbol Pairs -- Arithmetic Expressions

An arithmetic expression may begin only with a left parenthesis, a
-, or a variable, and may end only with a right
parenthesis or a variable.

""'111"1 unary

There must be a one-to-one correspondence between left and right
parentheses of an arithmetic expression.

154

Part IV -- Procedure Division

Test Conditions
CONDITIONS

A condition causes the object program to select between alternate
paths of control depending on the truth value of a test. Conditions are
used in IF, PERFORM, and SEARCH statements.
A condition is one of the following:
• class condition
• condition-name condition
• relation condition
• sign condition
• switch-status condition

In addition, there are two constructions that affect the evaluation
of conditions. These are:
1.

(condition)
Parentheses may be used to group conditions (see "Compound
Conditions").

2.

NOT condition
The construction -- NOT condition -- (where condition is one of
the five conditions listed above) is not permitted if the condition
itself contains a NOT.

Conditions may be combined through the use of logical operators to
form compound conditions (for a full discussion, see "Compound
Conditions").

TEST CONDITIONS
A test condition is an expression that, taken as a whole, may be
either true or false, depending on the circumstances existing when the
expression is evaluated.
There are five types of simple conditions which, when preceded by the
word IF, constitute one of the five types of tests: class test,
condition-name test, relation test, sign test, and switch-status test.
The construction -- NOT condition -- may be used in any simple test
condition to make the relation specify the opposite of what it would
express without the word NOT. For example, NOT (AGE GREATER THAN 21) is
the opposite of AGE GREATER THAN 21.
Each of the previously mentioned tests, when used within the IF
statement, constitutes a conditional statement (see ·Conditional
Statements").
Conditions

155

Class Condition
Class Condition
The class test determines whether data is alphabetic or numeric.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------~

I
I
I
{NUMERIC
}
I
identifier IS [NOT]
I
ALPHABETIC
I
IL______________________________________________________________________ JI
The operand being tested must be described implicitly or explicitly
as USAGE DISPLAY ~~~.U~8:.
A numeric data item consists of the digits
without an operational sign.

a

through 9, with or

The identifier being tested is determined to be numeric only if the
contents consist of any combination of the digits a through 9. If the
PICTURE of the identifier being tested does not contain an operational
sign, the identifier being tested is determined to be numeric only if
the contents are numeric and an operational sign is not present. If its
PICTURE does contain an operational sign, the identifier being tested is
determined to be numeric only if the contents are numeric and a valid
operational sign is present. Valid operational signs are hexadecimal F,
C, and D.
Program Product Information -- Version 3

The NUMERIC test cannot be used with an identifier described as
alphabetic.
An alphabetic data item consists of the space character and the
characters A through Z.
The identifier being tested is determined to be alphabetic only if
the contents consist of any combination of the alphabetic characters A
through Z and the space.
The ALPHABETIC test cannot be used with an identifier described as
numeric.
Figure 21 shows valid forms of the class test.
r-----------------------T--------------~-------------------------------,

I Type of Identifier

I

Valid Forms of the Class Test

I

~-----------------------+-------------------T--------------------------1

I Alphabetic

I ALPHABETIC

I NOT ALPHABETIC

I

~-----------------------+-------------------+--------------------------~

I Alphanumeric,
I Alphanumeric Edited,
I or Numeric Edited

I ALPHABETIC
I NUMERIC
I

I NOT ALPHABETIC
I NOT NUMERIC
I

I
I
I

~-----------------------+-------------------+--------------------------1

I

"_~?:!=~,es.n~J.,::peC;-imCil

.

!_J!!Ii1jd~
L1.~
_______________________

..

Figure 21.

156

I
I
I
I ___________________
NUMERIC
I __________________________
NOT NUMERIC
JI

~

Valid Forms of the Class Test

Part IV -- Procedure Division

~

Condition-name Condition
Condition-Name Condition
The condition-name condition causes a conditional variable to be
tested to determine whether or not its value is equal to one of the
values associated with condition-name.

r----------------------------------------------------------------------,
Format
I

I

t-----------------===--------------------------------------------------~

I
I
I
condition-name
I
IL______________________________________________________________________ JI

An example of the use of the condition-name condition follows:
02

MARITAL-STATUS PICTURE 9.
88 SINGLE VALUE 1.
88 . MARRIED VALUE 2.
88 DIVORCED VALUE 3.

MARITAL-STATUS is the conditional variable; SINGLE i MARRIED: and
DIVORCED are condition-names. Only one of the conditions specified by
condition-name can be present for individual records in the file. To
determine the marital status of the individual whose record is being
processed, IF SINGLE ••• can be coded, and its evaluation as true or
false determines the subsequent path the object program takes.
A condition-name is used in conditions as an abbreviation for the
relation condition, since the associated condition-name is equal to only
one of the values (or ranges of values) assigned to that conditional
variable. That is, to determine whether the condition SINGLE is
present, IF MARITAL-STATUS = 1 ••• would have the same effect as using
the condition-name test IF SINGLE •••
If the condition~name is associated with a range of values (or with
several ranges of values), the conditional variable is tested to
determine whether or not its value falls within the range(s), including
the end values. The result of the test is true if one of the values
corresponding to the condition-name equals the value of its associated
conditional variable.
(An example of both group and elementary condition-name entries is
given in the description of the VALUE clause in ftData Division ft .)

Conditions

157

Relation Condition
Relation Condition
A relation conjition causes a comparison of two operands, either of
which may be an identifier, a literal, or an arithmetic expression.

r----------------------------------------------------------------------,
,
Format
I
~----------------------------------------------------------------------1

I

I

I

I

,

{identifier-l
}
literal-l
arithmetic-expression-l

relational-operator

I
I
I
I

I
I
I

'{identifier-2}
I
literal-2
I
arithmetic-expression-2

I

IL______________________________________________________________________ J,

The first operand is called the sUbject of the condition; the second
operand is called the object of the condition.
The subject and object may not both be literals.
The subject and object must have the same USAGE, except when two
numeric operands are compared.
A relational-operator specifies the type of comparison to be made in
a relation condition. The meaning of the relational operators is shown
in Figure 22.

r-----------------------T----------------------------------------------,
,Relational-operator
I
Meaning
I
~-----------------------+----------------------------------------------~

I '
lIS [~] GREATER THAN IGreater than or not greater than
lIS [NOT] >
I

I

I
I

~-----------------------+----------------------------------------------~

lIS [NOT]
lIS [NOT]

LESS THAN

<

ILess than or not less than
I

I

I

~----------~------------t----------------------------------------------~

lIS [NOT] EQUAL TO
IEqual to or not equal to
I
IL _______________________
IS [NOT] =
~ ______________________________________________ JI
~

Figure 22.

Relational-operators and Their Meanings

The word TO in the EQUAL TO relational operator is
~~~.~m.i'.

~;~~~f*:~"

The relational-operator must be preceded by, and fol-lowed by, a
space.

158

Part IV -- Procedure Division

Relation Condition
COMPARISON OF NUMERIC OPERANDS: For operands whose class is numeric, a
comparison is made with respect to the algebraic value of the op~rands.
Zero is considered a unique value, regardless of sign.
Comparison of numeric operands is permitted regardless of the manner
in which their USAGE is described.
Unsigned numeric operanjs are considered positive for purposes of
comparison.

COMPARISON OF NO~NUMERIC OPERANDS: E'or notIIiurnefic operands, or for one
numeric and one nonnumeric operand, a comparison is made with respect to
the binary collating sequence of the characters in the EBCDIC set.
The EBCDIC collating sequence, in ascending

order~

is:

1.
2..
3. <
4. (
5. +
6 •• '*~
7
8.)

(space)
(period or decimal point)
("less thann symbol)
(left parenthesis)
(plus sign)
(currency symbol)
(asterisk)
(right parenthesis)
9.
(semicolon)
10. (hyphen or minus symbol)
11. I
(stroke, virgule, slash)
12.
(comma)
13. > (ngreater than" symbol)
1"._
• •Uj.lI[,!~~15. = (equal sign)
16. n (quotation mark)
17-42. A thru Z
43-52. 0 thru 9
(The complete EBCDIC collating sequence is given in the publication
IBM System/360 Reference Data, Order No. X20-1703.)
If one of the operands is described as numeric, it is treated as
though it were moved to an alphanumeric data item of the same size and
the contents of this alphanumeric data item were then compared to the
nonnumeric operand (see "MOVE Statement n ).

The size of an operand is the total number of characters in the
operand.
All group items are treated as nonnumeric operands.
Numeric and nonnumeric operands may be compared only when their USAGE
is the same, implicitly or explicitly.

There are two cases of nonnumeric comparison to consider:
of equal size and operands of unequal size.

operands

Conditions

159

Relation Condition
1.

Comparison of Operands of Equal Size
Characters in corresponding character positions of the two operands
are compared from the high-order end through the low-order end.
The high-order end is the leftmost position; the low-order end is
the rightmost character position.
If all pairs of characters compare equally through the last pair,
the operands are considered equal when the low-order end is
reached.
If a pair of unequal characters is encountered, the two characters
are compared to determine their relative position in the collating
sequence. The operand that contains the character higher in the
collating sequence is considered to be the greater operand.

2.

comparison of Operands of Unequal Size
If the operands are of unequal size, comparison proceeds as though
the shorter operand were extended on the right by a sufficient
number of spaces to make the operands of equal size.

COMPARISONS INVOLVING INDEX-N~MES AND/OR INDEX DATA ITEMS: The
compar~son of two index-names is equivalent to the comparison of their
corresponding occurrence numbers.
In the comparison of an index data item with an index-name or with
another index data item, the actual values are compared without
conversion.
The comparison of an index-name with a numeric item is permitted if
the numeric item is an integer. The numeric integer is treated as an
occurrence number. All other comparisons involving an index-name or
index data item are not allowed.
(For a discussion of indexing, see
"Table Handling.")
Permissible comparisons are shown in Figure 23.

160

Part IV -- Procedure Division

Relation Condition

-------------------------------T--T--T--T---T--T---T---T---T---T:~'_:;0,T7.fi,

--

---;'T---T---'

Second Operand I GR I AL I AN I ANE I NE I FC* I ZR I ED I BI 1:i!D:~" ,;,;'
1IN I IDI 1
,First Operand
I
\
\
1
\ \ NNL I NL I
1
I~,'j:;,~ ,::i::~
I
I
1
~-------------------------------+--+--+---+--+---+---+---+~~-dr+~i11f ':';'! '
'Group (GR)
INNINNINNINN INNINN INN INN h,.;!'Lll~;:;l~~
'I
I
I
~-------------------------------+--+--+--+---+--+---+---+---T~j~~:f;-:'" ,HH-l~
I Alphabetic (AL)
I NN I NN 1NN I NN I NN I NN INN INN,
F:,lINt~f, ,
)!~~:'
I
I
~-------------------------------+--+--+--+---+--+---+---+---+---+7n+""4~-i ,;-·a:~~+---+---1
I Alphanumeric (AN)
,NN I NN\ NNI NN I NNI NN INN I NN I
Ic:"',IN~l]ll,N~INNI
I
1

I

;

I,

---+---1
,,' : ---+---4

t-------------------------------+--+--+--+---+--+---+---+---+---+-:,-,--4~~+7-iT~-:-if~:-+---+---4

'Alphanumeric Edited (ANE)
'NNI NNI NNI NN I NNI NN INN INN 1
I', ,dNNll':fl:NNlt~~J
I
I
~-------------------------------+--+--+--+---+--+---+---+---+---+'7~ +--'f7+-:~+-~+---+---4
I Numeric Edited (NE)
! NN! NN I NN INN 1NNI NN INN INN 1
I, .JNNr(~tirNNI
I
1

..

t-------------------------------+--+--+--+---+--+---+---+---+---t,-~7+~~f~'~+~'7f~'7t---+---i
'Figurative Constant (FC) * &
I NNI NNI NNI NN \ NNI
I
I NN I
I'
HiNJ', INNlNN.;I
,
I

I Nonnumeric

Literal (NNL)
I
1 I ,
1 lit
1
1:,.,',"'.I,l,l"J',,1
I
I
t-------------------------------+--+--+--+---+--+---+---+---+---+.;,.-:~-+~~+'"':_:+':":~+~-+---+---4
I Fig. Constant ZERO (ZR) &
,NN I NN INN 1NN I NN\
1
1NU 1NU \'NP,"INUlNUJlt-l~Jl:m] 1:)1\
1
I Numeric Literal (NL)
1 1 I I
I
1
I
1
I
t~":',t,',',l... <,,'l,· . ,r>:,,'J
I
I
~-------------------------------+--+--+--+---+--+---+---+---+---+~~:_+-,7+~~f,:_~+~'~+---+---4
Decimal (ED)
\ NN I NNI NN INN 1NN\ NN I NU I NU 1NU I,Ntj''.''lNIJl~,UrN,N'I'N~:I 1:)11
I

I External

~-------------------------------t'"':::+--+--+---+--+---+---+---+---+.:..~..,:+:-:_+'"'::-+~~++,-1t---+---1
I
I
I
1
I NU I NU 1NU LNQ',lNU1Nvl:::'lNQ;'1 10 1 1
1
';~'7J~~.,.t7'~+2:.:.f:..~f~~---;t---4
',,',,11NtJ,>lNyl'N~t,~'J:No;l
.I
I

I Binary (BI)
t~'1
hiJk"""7:-------------------------...,,-- ;~~ It,,;,;:
'I,

I,

.

.

1m
"
.' .' """.~,,,. :ot~~ ."",~'~t""
", ',' "'
~,4\';'l,:;J'i'~

.'

, ' ' : ' : '....

~+~,':7+----+"7*,..t'7--4 -"""T---~

~,~lt!~~t~~,I~~f~,~l~~I---I---1

, ,/~,t" •., , : , : h f f "., t ' +, +, t,.+
+ 4
~4Jl;:}.
,~;;f;,~~~~WJ~9l:J~~,f~1i~?rrJ":l~~Jt;t,;n'i.'lJi;,Ji~;;;lt;},;,l[:\!':I!, :,:,:(, ,'.',,' }lXl~tJ']~UlNUI:... iN~:1
I
I
~~/-.;-:1~~~.,..,.-.T'~'~-:'--,"1-:'?'"i~1-:'..,'~~~~:;~~it-Htt·· ., . ~ . ;-fi-:1:-4~1i-~4i..,.-,.1ik...... ~+..,.-.,.f--+.--+-"""+~-+---+---1
1;$,t¢HJ.ti;I19f~~r;¥>r:t,'~:~~)!::.,ri'3"J,\IJ,J"J ,il!NN,Jltfflf~Ntfl~'y~t~~J,tJN~',{IJ,~~:t~r',' . ":·;\l;",:.,,I N.Nl'.:':'I~~l,N,~.1
I
I
~~---:-f~-i-,~'7-.;;.~.~~,;,.~_i-:-_:A~~ ,·:-:....;~~-f·~·d'~... ~'~~r~'if~--:,;...~-hf,f:-l~--~Af~,;...·~-f-"'7--+~~-+~~+,~,~t-,-+. . -:t---+---4
IH~1;er1f:ij,~~':N~nre~6~t,. 'SS~); ':' ,[ .L:l~ ';'<~,~~,::N~'LNN:l;~",~'~,l.'~~ 'iFNU,a N:{J '; ',}fU;,; tNU'! NtJl~'ulNN,! N{J,I
I
i
~....'--""";...'""'=""'-"""==.;.;;.,.;;.'....'===~""''-'.;..'...'="-''=....~'='..o;.~=--'+'=~,t='"--+-'·:'o;,.·t'.;,.;'. . --'f--,"-'+'-''"'",--f,;.;..,-,-f·--;.;..~;f·--,;.;..~+:~:..;,'--. +-'. . '+·--'-'+--';';"+'-'-+---+---~
I Index Name (IN)
I
I
I I
I
I
1101 1101 1101 I IOirij 1 1 I 110 1IV 1
<"fJ'f

,,"':'" ",';

>.

t-------------------------------+--+--+--+---+--+---+---+---+---+~~'~·+--+--+--+--+---+---4

IIndex Data Item (101)
1 I I 1
I
I
I
I
I
1
I
1 I I IIV IIV 1
~-------------------------------~--~--~--~---~--~---~---~---~---~---~--~--~--~--~---~---1
I*FC includes all Figurative Constants except ZERO.
I
1 1 Valid only i f the numeric item is an integer.
I

I

1

I
NN = comparison as described for nonnumeric operands
\
I
NU = comparison as described for numeric operands
I
I
10 = comparison as described for two index-names
I
IL_______________________________________________________________________________________
IV = comparison as described for index data items
JI
Figure 23.

Permissible Comparisons

Conditions

161

Sign/Switch-status Conditions
Sign Condition
The sign condition determines whether or not the algebraic value of a
numeric operand (i.e., an item described as numeric) is less than,
greater than, or equal to zero.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------1

I
I
I

I

{identifier

}

IS [NOT]

arithmetic-expression

{POSITIVE}
NEGATIVE
ZERO

I
I
I

IL ______________________________________________________________________ JI

An operand is positive if its value is greater than zero, negative if
its value is less than zero, and zero if its value is equal to zero. An
unsigned field is positive or zero.

Switch-Status Condition
A switch-status condition determines the on or off status of a device
switch.

r----------------------------------------------------------------------,
F~~t
I

I

~----------------------------------------------------------------------~

I
I
I
condition-name
I
IL- _____________________________________________________________________ JI

The SPECIAL-NAMES paragraph of the Environment Division associates an
ON or OFF value (condition-name) with a switch (function-name). The
switch-status condition tests the value associated with the switch. The
result of the test is true if the switch is set to the position
corresponding to condition-name.

COMPOUND CONDITIONS
Two or more simple conditions can be combined to form a compound
condition. Each simple condition is separated from the next by one of
the logical operators AND or OR.
The logical operators must be preceded by a space and followed by a
space. The meaning of the logical operators is as follows:
Logical operator

Meaning
logical inclusive OR, i.e., either or both
are true
logical conjunction, i.e., both are true
logical negation

162

Part IV -- Procedure Division

Compound Conditions
Figure 24 shows the relationships between the logical operators and
simple conditions A and B, where A and B have the following values:

Values for Condition A
True
False
True
False

Values for Condition B
True
True
False
False

r-------T------T-----T-------------T-----------T------------T----------,

IA AND BIA OR BINOT AINOT (A AND B) I NOT A AND BINOT (A OR B) I NOT A OR BI
~-------+------+-----+-------------+-----------+------------+----------~

I True

I True

I FalselFalse

I False

I False

I True

I

~-------+------+-----+-------------+-----------+--------~---+----------~

\False

I True

ITrue Irrue

I True

\ False

I True

I

~-------+------+-----+-------------+-----------+------------+----------~

I False

I True

IFalselTrue

IFalse

IFalse

IFalse

I

~-------+------+-----+-------------+-----------+------------+----------~

IFalse
False
I ____________
True
I __________
True
L_______ IFalse
______ ITrue
_____ ITrue
_____________ I ___________
JI
~

Figure 24.

~

~

~

~

~

Logical Operators and the Resulting Values upon Evaluation

EVALUATION RULES
Logical evaluation begins with the least inclusive pair of
parentheses and proceeds to the most inclusive.
If the order of evaluation is not specified by parentheses, the
expression is evaluated in the following order:
1.

Arithmetic expressions

2.

Relational-operators

3.

[NOT] condition'

4.

AND and its surrounding conditions are evaluated first, starting at
the left of the expression and proceeding to the right.

5.

OR and its surrounding conditions are then evaluated, also
proceeding from left to right.

Consider the expression:
A IS NOT GREATER THAN B OR A + B IS EQUAL TO C AND D IS POSIrIVE

This will be evaluated as if it were parenthesized as follows:
(A IS NOT GREATER THAN B) OR «CA + B) IS EQUAL TO C> AND (D IS
POSITIVE».
Conditions

163

Compound Conditions
The order of evaluation is as follows:
1.

(A + B) is evaluated, giving some intermediate result, for example,

x.
2.

(A IS NOT GREATER THAN B) is evaluated, giving some intermediate
truth value, for example, t1.

3.

(x IS EQUAL TO C) is evaluated, giving some intermediate truth
value, for example, t2.

4.

(D IS POSITIVE) is evaluated, giving some intermediate truth value,
for example, t3.

5.

(t2 AND t3) is evaluated, giving some intermediate truth value, for
example, t4.

6.

(t1 OR t4) is evaluated, giving the final truth value, and the
result of the expression.

Figure 25 shows permissible symbol pairs. A symbol pair in a
compound condition is the occurrence of two symbols appearing in
sequence.

I

-------------------T--------------T-------T-------T-------T-----T-----'

IFirst
1Symbol

Second 1
Symbol I

I

~-------------------

I Condition

Condition

I
I
I

OR

I
I
I

AND

I
I
I

NOT

I
I
I

(

I
I
I

)

I
I
I

--------------+-------+-------+-------+-----+-----1
I
I pip
I
I
I p I

~-------------------+--------------+-------+-------+-------+-----+-----~
1 OR

I

1 AND

I

p

I

p

I

I

I

pip

I

I

I

I

pip

I

I

~-------------------+--------------+-------+-------+-------+-----+-----1

~-------------------+--------------+-------+-------+-------+-----+-----~
I NOT
I
p
I I
I
I p I - I
~-------------------+--------------+-------+-------+-------+-----+-----1
I (
I
p
I
I
I
pip I
I
~-------------------+--------------+-------+-------+-------+-----+-----~

I )

I

I

pip

I

I

I

p

I

~-------------------i--------------i-------i-------i-------i-----i-----1

Ip indicates a permissible pairing

I

1indicates that the pairing is not permitted
l ______________________________________________________________________
JI
Figure 25.

Permissible Symbol Pairs -- compound Conditions

IMPLIED SUBJECTS

~ND

R~L~TION~L-OPERATORS

When relation conditions are written in a consecutive sequence, any
relation condition except the first may be abbreviated by:
1.

The omission of the subject of the relation condition, or

2.

The omission of the subject and relational-operator of the relation
condition.

Within a sequence of relation conditions, both forms of abbreviation may
be used~ The effect of using such abbreviations is as if the omitted
subject was taken from the most recently stated subject, or the omitted
relational-operator was taken from the most recently stated relationaloperator.
164

Part IV -- Procedure Division

Compound Conditions

r-----------------------------------------------------------------------,
IFormat of Implied Subject:

I

~-------------------------~--------------------------------------------~

I

I ••• subject

I

:

j~D}

relational-operator

I

object

I

I

[NOT] relational-operator

I

object...

I
~I
IL ______________________________________________________________________ JI
r---------------------------~------------------------------------------,

IFormat of Implied Subject and Relational-operator:

I

~----------------------------------------------------------------~-----~

I

I

1 . . . sUbject

relational-operator

object

{AND}

[NOT] object...

I

I
OR
I
IL ______________________________________________________________________ JI
Ambiguity may result from using NOT in conjunction with
abbreviations. When only the subject is implied, NOT is interpreted as
a logical operator rather than as part of the relational" operator. For
example, A NOT > BAND < C is equivalent to A NOT > B AND A < C. When
both the subject and the relational operator are implied, NOT is
interpreted as part of the relational operator. For example, A NOr > B
AND C is equivalent to A NOT> B AND A NOT > C.
The following are examples of implied subjects, and relationaloperators. Each example consists of two equivalent statements:
Implied.Subject
(The subject, A, is implied.)
(The subject, A, is explicit.)

A = B OR NOT > C
A ~ B OR NOT A > C

Implied SUbject and Relational Operator
A

B AND

A

B AND A

C
C

A NOT

B AND

C

A NOT

B

AND

A

NOT

C

(Subject and relational-operator, A
are
implied. )
(Subject and relational-operator, A
are
explicit.)
(Subject and relational-operator, A NOr =,
are implied.)
(Subject and relational-operator, A NOr
are explicit.)

Implied Subject, and Subject and Relational-Operator
A > B AND NOT < C AND D
A > B AND NOT A < C
AND A < D

(Subject, A, is implied in the second condition. Subject, A, and relational-operator,
<, are implied in the third condition.)
(Subject, A, and relational-operator, <, are
explicit.)

The omitted subject is taken from the most recently stated subject,
i.e., A.
The omitted relational-operator is taken from the most recently
stated relational-operator, i.e., <.
Conditions

165

IF Statement
CONDITIONAL

STATE~ENTS

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. Conditional statements are listed in
"Categories of Statements."
A conditional sentence is a conditional statement optionally preceded
by an imperative statement, terminated by a period followed by a space.
Only the IF statement is discussed in this section. Discussion of
the other conditional statements is included as part of the description
of the associated imperative statements.

IF Statement
The IF statement causes a condition to be evaluated. The subsequent
action of the object program depends upon whether the condition is true
or false.

r----------------------------------------------------------------------,
I
Format
I
~----------------------------------------------------------------------~

I
I
I
{statement-l } {ELSE
}
{statement-2 } I
I
IF condition
I
I
NEXT SENTENC~
(11111'111 1ft
NEXT SENTENCE I
IL- _____________________________________________________________________ JI

The phrase ELSEllllllillil NEXT SENTENCE may be omitted if and only if
it immediately precedes the period for the sentence.
When an IF statement is executed, the following action is taken:
1.

If the condition is true, the statement immediately following the
condition or THEN (statement-l) is executed.
(If ELSE
is
omitted, then all imperative statements following the condition and
preceding the period for the sentence are considered to be part of
statement-l.) Control is then passed implicitly to the next
sentence unless GO TO procedure-name is specified in statement-l.
If the condition is true and NEXT SENTENCE is written, control
passes explicitly to the next sentence.

2.

If the condition is false, either the statement following ELSE
_ _ (statement-2) is executed, or, if the E.LSE 1.<• • • •111
option is omitted, the next sentence is executed. If the condition
is false and NEXT SENTENCE is written following ELSE, control
passes explicitly to the next sentence.

When IF statements are not nested, statement-l and statement-2 must
represent imperative statements.
166

Part IV -- Procedure Division

IF Statement
Nested IF Statements
The presence of one or more IF statements ~ithin the initial IF
statement constitutes a "nested IF statement."

Statement-l and statement-2 in IF statements may consist of one or
more imperative statements and/or a conditional statement.
If a
conditional statement appears as statement-lor as part of statement-l,
it is said to be nested. Nesting statements is much like specifying
subordinate arithmetic expressions enclosed in parentheses and combined
in larger arithmetic expressions.

IF statements contained ~ithin IF statements must be considered as
paired IF and ELSE combinations, proceeding from left to right.
Thus,
any ELSE encountered must be considered to apply to the immediately
preceding IF that has not already been paired with an ELSE.

In the conditional statement in Figure 26, C stands for condition; S
stands for any number of imperative statements; and the pairing of IF
and ELSE is shown by the lines connecting them.

Figure 27 is a flowchart indicating the logical
conditional statement in Figure 26.

,~

Fl

Cl

Sl
I

I

IF2

t

C2

IF3

r

C3

S2
c1

t
ELSE

~

ELSE

S3
c2

t

'f

S4

I

IF4

C4

IF5

flo~

C5

l

of the

S5
el

t
ELSE

,Ir

S6
e2

dl
\.

~

\,.

~

b2

bl

~

al

at - Statement-l for IFI (IfCl is false, the next sentence is executed, since there is no ELSE for it.)

bl b2 cl c2 dl el e2 -

Figure 26.

Statement-l for IF2
Statement-2 for IF2
Statement-l for IF3
Statement-2 for IF3
Statementol for IF4 (IfC4 is false, the next sentence is executed, since there is no ELSE for it.)
Statement-l for IF5
S~tement-2 for IFS

Conditional statements with Nested IF Statements
Conditional statements

167

IF Statement

* * **A1 *** * ... ** ... *
* EXECUTION OF *
.. IF STATEME~T *
*
BEGINS
*
***************

I

~

B1 · *. * .

. *. *
*.
*.

*.

C1

*.. *

* . *.

.*

.*

FALSE
• *---------------------------------------------------------------------------------

('m

** ***C1*** ** ** ***

*

*

*
*
*
*

Sl

. . ·. T·. ·. ·
*

01

*:

*

.*

*.

· *. *.

. *.

*g

C2

*..*
* .. *

1

*****02**********
03
*•
*
*
.*
*. *. FALSE
*. FALSE
*
*
•*
• *-------->*
S4
*-------->*.
C4
• *--------------------------->

*

.*

*

....

*
*
*****************

1

*..*
*.• *

TRUE

TRUE

E1 · *. *.
*:

*.*

*. ...

I

C3

*.• *

*****E2**********

* •*.

• *. *

.*

FALSE

:

• *-------->*

S3

:

*

**
*****************

E3

•*. *

*•

*..

*..

. *.

*.

I

C5

* .. *

*****E4**********
**
FALSE
**
• *-------->*
S6
*

*. *.

•*

•*

*
*
*
*
*****************

TRUE

nUE

***** F1 ** ... ** *****

***** F3* *** ** *** *

*
S2
**
*
*** .. ** **+ ** ** * *** **

**
**
*
S5
*
*
*
*** * ** * ****** * *** **

*

*

I

<---------------------------------------------------------------------------------------

** *** Hi ***** *** **

*

*

** NEXT SENTENCE **

•*

**
** ***:Ie ** ** ** *****

Figure 27.

168

Logical Flow of Conditional statement with Nested IF
Statements

Part IV -- Procedure Division

Declaratives -- General Format
DECLARATIVES

The Declaratives section provides a method of including procedures
that are invoked nonsynchronously:
that is, they are executed not as
part of the sequential coding written by the programmer, but rather when
a condition occurs which cannot normally be tested by the programmer.
Although the system automatically handles checking and creation of
standard labels and executes error recovery routines in the case of
input/output errors, additional procedures may be specified by the COBOL
programmer.
The Report Writer feature also uses declarative procedures.
since these procedures are executed only when labels of a file are to
be processed, or at the time an error in reading or writing occurs or
when a report group is to be produced, they cannot. appear in the regular
sequence of procedural statements.
They must be written at the
beginning of the Procedure Division in a subdivision called
DECLARATIVES. A group of declarative procedures constitutes a
declarative section. Related procedures are preceded by a USE sentence
that specifies their function.
A declarative section ends with the
occurrence of another section-name with a USE sentence or with the words
END DECLARATIVES.
The key words DECLARATIVES and END DECLARATIVES must each begin in
Area A.
No other text may appear on the same line.

r----------------------------------------------------------------------,
General Format
I

I

~----------------------------------.------------------------------------~

I
I
I
DECLARATIVES.
I
I
{section-name SECTION. USE sentence.
I
}
{paragraph-name.
{sentence} •••
} •••
I
I
END DECLARATIVES.
I
______________________________________________________________________ JI
PROCEDURE DIVISION.

...

The USE sentence identifies the type of declarative.
There are three formats of the USE sentence.
one of the following types of procedures:
1.

Input/output label handling

2.

Input/output error-checking procedures

3.

Report writing procedures

Each is associated with

A USE sentence, when present, must immediately follow a section
header in the Declarative portion of the Procedure Division and must be
~ollowed by a period followed by a space.
The remainder of the section
must consist of one or more procedural paragraphs that define the
procedures to be used.
The USE sentence itself is never executed, rather it defines the
conditions for the execution of the USE procedure.
Declaratives

169

LABEL Declarative
Format 1 is used to provide user label-handling procedures.
are two options of Format 1.

There

r----------------------------------------------------------------------,

I

Format 1
I
~----------------------------------------------------------------------~
option 1
USE

{BEFORE}
AFTER

STANDARD [BEGINNING]

LABEL PROCEDURE ON

{file-name} •••
OUTPUT
{ INPUT

1

1-0

~----------------------------------------------------------------------~

Option 2
USE

BEFORE}
{ AFTER

STANDARD [ENDING]

LABEL PROCEDURE ON

REEL]
FILE
[ UNIT

{file-name} ••• ~
OUTPUT
{ INPUT

1-0
L_____________________________________________________________________ _

When BEFORE is specified, it indicates that nonstandard labels are to
be processed.
Nonstandard labels may be specified only for tape files.
When AFTER is specified, it indicates that user labels follow
standard file labels, and are to be processed.
Note: ASCII considerations for user label-handling procedures are given
in Appendix E.
The labels must be listed as data-names in the LABEL REcoaDS clause
in the File Description entry for the file, and must be described as
level-01 data items subordinate to the file entry.
If neither BEGINNING nor ENDING is specified, the designated
procedures are-executed for both beginning and ending labels.
If UNIT, REEL, or FILE are not included, the designated procedures
are executed both for REEL or UNIT, whichever is appropriate, and for
FILE labels. The REEL option is not applicable to mass storage files.
The UNIT option is not applicable to files in the random access mode
since only FILE labels are processed in this mode.
If FILE is specified, the designated procedures are executed at
beginning-of-file (on first volume) and/or at end-of-file (on last
volume) only. If REEL or UNIT is specified, the designated procedures
are executed at beginning-of-volume (on each volume but the first)
and/or at end-of-volume (on each volume but the last.)
Both BEGINNING
and ENDING label processing is executed if BEGINNING or ENDING has not
been specified.
170

Part IV -- Procedure Division

LABEL Declarative
The same file-name may appear in different specific arrangements of
Format 1. However, appearance of a file-name in a USE statement must
not cause the simultaneous request for execution of more than one USE
declarative.
If the file-name option is used, the File Description entry for
file-name must not specify a LABEL RECORDS ARE OMITT£D clause.
The user label procedures are executed as follows when the OUTPUT,
or 1-0 options are specified:

I~PUT,

• When OUTPUT is specified, only for files opened as output.
• When INPUT is specified, only for files opened as input.
• When 1-0 is specified, only for files opened as 1-0.
The file-name must not represent a sort-file.
If the INPUT, OUTPUT, or 1-0 option is specified, and an input,
output, or input-output file, respectively, is described with a LABEL
RECORDS ARE OMITTED clause, the USE procedures do not apply.
The standard system procedures are performed:
1.

Before or after the user's beginning or ending input label check
procedure is executed.

2.

Before the user's beginning or ending output label is created.

3.

After the user's beginning or ending output label is created, but
before it is written on tape.

4.

Before or after the user's beginning or ending input-output label
check procedure is executed.

Within the procedures of a USE declarative in which the USE sentence
specifies an option other than file-name, references to common label
items need not be qualifie1 by a file-name.
A common label item is an
elementary data item that appears in every label recorj of the program,
but does not appear in any data record of this program. such items must
have identical descriptions and positions within each label record.
within a Format 1 declarative section there must be no reference to
any nondeclarative procedures.
conversely, in the nondeclarative
portion there must be no reference to procedure-names that appear in the
declaratives section, except that PERFORM statements may refer to a USE
procedure, or to procedures associated with it.
The exit from a Format 1 declarative section is inserted by the
compiler following the last statement in the section. All logical
program paths within the section must lead to the exit point.

Declaratives

171

LABEL Declarative -- Sample Program
there i~ -another user label to check. Hence, there, n~ed not bea
program ,path that flows ,through the last statement in :the :!isection~
For nonstandard labelE1"the compiler does not kno~'hio~,ma
1 cU!>e Is
ex~s~~" ~her€!f,o:r::~,!,th~ :,~~s:t~tt,ctt,~~e.qtr ;i,p ,the ,se9~iQ.rt l'us~'
'
h

~~"iecu~£Td ,:totez.:m1.~ate 111~qgtartda.1q ;~~'q~~ ,pr,ocess~ng.,

:'

;""

" , "'"

': j l '; ,;

t

':'

;",

'

J' I

!

,!';t f"

r;l"l,Y~J:4'~:~~,c!\Mv !~ti:art;~9mE~n;t.! 1jf~ .

No tape marks are written following nonstandard header labels. A
tape mark is written following the last nonstandard trailer label on
each reel.

SAMPLE LABEL

DE~LARATIVE

PROGR~M

The following program creates two files, one with user labels, the other
with nonstandard labels. To create the labels, the program contains a
DECLAR~TIVES section, with USE procedures for creating both header and
trailer labels.
The program illustrates the following items:
For the two files requiring label creation, the LABEL RECORDS
clause specifies the data-name option.
The user labels are created by a USE
procedure.

~FrER

BEGINNING/ENDING LABEL

The nonstandard labels are created by a USE BEFORE BEGINNING/ENDING
LABEL procedure.
Label information for the program is taken in part from the input
file; therefore input records containing the information must be
read and stored before the output files are opened, and the header
label procedures invoked.

172

Part IV -- Procedure Division

LABEL Declarative -- Sample Program
IDENTIFICATION DIVISION.
PROGRAM-ID. LABELPGM.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-360-F50.
OBJECT-COMPUTER. IBM-360-F50.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT NO-LBL ASSIGN TO SYS010-UT-2400-S.
SELECT USER ASSIGN TO SYS011-UT-2400-S.
SELECT NON-STD ASSIGN TO SYS012-UT-2400-S.
DATA DIVISION.
FILE SECTION.
FD NO-LBL
RECORD CONTAINS 80 CHARACTERS
DATA RECORDS ARE IN-REC IN-LBL-dIST
LABEL RECORD IS OMITTED.
01 IN-REC.
05 TYPEN PIC X(4).
88 NSTD VALUE 'NSTD'.
05 DEPT-ID PIC X(11). '
05 BIL-PERIOD PIC X(5).
05 NA¥~ PIC X(20).
05 AMOUNT PIC 9(6).
05 FIL-NAM PIC X(15).
05 SECUR-CODE PIC XX.
05 AREAN PIC 9.
BB HDR-REC VALUE 9.
05 ACCT-NUM PIC 9(10).
05 SER-NUM PIC 9(6).
01 IN-LBL-HIST.
05 FILLER PIC X(4).
05 FILE-HISTORY PIC X(76).
FD USER
RECORD CONTAINS 80 CHARACTERS
BLOCK CONTAINS 5 RECORDS
DATA RECORD IS USR-REC
LABEL RECORDS ARE USR-LBL USR-LBL-HIST.
01 USR-LBL.
05 USR-HDR PIC X(4).
05 DEPT-ID PIC X(11).
05 USR-REC-CNT PIC 9(8) CO~~-3.
05 BIL-PERIOD PIC X(5).
05 FILLER PIC X(53).
05 SECUR-CODE PIC XX.
01 USR-LBL-HIST.
05 FILLER PIC X(4).
05 LBL-HISTORY PIC X(76).
01 USR-REC.
05 TYPEN PIC X(4).
05 FILLER PIC X(5).
05 NAME PIC X(20).
05 FILLER PIC X(4).
05 ACCT-NUM PIC 9(10).
05 AMOUNT PIC 9(6) COMP-3.
05 FILLER PIC X(25).
05 U-SFQ-NU~m PIC 9(8).
FD NON-STD
RECORDING MODE IS U
DATA RECORDS ARE NSTD-REC1 NSTD-REC2
LABEL RECORD IS NSTD-LBL.
01 NSTD-LBL.
05 NSTD-HDR PIC XC?).
05 NSTD-REC-CNT PIC 9(8) COMP-3.
05 FILLER PIC X(3).
05 FIL-NAM PIC X(15).
05 DEPT-ID PIC X(11).
05 SER-NUM PIC 9(6).
Declaratives

173

LABEL Declarative -- Sample Program
OS CREAT-DATE PIC XeS).
NSTD-REC1.
OS ACCT-NUM PIC 9(10).
OS BIL-PERIOD PIC xes).
OS NAME PIC X(20).
OS FILLER PIC X(40).
OS AREAN PIC 9.
OS FILLER PIC X(20).
05 &~OUNT PIC 9(6) COME-3.
01 NSTD-REC2.
OS ACCT-NUM PIC 9(10).
OS BIL-PERIOD PIC xes).
OS NAME PIC X(20).
OS FILLER PIC X(lS).
OS DEPT-ID PIC XCll).
OS AMOUNT PIC 9(6).
OS N-SEQ-NUMB PIC 9(S).
OS AREAN PIC 9.
OS FILLER PIC X(4).
WORKING-STORAGE SECTION.
77 N-REC-NUMB PIC 9(S) VALUE ZERO.
77 U-REC-NUMB PIC 9(S) VALUE ZERO.
77 SAV-FIL-NAM PIC X(lS).
77 SAV-DEPT-ID PIC X(11).
77 LBL-SWITCH PIC 9 V~LUE ZERO.
77 USER-SWITCH PIC 9 VALUE ZERO.
77 NSTD-SWITCH PIC 9 VALUE ZERO.
77 NSTD-REC2-CNT PIC 9(S) VALUE ZERO.
01 STOR-~C.
OS DEPT-ID PIC X(11).
OS BIL-PERIOD PIC xes).
OS SECUR-CODE PIC xx.
PROCEDURE DIVISION.
01

o

DECLARATIVES.
USR-HDR-LBL SECTION. USE AFTER BEGINNING FILE
LABEL PROCEDURE ON USER.
A.
IF LBL-SWITCH = 0
MOVE SPACES TO USR-LBL
MOVE ZEROES TO USR-REC-CNT
MOVE 'UHL1' TO USR-HDR
MOVE CORRESPONDING STOR-REC TO USR-LBL
ADD 1 TO LBL-SWITCH GO TO MORE-LABELS
ELSE MOVE 'UHL2' TO USR-HDR
MOVE FILE-HISTORY TO LBL-HISTORY.
USR-TRLR-LBL SECTION. USE AFTER ENDING FILE
LABEL PROCEDURE ON USER.
B. MOVE SPACES TO USR-LBL.
MOVE 'UTL1' TO USR-HDR.
MOVE SAV-DEPT-ID TO DEPT-ID IN USR-LBL.
MOVE U-REC-NUMB TO USR-REC-CNT,
NSTD-HDR-LBL SECTION. USE BEFORE BEGINNING FILE
LABEL PROCEDURE ON NON-STD.
C. MOVE 'NSTHDR1' TO NSTD-HDR.
MOVE ZEROES TO NSTD-REC-CNT
MOVE CORRESPONDING IN-REC TO NSTD-LBL.
MOVE CURRENT-DATE TO CREAT-DATE.
MOVE FIL-NAM OF IN-RFC TO SAV-~IL-NAM.
NSTD-TRLR-LBL SECTION. USE BEFORE ENDING FILE
LABEL PROCEDURE ON NON-STD.
D. MOVE SPACES TO NSTD-LBL.
MOVE 'NSTEOF ' TO NSTD-HDR.
MOVE N-REC-NUMB TO NSTD-REC-CNT.
MOVE SAV-FIL-NAM TO FIL-NAM IN NSTD-LBL.
END DECLARATIVES.
NON-DECLARATIVE SECTION.
OPEN INPUT NO-LBL.

1"" 'I

.L f ~

l"""lo _ _ .I-

ra..1. '-

T1'7
..1. V

Procedure Division

ERROR Declarative

CD

READ-IN.
READ NO-LBL AT END GO TO END-JOB.
E.
IF NSTD NEXT Sl!;NTENCE
ELSE GO TO PROCESS-USER.
IF NSTD-SWITCH = 1 NEXT SENTENCE
ELSE ADD 1 TO NSTD-SWITCH
OPEN OUTPUT NON-STD
GO TO READ-IN.
ADD 1 TO N-REC-NUMB.
IF HDR-REC MOVE SPACES TO NSTD-REC1
MOVE CORRESPONDING IN-REC TO NSTD-REC1
WRITE NSTD-REC1
ELSE ADD 1 TO NSTD-REC2-CNT
MOVE SPACES TO NSTD-REC2
MOVE CORRESPONDING IN-REC TO NSTD-REC2
MOVE NSTD-REC2-CNT TO N-SEQ-NU~~
WRITE NSTD-REC2.
GO TO READ-IN.
PROCESS-USER.
IF USER-SWITCH = 1 NEXT SENTENCE
ELSE ADD 1 TO USER-SWITCH
MOVE CORRES?ONDING IN-REC TO STOR-REC
MOVE DEPT-ID OF IN-REC TO SAV-DEPT-ID
PERFORM READ-IN
OPEN OUTPUT USER
GO TO READ-IN.
ADD 1 TO U-REC-NUM3.
MOVE CORRESPONDING IN-REC TO USR-REC.
MOVE U-REC-NUMB TO U-SEQ-NUMB
WRITE USR-REC
GO TO READ-IN.
END-JOB.
CLOSE NO-LBL.
IF USER-SWITCH
1 CLOSE USER.
1 CLOSE NON-STD.
IF NSTD-SWITCH
STOP RUN.

A Format 2 USE sentence specifies procedures to be followed if an
input/output error occurs during file processing.

r----------------------------------------------------------------------,

I
Format 2
I
~----------------------------------------------------------------------~

I
I

I
I

!

USE AFTER STANDARD ERROR PROCEDURE
{file-name-1} •••

i

I

I

I
I

I
)~if~'i~~tmlt~t:~~~~~~;~f l;l,~@:~~~~~t~};
I
I
ON
INPUT
I
OUTPUT
I
I
1-0
I
I
!L______________________________________________________________________ JI

When Format 2 is used, automatic system error routines are executed
before user-specified procedures.
USE declaratives which specify error handling procedures are
acti va~E:!cl,ltlh~I'l,,~ni'~I'lP,?'t:.(Output error occurs during execution of a READ,
WRITE~~~mi~~t:;~~'t( statement.
Within the section, the tile associated with the USE sentence may not
be referred to by an OPEN,::~;,,~; SEEK, READ, WRITEij:t~&\~m;
statement.
Declaratives

175

ERROR Declarative
Within a USE procedure there must be no reference to nondeclarative
procedures '~iG~ptit}\~Jnen,',:'ap.' ex:it:';:is:ta'k(;h':"'wi.tli"ii',(;O"TO:':statemel'lt.
Conversely, in the nondeclarative portion, there wust be no reference tc
procedure-names that appear in the declaratives portion, except that
PERFORM statements may refer to a USE declarative, or to procedures
associated with such a declarative.
Whened'.ithel;) the file-naITIe-19r;:'if'lte;';":!l~m~:4:'Z; option is used, user errcr
handling procedures are executed ,;S);-!p"Ptl1:{,2,~,1:g11t:,~Erors occurring
during execution of a READ, WRITE",;:g~~'!<$lW~i:friQ:;t'};i9~~W' statement for that
file only.
A file-name must not be referred to, implicitly or explicitly, in
more than one Format 2 USE sentence.

The user error procedures are executed when the INPU~, OUTPUT, or 1-0
options are specified and an input/output error occurs, as follows:
• When INPUT is specified, only for files opened as INPUT.
• When OUTPUT is specified, only for files opened as OUTPUT.
• When 1-0 is specified, only for files opened as 1-0 (input-output).
,Wl1f:!nth~,.,.GI\lING.",opt~oni$ ",use(j,'d(ita-name-l,~ill., b~set • t() reflect
the, ~rro:r;conditi?nthat 'caused the errorcieclarative" to be entered.; A
value, >of}inan~rror, byte indicatesi:hat its corresponding error
condition has occurred. Indi vidual bytes will correspond to specific
error conditions depending on the type of file being processed as shown
in Figure 28~

The GIVING option must not be specified for files on unit record
devices.
r-------~-,-,,...--:-,-T---,--,..,.-----.,...'-----

I
I

.

Error Byte

I
I

L'lPEXED
SEQUENTIAL

....

T--------'--..;.------T------"...-:---------,

I I . ... .....
I
DIRECT
t
SEQUENTIAL

I

.I

~---------~--- . . -t--~-~~---------t- . . -----'-:....--------+-.;.;. ...---.,.;.;..---.;..-.... ---~

I
I

1

I
I

2

t

I

I
I

Data check
in count

I wrong length
I record

I
I

Wrong length
record

DASD error

I
I

t-------.;.;.-----.,.;---t-------------~,-.,.;-+--------...;,--,....;.;.-,-+-'

I
I

parity error

I
I

........------,-,'-,~---,~-i
wrong length
record

I
I

l----""'r-.--------...,-t---.;..-------------.-+-----.. .------:----t.----:...;----------...;-i

'I
3
I Prime data
J
NO room
J
J
.1:, ........... >' ... .., ,I full . . . . . .•. . .>1< found
... ,1; .',. . . . ...... ..... ....1
'P----"'-..----.... ----+-~ __ -._.'"":---:----'-.~~-.+-:"-__ --._.~_.-_.-~-.-7'"'-.+-,..,.-.-.----""'r-. _:"-.,. . . . . . ~-i

.,

Icylin~erilJdex

4

I, ... ... ... .. " ....'tQO small........ .....

~_....,.-::-,-:-----~-:-t-t-~....

',>,5

i,'

I

Data <:heck,in

I

J

J ker oy:dat(i,. . -.....,
. .. '.. . .. . .,................ J
•. .. . . . . . ,. . -'-~-+_.~-,...--:'---'"":. .--t-.. . ----.,...--_:'---.
. .7'"' . . -:'~

.J,Ma~terJAd~x

..... , L · ,

,I>",'

...... J

..,~C?o:sm~ll, .·•.••.. i l ". ..,\,;' ,I.. . ' . . , ....... >, .....J
f:---:-~~'"":~-,-'--.,..,""'r-..,.,t~_.,_.T-:-:'-.---'--. . . -.-+-:----:-~-.--:-.-;-:-:'::':''"'':-:+-.---:_'_'-""'r~-~-:,-:-::--i
l:,"t.,;< ..................... ,J',p"'et"flQ'waJ:;ea.., .J
."
...1<, <: . . . . . . ' . ', J
1.:,i:,'·.···.•
';,',".J,~UtN.~·. ·.,',"\':< .• ·1
. . . •. . . . . . . .•.••.•. . •. •. ·.•. ·.· .••·.·. . . i"t' ....... ". ,'··•.•• ii . . . ·,·.·. :,,1
r""'r'--:'~. . . . . ..,.,.,..~~---:'-:-.+:__~:,T::---:-~--;-'::':'--:-+---~~--"":--. . ---,. . :--q'---;-:--........·-_.:__--.....:--...:71
I.",•. ·.·.·.? . . • ,'......... ·,.··.··., .• ,:1·.No . '~oF::r;t:!.<='?)':4, :.. 1. . . . . . .
." . ', . '.•.• . 1,., . ,,' . . . •. '.', .•· •.· ,.•.·...•.•.• ·.·.·. ,.•. ,;1
":i·. .· · · .·.·· · .·.·. . .·.· . .·.: . .·.·. ·. . ··'.·l'w;~tten; .ill,:!>:t:'~~l,.···,'·,·. . ·., . ,·.,' .•·•.·•. "l< . . •. ·•. · · · . .• ·. •. ··,'/<:,',:,i",<>l
t.>'i

:i .

:' .. ··>",i"·• lda't:~areai"'.·',i.··l.,,:';,.... .' . . ":.... .' •.

l:·'·','«',·.• .• ····.,',<".,l

f-:' ............-...,.,~-- ...-:-......,.,-:~·+-7--.-.~--·-:-.-...-':. . 7'"'---+~. . .""":'"""·--.,. '"":... -:'::':'...7----+. . . . -~-:',...-.. . . . . .'-:"-~:'"!'::':'-:''i
t , ' , 8 , ' .. . : : 1 .... . •.•..•....... " " . ..1 ....'. . . . .' .. ' . ..' .. t ....•..'< ....>. . , 1
»

- .•. ,·.·.·.

--'-""'r.......

l_'-~--~-7 .... ~~....--"'""'---:-~-.---,"":_.... -:....--,-~J.-;-;~7~- ...... - ...
_J. ......... ~.--_ ....... _'.......
Fiqure28.E,rro,r;B¥t~ Meaning;rfor the" GIVING Option of' an Erro'r

Decla1:"yt~,,~xternal -(i€ci.ma'l

~~tin~~ti,*n[},~h~ ·w~,;~~~~7~1tp~p.~~~;iR~~tion;.
176

Part IV -- Procedure Division

""'r-.. . . . ,. . _J

ERROR/BEFORE REPORTING Declarative
, ',nata-'name::'2'",{f s~i~'ied, "wJ.ll:~on~fri}tihe!:,.:~~k:;1~~:}A'~:Jt:n,:),r'<;@;,~)-1
'"it: 'DO data was tra,ilsn\iJtted) ,
bat.:t·...:riarde~i,:~il1?~Ctjnta~~; i\t1],,~~Jt!;,
,erroronlywhen' tih;e er;ror 'occurs during:
a;,·RiiA:)j;:~~a~idJj.,;:
, .. ' . f .". . , ' !: t · ".
j
..
~.

0;'

, .,
~ .1>i

!!

,,~.

~

~.':

<

',~",;i,
',J
"'
~ ~
y

.nata""name~2 :must J)e l,aj:'ge enouthatexlstso:C:;wil.l,be written 'onfile:-iname"':2.: 'I,t'must
>the' Working-Storage or Linkage, :Sectlon., "rfIdata~name~i, ;is :dE~f!:iJil1e~
':the'LinkilgeSection, :the :block in 'error is'referenced
al';"!:~~L._!lP~,~~_C?.~~'ge, 'neE;d' be :defined,for: 'the ~r.ror'hlock,':' .

in

~~ exit from this type of declarative section can be effected by
executing the l(ist statement in the section (normal return)flo,~~Jgt'A&~
P~".cf~,(;O;",TO/~~:J::(l,t:,eIn.ent:.
Figure 29 summarizes the facilities and
li~i~~fi6~i'as~ocii~ied with each file-processing technique when an error
occurs.

The normal return from an error declarative is to the statement
following the input/output statement that caused the error.

A Format 3 USE sentence specifies Procedure Division statements that
are executed just before a report group named in the Report Section of
the Data Division is produced (see "Report Writer").

r----------------------------------------------------------------------,

i

I

Format 3

~----------------------------------------------------------------------~

I
I
Q~~ BEFORE REPORTING data-name.
I
I
I ______________________________________________________________________ JI
L

Declaratives

177

ERROR Declarative
r--------T-------T----------T--~~=~~T-------------------------------------T-------------,

I
I
IType of
I
I
Error Declarative written
I No Error
I
I
IOrgani-1
I/O
I Error ~------------------T------------------1 Declarative I
I Access Ization IStatement I Bytes I Normal Return
I
GO TO Exit
I
written
I
~--------+-------+----------+~----~~+------------------+------------------+-------------~

SEQUEN- ISequen-IREAD
TIAL
Itial
I
(or not I
I
speci-,
I
fied)
I
I

I

I
I
I
I

,

I

I

I

I

I

I

I Direct I READ
I
I

ling of file perling of file perI
Imitted; bad block Imitted; bad block,
I has been written I has been written I

r

I

I

I
I
I

I

I Direct I READ
I
I
I
I
I
I
I
,

I

. . .--.. . ___+------------------+------------------1
I User limited to

Ll,2', orl User limited to
, 4~
ICLOSE for file

~--------+-------+----------+..:..,"'"'

I
I
,

. . ---....;+------------------+------------------1

11,2'" orl Continued process-I continued process-I
I ! 4'
I ing of file per- I ing of file perI
I~

Imitted; bad block Imitted; bad block I
Ihas not been byIhas not been byI
I passed
I passed
I

I
I

I WRITE
I

I

I~r 4
ling of file
~=~=-_....,-_....,~+-i -.;..---~mitted; bad

I
I

I REWRITE

perling of file perI
block Imitted; bad block I
; Ili .. 2, orl has been written I has been written I

...

~ 1'1 ."·4 :
I
h...,-,.,,.,.-·...,,,·,·....... ,-+-'''''_.---,.,,=.+-....,·------~,.,j-,-+...;;-·-_-.,.----I-,._-.--.-.-,,.,.,...,,-._-,-.--..,,-,..._.

I

I
,

,CLOSE for file

~----------+-------+------------------+------------------~
I ~" 2',3, I Continued process-I Continued process-I

I

I

I

I

...,+...,__ ,. . , .,. ,.,. ,.,...,. .,. ,. ,., . _.,...,.-._.,..,,--:

2: J:Continued process-I Continued proces$
'ling of fi~e per- 'I ingof file perImitted; bad block Imitted; bad blQc~
(has 'not be,en QY- i (has ~not beenbYi- ;
!: I passed
i i i 'h?as~ed
i
I

H~-.--,--,---ih,-I+i~I-!_I-'-...J+-...:---...:-'-_...;-_-J--J4---.J-----!...:-..;--..; ,
, . tinued ipro~es~-J
'inueq lp,r:'oc~~~-;
of fill~
,
i J,f~~e ,
j!mJ~tt:;eCl

t i

i •

I
I
I
I
I
I
I

L"Ji~it'ri~~'!:'!!i~~::!£,! :

Figure 29.

178

I

~----------+;,..--_:~--+------------------+------------------1
11 or 2 IContinued process-I continued process-I

tWRITE

~-------+----------+..:..-

I RANDOM

I Diagnostic
I
lerror messagel
I is printed; I
I job is
I
,terminated
I

110r 2 IContinued process-IUser limited to
I
ling of file perICLOSE for file
I
'I mitted; bad block I
I
',is bypassed
I
I
I
I

File Processing Techniques and Associated Error Declaratives

Part IV -- Procedure Division

I

CORRESPONDING/GIVING/ROUNDED Options
ARITHMETIC STATEMENTS

The arithmetic statements are used for computations. Individual
operations are specified by the ADD, SUBTRACT, MULTIPLY, and DIVIDE
statements. These operations can be combined symbolically in a formula,
using the COMPUTE statement.
Because there are several options common to the arithmetic statements, their discussion precedes individual statement descriptions.

CORRESPONDING Option
The CORRESPONDING option enables computations to be performed on
elementary items of the same name simply by specifying the group item to
which they belong. The word CORRESPONDING may be abbreviated as CORR.
Both identifiers fol~owing CORRESPONDING must refer to group items.
For the purposes of this discussion, these identifiers will be called d 1
and d 2 •
Elementary data items from each group are considered CORRESPONDING
when both data items have the same name anj qualification, up to but not
including d 1 and d 2 •
Neither d 1 nor d 2 may be a data item with level number 66, 77, or 88,
nor may either be described with the USAGE IS INDEX clause. Neither d 1
nor d 2 may be a FILLER item.
Each data item subordinate to d 1 or d 2 that is describe~ with
REDEFINES, RENAMES, OCCURS, or USAGE IS INDEX clause is ignored;
items subordinate to such data items are also ignored. HOwever,
d 2 may themselves be described with REDEFINES or OCCURS clauses,
subordinate to items described with REDEFINES or OCCURS clauses.

a
any
d 1 or
or be

Each FILLER item subordinate to d 1 or d 2 is ignored •

.~~~~:;~:~~~~~'~~~~W~,\~~!\:,~:;;'~:::~.·.~:i~\r:~!,~:~!~~J:':¥ . ,,;,~
GIVING Option
If the GIVING option is specified, the value of the identifier that
follows the word GIVING is set equal to the calculated result of the
arithmetic operation. This identifier, since not itself involved in the
computation, may be a numeric edited item.

ROUNDED Option
After decimal point alignment, the number of places in the fraction
of the result of an arithmetic operation is compared with the number of
places provided for the fraction of the resultant identifier.
Arithmetic Statements

179

SIZE ERROR Option/Overlapping Operands
When the size of the fractional result exceeds the number of places
provided for its storage, truncation occurs unless ROUNDED is specified.
When ROUNDED is specified, the least significant digit of the resultant
identifier has its value increased by 1 whenever the most significant
digit of the excess is greater than or equal to 5.
When the resultant identifier is described by a PICTURE clause
containing piS and when the number of places in the calculated result
exceeds this size, rounding or truncation occurs relative to the
rightmost integer position for which storage is allocated.

SIZE ERROR Option
If, after decimal point alignment, the value of a result exceeds the
largest value that can be contained in the associated 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 of an arithmetic operation and does not apply to
intermediate results. If the ROUNDED option 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 option is specified.
If the SIZE ERROR option is not specified and a size error condition
occurs, the value of the resultant identifier affected may be
unpredictable.
If the SIZE ERROR option is specified and a size error condition
occurs, the value of the resultant identifier affected by the size error
is not altered. After completion of the execution of the arithmetic
operation, the imperative statement in the SIZE ERROR option is
executed.

Overlapping Operands
When the sending and receiving operands of an arithmetic statement or
a MOVE statement share a part of their storage (that is, when the
operands overlap), the result of the execution of such a statement is
unpredictable.

180

Part IV -- Procedure Division

ADD

statement

ADD statement
The ADD statement causes two or more numeric operands to be summed
and the result to be stored.

r----------------------------------------------------------------------,
Format 1
,
,~----------------------------------------------------------------------~,
,

I

i,

\identifier-l,
lliteral-l
\

ADD

fidentifier-21
Lliteral-2

'

J

TO identifier-m [ROUNDED]

I,

,
[identifier-n [ROUNDED]] ••• [ON SIZE ERROR imperative-statement] I
IL______________________________________________________________________ JI

r----------------------------------------------------------------------,
Format 2
I

I

~----------------------------------------------------------------------~

I

I
I
I
I

,

ADD

'jidentifier-l
literal-l

i
~

jident.ifier-2t
literal-2

GIVING identifier-m [ROUNDED]

~

II

[identifier-3]

I
I

literal-3

[ON SIZE ERROR imperative-statement],

,

L ______________________________________________________________________ J

r----------------------------------------------------------------------,
Format 3
,

I

~-------------------------------------------~--------------------------~

I
I,

,

ADD

jCORR
CORRESPONDING

1

I
I

identifier-l TO identifier-2

,

I

I
,
[ROUNDED] [ON SIZE ERROR imperative-statement]
I
IL__________________________ ___________________________________________ JI
~

Format 1 -- the values of the operands preceding the word TO are
added together, and the sum is added to the current value o f '
identifier~m (identifier-n), etc.
The result is 'stored in identifier-m
(identifier-n), etc.
Format 2 -- when the GIVING option is used, there must be at least
two operands preceding the word GIVING. The values of these operands
are added together, and the sum is stored as the new value of
identifier~m.

In Formats 1 and 2 each identifier must refer to an elementary
numeric item, with the exception of identifiers appearing to the right
of the word GIVING. These may refer to numeric edited data items.
Each literal must be a numeric literal.
The maximum size of each operand is 18 decimal digits. The maximum
size of the resulting sum, after decimal point alignment, is 18 decimal
digits.
Format 3 -- when the CORRESPONDING option is used, elementary data
items within identifier-l are added to and stored in corresponding
elementary data items within identifier-2. Identifier-l and
identifier-2 must be group items.
Arithmetic Statements

1,8-1

COMPUTE Statement
When ON SIZE ERROR is used in conjunction with CORRESPONDING, the
size error test is made only after the completion of all the ADD
operations. If any of the additions produces a size error condition,
the resultant field for that addition remains unchanged, and the
imperative statement specified in the SIZE ERROR option is executed.

COMPUTE statement
The COMPUTE statement assigns to a data item the value of a data
item, literal, or arithmetic expression.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------1

I

I
I
I
lidentifier-2
I
I
COMPUTE identifier-1 [ROUNDED] =
literal-1
I
I
arithmetic-expression
I
I
I
I
[ON SIZE ERROR imperative-statement]
I
IL ______________________________________________________________________ JI

Literal-1 must be a numeric literal.
Identifier-2 must refer to an elementary numeric item.
may describe a numeric edited data item.

Identifier-1

The identifier-2and literal-1 options provide a method for setting
the value of identifier-1 equal to the value of identifier-2 or
literal-1.
The arithmetic-expression option permits the use of a meaningful
combination 6f identifiers, numeric literals, and arithmetic operators.
Hence, the user can combine arithmetic operations without the
restrictions imposed by the arithmetic statements ADD, SUBTRACT,
MULTIPLY, and DIVIDE.
As in all arithmetic statements, the
18 decimal digits.

182

Part IV -- Procedure Division

ma~imum

size of each operand is

I

DIVIDE Statement
DIVIDE Statement
The DIVIDE statement is used to find the quotient resulting froIT! the
division of one data item into another data item.

r----------------------------------------------------------------------,
Format 1
I

I

~----------------------------------------------------------------------1

I
DIVIDE

l~::::::~:r-lt

I
INTO identifier-2

[ROUNDED)

i

I
I
IL______________________________________________________________________ JI
[ON SIZE ERROR imperative-statement]

r----------------------------------------------------------------------,
I
Format 2
I
~----------------------------------------------------------------------1

I
I
I
lidentifier- 1 f lINTO f lid. entifier- 2 f
I
DIVIDE
§IVING identifier-3
I
literal-l
BY
l1teral-2
I
I
I
I
[ROUNDED] [REMAINDER identifier-4]
I
I
I
I
[ON SIZE ERROR imperative-statement]
I
IL ______________________________________________________________________ JI

When Format 1 is used, the value of identifier-l (or literal-i) is
divided into the value of identifier-2. The value of the dividend
(identifier-2) is replaced by the value of the quot{ent.
When Format 2 is used, the value of identifier-l (or literal-i) is
divided into or by identifier-2 (or literal-2), the quotient is stored
in identifier-3, and the remainder optionally is stored in identifier-4.
remainder is defined as the result of subtracting
tient and the divisor from the dividend.
after

remainder is

Each identifier must refer to an elementary numeric item except the
identifier following the word GIVING, which may be a numeric edited
item.
Each literal must be a numeric literal.
The maximum size of the resulting quotient, after decimal point
alignment, is 18 decimal digits.
The maximum size of the resulting
remainder (if specified), after decimal point alignment, is 18 decimal
digits.
Division by zero always results in a size error condition.

Arithmetic Statements

183

MULTIPLY Statement
MULTIPLY Statement
The MULTIPLY statement is used to multiply one data item by another
data item.

r----------------------------------------------------------------------,
Format 1
I

I

~----------------------------------------------------------------------~

I
I
I
lidentifier-1~
I
MULTIPLY
BY identifier-2
[ROUNDED]
I
literal-1
I
I
I
I
[ON SIZE ERROR imperative-statement]
I
IL _______________________________________________
_________________ JI
~-----

r-----------·-----------------------------------------------------------,
I
Format 2
I
~----------------------------------------------------------------------~

I
I
I
lidentifier-1!
lidentifier-2!
I
I
MULTIPLY
BY
GIVING identifier-3
I
I
literal-1
literal-2
I
I
I
I
[ROUNDED]
[ON SIZE ERROR imperative-statement]
I
IL ______________________________________________________________________ JI

When Format 1 is used, the value of identifier-1 (or literal-1) is
multiplied by the value of identifier-2. The'value of the multiplier
(identifier-2) is replaced by the. product.
When Format 2 is used, the value of identifier-1 (or literal-1) is
multiplied by identifier-2 (or literal-2), and the product is stored in
identifier-3.
Each identifier must refer to an elementary numeric item except the
identifier following the word GIVING, which may be a numeric edited
item.
Each literal must be a numeric literal • .
The maximum size of each operand is 18 decimal digits. The maximum
size of the resulting product, after decimal point alignment, is 18
decimal digits.

184

Part IV

procedure Division

SUBTRACT Statement
SUBTRACT Statement
The SUBTRACT statement is used to subtract one, or the sum of two or
more, numeric data items from another data item(s).

r----------------------------------------------------------------------,
I

I

Format 1

~----------------------------------------------------------------------1

I
I
I
,identifier-l/
ridentifier-21
I
I SUBTRACT)
!
I
(literal-l
,
literal-2
I
I
I
I
I
FROM identifier-m
[ROUNDED]
I
I
I
I
[identifier-n [ROUNDED]] ••• [ON SIZE ERROR imperative-statement] I
"L
I ______________________________________________________________________ JI

L

J

r--------------------------------------~-------------------------------,

I

I

Format 2

~----------------------------------------------------------------------1

I
identif ier-ll
identifier-j
I
I SUBTRACT
literal-l
~ [ literal-2
I
I
,identif ier-m)
!
GIVING identifier-n
I
IIi teral-m
f
I
I
[ROUNDED]
[ON SIZE ~RROR imperative-statement]
I
IL _____________________________________________________________________ _

l

r------------~---------------------------------------------------------,

I

Format 3
I
~-------------------------------------------------------~--------------~

I
:

I
I
I

SUBTRACT

t

lCORR
CORRESPONDING\

[ROUNDED]

identifier-l FROM identifier-2

[ON SIZE ERROR imperative-statement]

IL______________________________________________________________________ JI
Format 1 -- all literals or identifiers preceding the word FROM are
added together, and this total is subtracted from identifier-m and
identifier-n (if stated), etc. The result of the subtraction is stored
as the new value of identifier-ro, identifier-n, etc.
Format-2 -- all literals or identifiers preceding the word FROM are
added together, and this total is subtracted from literal-m or
identifier-me The result of the subtraction is stored as the value of
identifier-n.
Format 3 -- data items in identifier-l are subtracted from, and the
difference stored into corresponding data items in identifier-2.
When
the CORRESPONDING option is used in conjunction with ON SIZE ERROR and
an ON SIZE ERROR condition arises, the result for SUBTRACT is analogous
to that for ADD.
Arithmetic Statements

185

SUBTRACT Statement
Each identifier must refer to an elementary numeric item except the
identifier following the word GIVING, which may be a numeric edited
item.
Each literal must be a numeric literal.
The maximum size of each operand is 18 decimal digits. The maximum
size of the resulting difference, after decimal point alignment 1 is 18
decimal digits.

'\

-..;

.~.

186

Part IV -- Procedure Division

GO TO Statement
PROCEDURE BRANCHING STATEMENTS

Statements, sentences, and paragraphs in the Procedure Division are
ordinarily executed sequentially. The procedure branching statements
(GO TO, ALTER, PERFORM, STOP, and EXIT) allow alterations in the
sequence.

GO TO Statement
The GO TO statement allows a transfer from one part of the program to
another.

r----------------------------------------------------------------------,
Format 1
I

I

~----------------------------------------------------------------------1

I
I
I
GO TO procedure-name-1
I
IL______________________________________________________________________ JI

r----------------------------------------------------------------------,
Format 2
I

I

~----------------------------------------------------------------------~

I
I
GO TO procedure-name-1 [procedure-name-2J
I
I
I
I
DEPENDING ON identifier
I
I
IL______________________________________________________________________ JI

r-------------------------------------------------------------=--------1
Format 3
I

I

~----------------------------------------------------------------------1

I
I
I
GO TO.
I
IL ______________________________________________________________________ JI
When Format 1 is specified, control is passed to procedure-name-1 or
to another procedure name if the GO TO statement has been changed by an
ALTER statement.
(If the latter is the case, the GO TO statement must
have a paragraph name, and the GO TO statement must be the only
statement in the paragraph.)
If ·a GO TO statement represented by Format 1 appears in an imperative
sentence, it must appear as the only or last statement in a sequence of
imperative statements.
When Format 2 is used, control is transferred to one of a series of
procedures, depending on the value of the identifier. When identifier
has a value of 1, control is passed to procedure-name-1; a value of 2
causes control to be passed to procedure-name-2, ••• ; a value of ~
causes control to be passed to procedure-name-n. For the GO TO
statement to have effect, identifier must represent a positive or
unsigned integer, i'-e., 1, 2, ••• , n. If the value of the identifier is
anything other than a value within the range 1 through ~, the GO TO
statement is ignored. The number of procedure-names must not exceed
2031.
Procedure Branching Statements

187

ALTER Statement
Identifier is the name of a numeric elementary item described as an
integer. Its PICTURE must be of four digits or less.
Its USAGE must be
DISPLAY, COMPUTATIONAL, 9~Cti~1:PW;rATJ:ONAL;""3.
When Format 3 is used, an ALTER statement, referring to the GO TO
statement, must have been executed prior to the execution of the GO TO
statement. The GO TO statement must immediately follow a paragraph name
and must be the only statement in the paragraph.
ALTER statement
The ALTER statement is used to change the transfer point specified in
a GO TO statement.

r----------------------------------------------------------------------,
I

Format

I

~----------------------------------------------------------------------~

I
I
I
ALTER procedure-name-l TO [PROCEED TO] procedure-name-2
I
I
I
I
I
I
[procedure-name-3 !Q [PROCEED TO] procedure-name-4]...
I
IL______________________________________________________________________ JI

procedure-name-l, procedure-name-3, etc., must be the names of
paragraphs that contain only one sentence consisting of a GO TO
statement without the DEPENDING option.
Procedure-name-2, procedure-name-4, etc., must be the names of
paragraphs or sections in the Procedure Division.
The effect of the ALTER statement is to replace the procedure-name
operands of the GO TO statements with procedure-name-2,
procedure-name-4, etc., of the ALTER statement, where the paragraph-name
containing the GO TO statement is procedure-name-l, procedure-name-3,
etc. For 'example:
PARAGRAPH-i.
GO TO BYPASS-PARAGRAPH.
PARAGRAPH-1A.
BYPASS-PARAGRAPH.
ALTER PARAGRAPH-l TO PROCEED TO PARAGRAPH-2.
PARAGRAPH-2.

Before the ALTER statement is executed, when control reaches
PARAGRAPH-l, the GO TO statement transfers control to BYPASS-PARAGRAPH.
After execution of the ALTER statement, however, when control reaches
PARAGRAPH-l, the GO TO statement transfers control to PARAGRAPH-2.
segmentation Informatiou:
A GO TO statement in a section whose
priority is greater than or equal to 50 must not be referred to by an
ALTER statement in a section with a different priority. All other uses
of the ALTER statement are valid and are performed even if the GO TO to
which the ALTER refers is in an overlayable fixed segment (see
"Segmentation").
188

Part IV -- Procedure Division

PERFOFWI statement
PERFORM Statement
The PERFORM statement is used to depart from the normal sequence of
procedures in order to execute a statement, or a series of statements, a
specified number of times; or until a predetermined condition is
satisfied. After the statements are executed, control is returned to
the statement-after the PERFORM statement.

r----------------------------------------------------------------------,
I

I

Format 1

r--------------------------------------------------~-~~----------------~

I
I
I ______________________________________________________________________
PERFORM procedure-name-l [THRU procedure-name-2]
L
JI

r----------------------------------------------------------------------,
Format 2

I

1

r----------------------------------------------------------------------1

I
I
I
II

I

PERFORM procedure-name-l [THRU procedure-name-21

1

li.dentifier- 1

I

I
I
II

TIMES

I

1nteger-l

L __________________________ - - - - - - - - - - - - - - - - - - - - - - - - - - - _________________ J

r----------------------------------------------------------------------,
Format 3
I

I

~----------------------------------------------------------------------~

I
I
I
PERFORM procedure-name-l [THRU procedure-name-21
I
I
I
IL______________________________________________________________________
UNTIL condition-l
JI

r----------------------------------------------------------------------,
Format 4
I

I

~----------------------------------------------------------------------~

PERFORM procedure-name-l [THRU procedure-name-21
index-name-l!
FROM

VARYING
l identifier-l
BY

literal-3

I

!

UNTIL

index-name-2!
literal-2
identifier-2

l

condition-l

identifier-3
index-name-4

index-name- 51

l
[AFTER
literal-5
I
. identifier-4\
identifier-5
I
I
literal-6
l
I
UNTIL condition-2
I
identifier-6\
I
I
index- name -7l
index-name-8!
I
[AFTER
FROM
literal-8
I
l identifier-7\
identifier-8
I
I
literal-9
l
I
UNTIL condition-311
I
i den tif ier- 9\
L
J
I ______________________________________________________________________

l

I

j

I

I

Procedure Branching Statements

189

PERFORM Statement
Each procedure-name must be the name of a section or paragraph in the
Procedure Division.
Each identifier represents a n~meric elementary item described in the
Data Division.
In Format 2, and Format 4 with the AFTER option, each
identifier
ents a numeric item described as an
ere

Each literal represents a numeric literal.
Whenever a PERFORM statement is executed, control is transferred to
the first statement of the procedure named procedure-name-1. Control is
always returned to the statement following the PERFORM statement. The
pOint from which this control is passed is determined as follows:
1.

If procedure-name-1 is a paragraph name and procedure-name-2 is not
specified, the return is made after the execution of the last
statement of procedure-name-1.

2.

If procedure-name-1 is a section name and procedure-name-2 is not
specified, the return is made after the execution of the last
sentence of the last paragraph in procedure-name-1.

3.

If procedure-name-2 is specified and it is a paragraph name, the
return is made after the execution of the last statement of that
paragraph.

4.

If procedure-name-2 is specified and it is a section name, the
return is made after the execution of the last sentence of the last
paragraph in the section.

When both procedure-name-l and ~ocedure-name-2 are specified, GO TO
and PERFORM statements may appear within the sequence of statements
within these paragraphs or sections.
When procedure-name-1 alone is
specified, PERFORM statements may appear within the procedure. GO TO
may also appear but may not refer to a procedure-name outside the range
of procedure-name-1.
When a PERFORM statement includes within its range of procedures
another PERFORM statement, this embedded PERFORM statement must have its
range of procedures either totally included in or totally excluded from
the range of procedures of the original PERFORM statement. That is, the
exit point of the original PERFORM statement cannot be contained within
the r
of procedures of the embedded PERFORM statement

Control may be passed to a sequence of statements that lies between
the entry and exit points of a PERFORM statement by means other than a
PERFORM. In this case, control passes through the last- statement of the
procedure to the following statement as if no PERFORM statement referred
to these procedures.
FORMAT 1: When Format 1 is used, the procedure(s) referred to are
executed once, and control returns to the statement following the
PERFORM statement.
FORMAT 2: When Format 2 is used, the procedure(s) are performed the
number of times specified by identifier-lor integer-i. Once the TI~lliS
option is satisfied, control is transferred to the statement following
the PERFORM statement.
The following rules apply to the use of a Format 2 PERFORM statement:
190

Part IV -- procedure Division

PERFORM statement
1.

if integer-lor identifier-1 is zero or a negative number at the
time the PERFORM statement is initiated, control passes to the
statement following the PERFORM statement.

2.

once the PERFORM statement has been initiated, any reference to
identifier-l has no effect in varying the number of times the
procedures are initiated.

FORMAT 3: When Format 3 is used, the specified procedures are performed
until the condition specified by the UNTIL option is true. At this
time, control is transferred to the statement following the PERFORM
statement. If the condition is true at the time that the PERFORM
statement is encountered, the specified procedure(s) are not executed.
FORMAT 4:- Format 4 is used to augment the value of one or more
identifiers or index-names during the execution of a PERFORM statement.
When executing a Format 4 PERFORM statement, the initial values of
identifier-2 (index-name-2) and identifier-5 (index-name-5) must be

~ositive

in .order to

confbrm;~~~~~~d"_]~itli_r:~~~~1~~0/

In the following discussion of Format 4, every reference to
identifier-n also refers to index-name-n except when identifier-n is the
object of the BY option.
Also, when index-names are used, the FROM and
BY clauses have the same effect as in a SET statement (see "Table
Handling").
Dur~ng execution of the PERFORM statement, reference to index-names
or identifiers of the FROM option has no effect in altering the number
of times the procedures are to be executed. Changing the value of
index-names or identifiers of the VARYING option or identifiers of the
BY option, however, will change the nuwber of times the procedures are
executed.

When one identifier is varied, the following is the sequence of
events:
1.

Identifier-l is set equal to its starting value, identifier-2 or
literal-2.

2.

If condition-1 is false, the specified procedure(s) are executed
once.

3.

The value of identifier-l is augmented by the specified increment
or decrement, identifier-3 or literal-3, and condition-l is
evaluated again.

4.

steps 2 and 3 are repeated, if necessary, until the condition is
true. When the condition is true, control passes directly to the
statement following the PERFORM statement. If the condition is
true for the starting value of identifier-l, the procedure(s) are
not executed, and control passes directly to the statement
following the PERFORM statement.

Figure 30 is a flowchart illustrating the logic of the PERFORM
statement when one identifier is varied.
When_~wo

identifiers are varied, the following is the sequence of

events:
1.

Identifier-l and identifier-4 are set to their initial values,
identifier-2 (or literal-2> and identifier-5 (or literal-5),
respectively.

2.

Condition-l is evaluated; if true, control is passed to the
statement following the PERFORM statement; if false, condition-2 is
evaluated.
Procedure Branching statements

191

PERFORM statement
3.

If condition-2 is false, procedure-name-l through procedure-name-2
(if specified) is executed once.

4.

Identifier-4 is augmented by identifier-6 (or literal-6), and
condition-2 is evaluated again.

5.

If condition-2 is false, steps 3 and 4 are repeated.

6.

If condition-2 is true, identifier-4 is set to its initial value,
identifier-5.

7.

Identifier-l is augmented by identifier-3 (or literal-3).

8.

steps 2 through 7 are repeated until condition-l is true.

At the termination of the PERFORM statement, if condition-l was true
when the PERFORM statement was encountered, identifier-1 and
identifier-4 contain their initial values.
Otherwise, identifier-l has
a value that differs from its last used setting by an increment or
decrement, as the case may be.
Figure 31 is a flowchart illustrating the logic of the PERFORM
statement when two identifiers are varied.
For three identifiers, the mechanism is the same as for two
identifiers except that identifier-7 goes through the complete cycle
each time that identifier-4 is augmented by identifier-6 or literal-6,
which in turn goes through a complete cycle each time identifier-l is
varied.
Figure 32 is a flowchart illustrating the logic of the PERFORM
statement when three identifiers are varied.
SEGMENTATION INFORMATION: A PERFORM statement appearing in a section
whose priority is less than the segment limit can have within its range
only one of the following:
1.

sections each of which has a priority number less than 50

2.

Sections wholly contained in a single segment whose priority number
is greater than 49

t~':~:~:i,~~~*~,'i~b,,:J~eE~~l":~~,~
~l~"~"~~~~ .,

A PERFORM statement appearing in a section whose priority number is
equal to or greater than the segment limit can have within its range
only one of the following:
1.

Sections each of which has the same priority number as that
containing the PERFORM statement

2.

Sections with a priority number less than the segment limit
.~('

..

,~."

.. ~··:·.::-~!J1.i"~'r·::

H.~~;~(r.;;J"l·f""·!~'

-~,,--.

·.;.,iit~

However ,this compiler allows the .PERfORM" t'O:'bave'~~Ulin ii:s"+ra:n:ge'
sections with any priority numbers~
.:;.: "';:;:':'~::' .' . ,; t~"
When a procedure-name in a permanent segment is referred to by a
PERFORM statement in an independent segment, the independent segment is
reinitialized upon exit from the performed procedure (see
"Segmentation").
192

'-.7

.LV

-- Procedure Division

PERFORM Statement

****A2 ** *** * ***
* EXECUTION OF *
* PERFORM STWT
*
BEGINS

* * **** *** ** * * * *

1

* * * **B2* ** * * * ** **
*
SET
*
* IDENTIFIER-i' *
* EQUAL TO ITS *
* FRO~ VALUE
*

*** ** *** * * * ** *** * **

1

. *.

* C2
*. *
****C3*********
• * • TEST
• *. TRUE
*
__ >*. CON9ITION-i • *-------->*
EXIT

*. *

. * ... *. * . *

r"

* ***************

*** **D2 **** * ** ***

**
*
*
*

EXECUTE
PROCEDURE-i
TqRU
PROCEDURE- 2

**
*

*

*

** * * *** ***** ** ***

1

* ****E2 * * * * * * ** **

*

*
---*
*
*

AUGMENT

*

WITR ITS BY
VALUE

*

IDENTI~IFR-i

"* ***~~* *"" *** * ** **

Figure 30.

Logical Flow of Option 4 PERFORM statement Varying One
Identifier

Procedure Branching Statements

193

PERFORM statement

** ** Ai *** ** ** ** ..

* EXECUTION OF
* PERFORM STMT
*
BEGINS

***************

*
*

v

** ***Bi *** ** *** **
** IDENTIFIER-l **
* IDENTIFIER-L!
*
*SET TO INITIAL *
* F«OM VALUE *
* .. *** * ****** **** *

:*::*:->1
* **** * V
. *.
• * *CiT!':ST *. *. *.

*. CONDITION-i •

*..

*..

.."

...

r"

* .... *

***************

. *.

*.
. * '" TEST *. •
2
-->*. *.CONDI'I'ION- . * •
*.
.*
Di

TRUE
* ****C2*********
*
*-------->*
EXIT
*
*
*

r"

* ... *

*----------------[
TRUE

***El ***** ** * ***
***
..
EXECUTE
*

PROCEDURE-l
THRU
PROCEDURE- 2

** *** *** **** *** **

1

***E2 SET
** * *** '" ****
***
*IDENTIFIEP-L! TO*
* ITS INITIAL *
FROM VALUE
*
*
* * ***** * .. ** * ...... **

1

.... * **Fl ** * ** ** * **
** ** *F2 ** * ** ** ***
*
*
*
AUGMENT
* . .*
AUGMEt>T
---* IDEN'IIFIER-4
* IDENTIFIER-l
** HITHVALUE"
ITS BY
* WIT':! ITS BY
,.
VALUE
,.
..

** *** ***** ** *****

** ** *** ***** * ** ....

1

****

*.. Cl **
*
*

Figure 31.

194

n~ ..........
................

Logical Flow of Option 4 PERFORM statement Varying Two
Identifiers

Tt7

~v

Procedure Division

PERFORM statement

** **1'.2 *** ** * ***
* EXECU":'ION OF *
* PERFORM STMT *
*
BEGINS
*
***************

1

*****32* **** *****
'" IDENTIFIER-l *
* IDENTIFIER-II *
* IDENTIFIER-7 *
*SET TO INITIAL *
* FROM VALUES *
** ***** ******* ***

1

C2

. *. *.

*.
****C3*********
*
*
•*
TEST
*. TRUE
*
*
* C2 *---->*. CONDITION-l • *-------->*
EXIT
*
*
*
*.
•*
*
*
****

•*

* * ** * ***** ** ***

*..*

****

r

* .. *

D2

. *.

SE

*.

****
.*
*.
*
*
•*
TEST
*. TRUE
* D2 *---->*. CONDITION-2 • *----------------------------------------

***** *

*.

r

*..*

*. . *

.*

E2

.*. * .

.*

SE

*•

•*
TEST
*. TRUE
-->*· CONDITION- 3 • *-----------------1

r

*.

.*

···r~;E

** ***F2* * **** ** **
*
*
*
EXECUTE
*
* PROCEDURE-l *
*
THRU
*
* ?ROCEDURE- 2 *
** * *** * ***** *****

1
** ***G2 ** ** ** ****
*
*
*
AUGMENT
*
---* IDENTIFIER-7 *
* WITH ITS BY *
'"
VALUE
*
*** ***'" **** * * ****

1
* * ***F3* *** ** *** *
*
SET
*
* IDENTIFIER-7 *
*TO ITS INITIAL *
* FROM VALUE
*
*
*
** * *** ** ***** *** *

j

** * **G3**** ** ****
*
*
*
AUGMENT
*
* IDENTIFIER-4 *
* WITH ITS BY *
*
VALUE
*
** * *** ** ******** *

1

*****FII * ** * ***** *

*
SE'I
*IDENTIFIEi<-1I

*
*

ITS INITIAL
FROM VALUE

* ****** ** ******
****

1

*****G!! * *** * *** **

**

*
AUGMENT
* IDENTIFIER-l
* WITH ITS BY
*
'VALUE
*
** ** **** **** * * ** *

1

1

****

** D2 **
* **** *

Figure 32.

*

TO*
*
*

**

****
C2

**

***** *

Logical Flow of Option 4 PERFORM statement Varying Three
Identifiers

Procedure Branching Statements

195

STOP/EXIT Statements
S'IOP Statement
The STOP statement halts the object program either permanently or
temporarily.

r----------------------------------------------------------------------,

I

Format

I

r----------------------------------------------------------------------~

I
I

I

STOP

IRUN

(

I

I
llteral
I
IL ______________________________________________________________________ JI

When the RUN option is used, the execution of the object program is
terminated, and control is returned to the system.
If a STOP statement with the RUN option appears in an imperative
statement, i t must appear as the only or last statement in a sequence of
imperative statements. All files should be closed before a STOP RUN
statement is issued.

When the literal option is used, the literal is communicated to the
operator.
The program may be resumed only by operator intervention.
Continuation of the object program begins with the execution of the nExt
statement in sequence.
The literal may be numeric or nonnumeric, or i t may be any figurative
constant except ALL.

EXIT Statement
The EXIT statement provides a common end point for a series of
procedures.

r----------------------------------------------------------------------,

I

Format
I
r----------------------------------------------------------------------~

I
I
I
paragraph-name. EXI'I tP~j.
I
IL______________________________________________________________________ JI

It is sometimes necessary to transfer control to the end point of a
series of procedures.
This is normally done by transferring control to
the next paragraph or section, but in some cases this does not have the
required effect. For instance, the point to which control is to be
transferred may be at the end of a range of procedures governed by a
196

PaLt IV -- Procedure Division

EXIT Statement
PERFORM or at the end of a declarative section. The BXIT statement is
provided to enable a procedure-name to be associated with such a point.
If control reaches an EXIT paragraph and no associated PERFORM or USE
statement is active, control passes through the EXIT point to the first
sentence of the next paragraph.
The EXIT statement must be preceded by a paragraph-name and be the
only statement in the paragraph.

Procedure Branching statements

197

MOVE Statement
DATA-MANI~ULATION

STATEMENTS

Movement and inspection of data are implicit in the functioning of
several of the COBOL statements. These statements are: MOVE, EXAMINE,
Mt~~~
MOVE Statement
The MOVE statement is used to trans-fer data from one area of storage
to one or more other areas:

r----------------------------------------------------------------------,

I

I

Format 1

~----------------------------------------------------------------------~

I
I

MOVE

lidentifier- 1

1

I

~Q

identifier-2

[identifier-31 ••.

I,

I
literal
I
Il ______________________________________________________________________ JI

r----------------------------------------------------------------------,
I
Format 2
I
~----------------------------------------------------------------------~

I

I,

MOVE

lCORRESPONDING!

identifier-1 Ta identifier-2

I
I

I
CORR
I
Il ______________________________________________________________________ JI

FORMAT 1: identifier-1 and literal represent the sending area;
identifier-2, identifier-3, .•• represent the receiving areas.
The data designated by literal or identifier-1 is moved first to
identifier-2, then to identifier-l Cif specified), etc.
An index data item cannot appear as an operand of a MOVE statement.
FORMAT 2: the CORRESPONDING option is used to transfer data between
items of the same name simply by specifying the group items to which
they belong.
Neither identifier may be a level-66, level-77, or level-aa data
item.
Data items from each group are considered CORRESPONDING when they
have the same name and qualification, up to but not including
identifier-1 and identifier-2.
At least one of the data items of a pair of matching items must be an
elementary data item.
Each subordinate item containing an OCCURS, REDEFINES, USAGE IS
INDEX, or RENAMES clause is ignored.
However, either identifier may
have a REDEFINES or OCCURS clause in its description or may be
subordinate to a data item described with these clauses.
i98

Part IV -- Procedure Division

MOVE statement

General Rules Applying to Any MOVE Statement:
1.

Any move in which the sending and receiving items are both elementary items is an elementary move. Each elementary item belongs to
one of the following categories: numeric, alphabetic,
alphanumeric, numeric edited, or alphanumeric edited (see "PICTURE
Clause" in "Data Division").
Numeric literals belong to the
category numeric; nonnumeric literals belong to the category
alphanumeric.

2.

When an alphanumeric edited, alphanumeric, or alphabetic item is a
receiving item:

3.

a.

Justification and any necessary filling of unused character
positions takes place as defined under the JUSTIFIED clause.
Unused character positions are filled with spaces.

b.

If the size of the sending item is greater than the size of the
receiving item, the excess characters are truncated after the
receiving item is filled.

c.

If the sending item has an operational
is used.

s~gn,

the absolute value

When a numeric or numeric edited item is a receiving item:
a.

Alignment by decimal point and any necessary zero filling of
unused character positions takes place, except when zeros are
replaced becau&e of editing requirements.

b.

The absolute value of the sending item is used if the receiving
item has no operational sign.

c.

If the sending item has more digits to the left or right of the
decimal point than the receiving item can contain, excess
digits are truncated.

d.

The results at object time may be unpredictable if the sending
item contains any nonnumeric characters.

4.

Any necessary conversion of data from one form of internal
representation to another takes place during the move, along with
any specified editing in the receiving item.

5.

Any move that is not an elementary move is treated exactly as
though it were an 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 is filled without
consideration for the individual elementary or group items
contained within either the sending or the receiving area.

6.

When the sending and receiving operands of a MOVE statement share a
part of their storage (that is, when the operands overlap), the
result of the execution of such a statement is unpredictable.

There are certain restrictions on elementary moves.
in Figure 33.

These are shown

Data-Manipulation Statements

199

MOVE Statement

.

---------------------------------T--T--T--T--T--T--T---T,-~T=~,T"".~=T""",= T.',...,..."."

I
Recei ving Field I
I I I I I I
I
I I I I I
I Source Field
I GR I AL I AN I ED I BI I NE I ANE I ID I EFI IF, Sl~iSR I
~--------------------------------- --+--+--+--+--+--+---+--+--+--+~-+-~i
IGroup (GR)
IY IY IY ly11Y11Y11Y1 ly1IY1IY~IY~ly11
~---------------------------------+--+--+--+--+--+--+---+--+~-+--+--+-~~
IAlphabetic (AL)
IY IY IY IN IN IN IY
IN IN IN ININI
~---------------------------------+--+--+--+--+-.-+--+---+~+~-+~-+""-+--i
I A.lphanumeric (AN)
I Y I Y I Y I y't I y't I y't I Y
I ytt I ytt I ytt I y't I y'tJ
~---------------------------------+--+--+--+--+--+--+---+"'~+~-+--=+~-+-,4
IExternal Decimal (ED)
IY1 1N ly 2 1Y IY IY IY2 IY IY jYjY IY J
~---------------------------------+--+--+--+--+--+--+---+--+~-+--+--+---~
IBinary (BI)
ly1 1N ly2 1Y IY IY IY2 IY,fYiY fY"lY 1
~---------------------------------+--+--+--+--+--+--+---+-"-+---+-...;+--+--~
INumeric Edited eNE)
IY IN IY IN IN IN IY
IN IN IN ININ, ,', I,:', ,:,:,';, ;,. , ,1:Y:1, f:,'~ 1t,Y2,',' 1 ,I,~, '1;,,'Yi ,t, ,\~"; 1,IIY2\J1IiY: Ul,Y;, JI,:Yi, t,",H,~', HIY-,' ,;1
~---------;-""-""'--!---""'---------~-+--f...J-If,--if-<-t+-l.jtl-'!-+H--f i'--l-r:...,...;-ti-l-HH-l11--~

I Interna;l;"

1E;xt:e,rnaLU :~loa;tij~~-\P,o~n1Iq~); t 1 !IJ:;~l{ll~ ill~,
~--~..:_.J~..J.J_~'~---...J-;~~...,.' ... -~"'; ....h--!..:,"';-:-l-:-Il, iI, · 1;

IJI ,JII~':lfl~ ~I
I,:.'!Ii~ 111~ !t1~:I'IN I t/ijlli;;'.;iti--rrlti-Hi
!

"I

"

',c

1~~terqa11 'F'l!o.a~i~ncj...Jpof,ntJ lq:rlE1)l t ~ 1,1 :llYl4'l~ !J!tfH~ 111~ \1 IllN'~

:'

.l:i,hl

~-;---,....,.-,----+--~~-.~-tl-.,.j-:"+"'~-i""-...,-\"'+-:~-ij; . !I : 'II ~ ,
' \ 1 , ' !,
I ~~erli!ng Nqnrepq:qt; (:~)': ' " , \ : " : ,i I:Yl1illN jl:()'~JY; ;jtY) :tlYl !I~ !'Ji~'i ~Y!'ll!
'I,

f;ijt~iH'~fl

;-IHfl-W,~

t~'!;,liYf.,H
~l--;~j ~: ia '; tL)!!,Lld 1;,Jl:11 ~-Ih-L!l~~tll ::\';,1"1 :"IJ;~;" ' : ,~;: ,::;,,~:~;:t:,:~
I ~~1;iAg; ~, ',,.t;~ ~', " '\;;'1, ,';:;l, .":1,, i ' i.il~, 4~!f~i~;I;~;'I'1 ldl Hi!ID1'i',l~<
jJ: ,;~1;N~11~,':1

~~-~h~,:!--l;f:, :.;~~~:;.J:; • ,* !:::t;',:;h~:~'~J:j~'~,;;::L:t7j T~I"'~J;r">l': it!;~1-~h:{~:,,_r'j' \' '~~t:~rt:r-J

I ~~~~~7,l\9;}?~s,~f"i~~~i~::,*N"!l"~1\t$,t,<'c';iJ"~~,1;~\\,t'''';~'~;fi'~rJ~~ "lt~:~;~L~I~~:~'~IJI~~:!J~:., I

~---------------------------------.1--.1.-~'"1--.1.--i--:1._-.1.---:.1.--;l.-~:J.--.1.- ..... ;L''''''-i

11 Move without conversion (like AN to AN)
I
1 2 0nly i f the decimal point is at the right of the least significant
I
I digit
I
13 Numeric move
I
I'tThe alphanumeric field is treated as an ED (integer) field
I
ISThe literal must consist only of numeric characters and is treated asl
IL ______________________________________________________________________
an ED integer field
JI
Figure 33.

200

Permissible Moves

Part IV -- Procedure Division

EXAMINE Statement
EXAMINE Statement
The EXAMINE statement is used to count the number of times a
specified character appears in a data item and/or to replace a character
with another character.

r----------------------------------------------------------------------,

I

I

Format 1

t----------------------------------------------------------------------~

I
I
I

I
i
literal-l
EXAMINE identifier TA~LYING
I
LEADING
f
I
I
I
i
[REPLACING BY literal-2J
I
I
lI ______________________________________________________________________ JI

l

~iIL FIRSTl

r----------------------------------------------------------------------,

I

I

Format 2

t----------------------------------------------------------------------~

I

:
I

EXAMINE identifier REPLACING

f~~ING
FIRST
UNTI~

!

I

II

literal-l

I
I

FIRST

BY literal-2
I
Il ______________________________________________________________________ JI

In all cases, the description of identifier must be such that its
usage is display (explicitly or implicitly).

When identifier represents a numeric data item, this data item must
consist of numeric characters, and may possess an operational sign.
Examination starts at the leftmost character and proceeds to the right.
Each character is examined in turn.
If the letter ·S· is used in the PICTURE of the data item description
to indicate the presence of an operational sign, the sign is ignored by
the EXAMINE statement.
Each literal must consist of a single character belonging to a class
consistent with that of the identifier; in addition, each literal may be
any figurative constant except ALL. If identifier is numeric, each
literal must be an unsigned integer or the figurative constant ZERO
(ZEROES, ZEROS).
When Format 1 is used, an integral count is created which replaces
the value of a special register called TALLY, whose implicit description
is that of an unsigned integer of five digits (see "Language
Considerations n ) .
Data-Manipulation Statements

201

EXAMINE Statement
1.

When the ALL option is used, this count represents the number of
occurrences of literal-l.

2.

When the LEADING option is used, this count represents the number
of occurrences of literal-l prior to encountering a character other
than literal-l.

3.

When the UNTIL FIRST option is used, this count represents all
characters encountered before the first occurrence of literal-l.

Whether Format 2 is used, or the REPLACING option of Format 1, the
replacement rules are the same. They are as follows:
1.

When the ALL option is used, literal-2 is substituted for each
occurrence of literal-l.

2.

When the LEADING option is used, the substitution of literal-2 for
each occurrence of literal-l terminates as soon as a character
other than literal-1 or the right-hand boundary of the data item is
encountered.

3.

When the UNTIL FIRST option is used, the substitution of literal-2
terminates as soon as literal-lor the right-hand boundary of the
data item is encountered.

4.

When the FIRST option is used, the
replaced by literal-2.

fir~t

occurrence of literal-l is

Specific EXAMINE statements showing the effect of each statement on
the associated data item and the TALLY are shown in Figure 34.

r---------------------------------------------T--------T-~-----T-------,

1
1

I

1
1

EXAMINE Statement

1
I
1
IITEM-l
I (Before)

1
1
I
I Data
I (After)

I Result-I
ling
1
I Value I
lof
I
I rALLY I

~---------------------------------------------+--------+-------+-------~

lEXAMINE ITEM-l TALLYING ALL 0

1101010

1101010 I

3

1

r---------------------------------------------+--------+-------+-------1
IEXAMINE ITEM-l TALLYING ALL 1 REPLACING BY 0 1101010 1000000 1
3
I
~---------------------------------------------+--------+-------+-------~

/EXAMINE ITEM-1 REPLACING LEADING U*R BY SPACE/**7000

I

7000 I

+

I

r---------------------------------------------+--------+---~---+-------1

IEXAMINE ITEM-l REPLACING FIRST n*R by n$n

1**1.94

1$*1.94 I

+

1

k.,. . .,--------------------------------------------.1.-----___ .1. _______ .1. _______ ~

1+\
unchanged
L______________________________________________________________________
JI
Figure 34.

202

Examples of Data Examination

Part IV -- Procedure Division

.

..' .~ . ";~:', .

. \!.. ;;

. .... .' '. . . . ':"~ ..... :(>::~,'~,ii!;~;t¥~[~tl~i'~;;!0~1~~f.,l,/ ~:,;,.

, ,The :TRANSFORM stateIrie"n't''''';is·.''i'fiSecr ·;t·o.·a,l~r:~aq;l~~~:f~nfJH J:h:;;"a" .;;.' ,

. . . '.: . '
:1:

..

~figq:ra~~V~-(£Qnsta:nt-1j' il. . :.;.'.: ·~

' .

T'

lnon~uI1le:r1i'C-literal-l.{

~:t··

," d·;

!:ideQt:.i:ei~r~·l.

··t'

'!

',:1.::

.·~r

:J':.
•...•.
{ . '.
'~

: •. TO.
.... .....

•

i

<'~,,:.

, . ·....1.·.':.·,
tz'

<;

,

····tdij\-~~~L\-+~~~~~c~:~--_·.·.'-_L~'-i_j;/~;2~i:;;.i'-j~L' •.-d"',"-c,:. U_. .JDi.-U_JI;
•

':'.

••

" •

' ' <

.~.

;;.

~.

•<

""

'

oft.:,..t.,<'

.......a~eIltifier~3. ,.·';rrl~·~t.re~r~~e~··t:····~rr.:eiemerita~i::·~lP~·~tJ~ti.d,::,··a·£f>ll.~Ildm~J!·l.c;.·>.·:;!"

:.oi;n:umerie,.edi,ted: item'.or·,a:group':.i:t:,enL. ' ... .. , ," . '

': " .. :.'.' .'., ":'"

:. .: :.:. '.:.'. . . . :":\.'.' "': : :'. . . .',:~:.:;'.:.:.'..;: :. ',':'.':'.:.<.,'.\., . . '. . .:';:.. . ',:":' \:::. .,. ,"':;..":, ~.. . '. .~ .' :'.:,:~..~": .'.. ,.; . '.

>.

~

" ".:'T}re·•.'.q·ompinat,ioI1; .. o.f.·, t:h~ .;FROM:~na ... TP,.·pptioris>d~tern:i:in;¢s:, what· :th~
:t~1;'allsfc)rmat·;i()n,rule·is~

..........

....

;:";.l;\

.... :':....,.: . ".' ::".'\;::

.,

'.' ' .. ~', ~",':f

'The, fol.+owing r,ules pe,rtain .to l;..J:.l~.t?l?e+·a.n'd.s.· ··o.f',the' "FRO~~:and:':};r()
'options: '.,
.
. ", ','
..
• ,v

,

y

:\:.:::j:.\:·,>.·. . ~··. .'~.ha:·ra6·~~~.···ina:.~··;.·~bt···:.·:b~··.···t:.ep·e~t~(i.:.~···i'ri. ·•. n~fintimer:~·c~···i~·tei~i~.·i:.····o·~. :···ih.,····~.tie'::.·,:,,::·

;,>.:.:::.;·. ;.:a;-:ea:;def.;int:d:.:J:~y,.iden1::ifit:~.~~t;,

'~t,.a

:.:·~\':,',:.,·::.:r,:es,\lH:s:::·V1fJ:J;j~:l?·~:Ullpred];ct~~le •. "'.'

·'·:: ..·.4:':.:... ·:·Th~.'·~'~·l~~~~le
,

,character is .repeated" the
.

."'::,

.

.

. <".~; ~ .

.

~.

.

.,

. .

.;

. . <',':.. '

'~~~urati~~, Gonst~~t~.'aie; .. ~mRo"" ZER~ES;' Z~~dS,':';' ,:, .~,:~

",SPAC,£,,';SPAGJ;:S', ·?U?TE". QOO.TE·S, Hi~B-v~LUE,:'
, , a·nd"LOW"':VALUES...
. " ' . , ".
h' :
,

',j. :....

,.

HTGfI-VALtJES,::'LOW:"VALUE, ;' ,>'

~;

.

... ' : .z':
.; i:~':'.

. ..wh¢n·eith~r'identifie.r";lor identifier:: 2 . appears as an opetahdof th~.\.
. $Pt:cif ic i:ransformation, tneu$er· can change the.transformationrule. at";.:
·'.object time'.. '
.

·of

Examples of data transformation are given in:F'ig\lre, 35;.

:theFR:OM.andTOoptions.ar~.shown i.n' F:ig\lre.·36.

If .' any of the operands of a' TRANSFORM :stat.ement s'haie aiJart. oftheir'~
. stora'ge' (that· is, if the operaridsoverlap)., the result· of" the. execution
of such a statement is unpredictable.

r-------------------T---------------T.------------.---T-------------:----:-.---,
I
Identifier-3
I
I
I
Identifier-3
I~
I
(Before)
I
FROM
I
TO
I
(After)
I
~------.-::....-----..;.-----+------.---------+--..;..------------+-----...;.-~..;.----.,..----~

I

lb7bbABC
I
SPACE
l
QUOTE
I
1 n 7" "ABC
I
lb7bbABC
I
"17CB"
I
"QRST"
I
QbRbbATS
1
I
lb7bbABC
I
b17ABC
I
CBA71b
I
BCACC71b
I
I _____________
98YXW4321
I _______________
ABCDEFGHI
I __________________
IHGFEDCBA
L
IL _____1234WXY89
._:______ ...;. ______ .1._,..,
.L
.L
J."

I

Figure 35.

Examples of Data Transformation
Data-Manipulation Statements

203

TRANSFORM Statement
r----~------~---------Tr------------~---~---------~~-------------------,

I

I'

Operands

I

'Transformation Rule

~:----~----""'-------~--'-~--~----:------""-~""'--.--------~-------,.... ..----:--------~

IF'ROM '.
. . ' ; i r1 All characters in the data item represented byt
Ifigurative--constant-t1i
identifier-3 equal to the single character' I
ITt) .... '.
.
,l:j
figurative-constant-l are replaced by the
I
f
I fi g urative-constant-2J ' single character fjullrative-constant-2.
J

tt

,t~

.

,I

f
I

1*

itFROM;.
'
,
, IlAII characters in lhedata item represent'ed bYI
!Jfigurative-constant""lJ~.
identifier-3 equal to the single character

>]TO

.'

.'

':I~

.

figurative~constant-l 'are replaced by the
single character nonnumeric....;literal-2.

;lnonnumer.ilc-literal~2'.",~!

' . ri

.

~t

il
~,tFROM .

.,

I
q f
; 1;1, All characters inthe~ata. item repre~ented by: I

I

'"

;

··r.

!'lfig.uiat,ive-cohstailt-ll::
~ITO'

t

r·.

.'

~ fidentifier-2
~"

identifier-3 equal to thesingTe character
figurative;":constant-lare replaced by tbe;t
single character represented by
,,
i3entifier- 2 .
t,
,:,

' 'j;r

. ......

' I,~

. f ~~,

.

H t l~

HFr

I
I ~ll characters in the data item .repI:"esented byf
i
I ~, ' identifier-3 that are equal to any charactej;l
i ITO '.. . . . ' . ! 1\t innonnumeric-li teral-l are replaced by the' I
Ilfi(}urativ~-¢onstant-2~:
single character figurative-constant-2.
t
j'~;':;; I ~rH:
U~FROM

':

".

t

i
~no~Elumeric_literal"":l:

I:

!

".

J:'FRO~,: .. r;,L ".' ,

:ll~'

:.1. : .

tfi~m~~~er~~~:t.t~r~t~:l·: . ~

nonnumeric-litet;'~1,;2<~,

Nonnumeric-literal-l and
. must be ~qua~ in length or
~~~~~~~~~~-11 teral - 2 must

I

It~~~~r ,l,:~ ii!t~ " '~ iI~
be asingle
t1;~'~ 'J i'~~, r t";" i'!f~11~ tU
'11; the nonnumeric-literals are equal in
Ill'\! , tl'l!
It ~ . '\ ~length, any character in the data item

rl

~I:.~

' J- I { ~ ~ :i

~ f
I,i...,.t

i.:.'.",:.'.". '.

\"i.'.

'

I l,l'l} ~
ii

i,.~

ft~'~,::·'.,.I.,!.t
t.!·": ... ~
~l :). ~';
··.'.'H.',. . .•. •.........•....••...

",>l';";;i
H1i1:t.:f';.~.;~:

:~

'ii<

'·t.. i

.,.·:·,.....

J

I; ~

, f"
~.

,'.'

'1
nonnumeric-lit,eral-2
~s ,on~" ff·i
in
the data item repr:es,e~

'l'

,:,':

~.'t}'!

,

j

I
1\

,

;

by

i

t I ~ f ~U n'

1

~~ ~umeric-literal-2.

':f;

I

~.'.~.·<~iU."'bil;WH
. :,/. ~d•.
';.·.·~.:~~T~-~~~i;~;-(~;;~.,f oi-Ij,:' '~';1~7"p~r

~,<~:;'!~~;;\,;""'f\'

204

d,
"l

~! ill;I~ i ~f:i11fa41i.r~l1a:r~c~ers
yqe ~~ength of
11ii' n
~ !I
bl1 !lJ~nt~f~'er-3 that are equal to any,
,1
I'! l' ~! h~ ~: 1,~rJaid,ter appearing in non~Wneric-literal-l tT
111 ~' : ~~zJ.~ ~rl~placed
the single characte~ give,!)' t

~L~

.

'f

:t

c~a7"acter

!:! . h
~ I~ q
J,' ;

i:!!:!'~! ,nQ:n~~eriC-literal-2.

1.

rP.·i.': '.~

~represented by identifier-3 equal to a
in nonnumeric-literal-l is
freplaced
b¥
j ~f "correspond~ngthepos~ t~on of in the
,I

t; EI ~'i' i I U ~character

i.''-". . ~.~'
', .~" .... f."
I:,...
iii1j:

,if
;Hr'.l

Part IV -- Procedure Division

,.'

;'

",

i"',·.

i~""~ __ --:~~;"':-"""~+~-'-'-,;"'~;"'-r-;"::~-;'---':'-~""""-~--"-;"'--;"'--;"'--~~--'-;':'-';:-- __ --:.;..i'.-..i:;.....i..,..,..i-..i~

';~,;";o~'rands

I,'

I'

'"

__

,Transf,ormation Rule'

", I

,

'~-f--:--: -';";'~"';';':"':"'---;"'''''''';-+--'''''''';'~'---- __ - - -__ ..,.----__ -.;,...,.--..,.-..,. ..... ,,-,-:---~-"';- __ ~..J~ __ -".;..-:-,-,:':":'-t

lFR~ ""

" """

'r

"""

'Nonnume'ric-literal-land,"the dataj,tem , ' , ' ,'.:1
r'epresented by identif ier':' 2 must'beeqtia,l:inl
length or identifier__2 must repr~sent a : t
single characte:r it,em.
' I

't nonn\l1t\eriC'~literal~l ,t

T

ITO' ',:
'"
Jide:t1ti'f:i~r""2"

I
,I

t

I,
f'

',

If',~Orinumeric __literal':'l 'andidentifier-2ar€

L

't

'I

I"',
e,qual""in, length", ,aJlY',characte:r: 'represented 'I
l
l' );>t'ident'ifier7'"3"eqv.alt? a:cllfth,e:,dClt:a,,,i,te~:repre~entecl, by,t

.'" '

'I, ~ ,

1',>,,'"

ifl,ent:~fi~:r:'~ 2, :"i.s':,'OI)~'r'"all'cha:~acters',,~\ ",",,','<,\'

,';J,

, , ,1,'>',:,rep;c~sen,t~d"pY",'id€int~fier~3"tll~t,:"'4re .• ~qual,'>l
. ,',,',f"",'," ",'t?:"a~¥:'c~~racte'r',app~ar~n9 .,in,,', "",~,' /',,,, " :', ':>:>,',}
'>",:, ': l,c>",' " .no,nriumer,i~7).~ite:fa;l. -\1" (i]::'e."r,e,pla(:ed '. :hy,"~he" ", >~J

't ,

1':'" ,

r':," '
1 ','>'

"3l
J

t'~",,-,':'l'::'·,, :\:,::$'l:flgle,C):lCir,acter,~epr'~sent.ed ,by" " ' ,

"

"

"""

, ,,:"r,:':,':",','.iqelltif"ie'r':""'2',.,'

: ';, >',','<',l,"'::",:>:',

lFR~"",

, ..

"

. ",' '.'"

"'
"
,"

'

,'J'

' ,"

,',,':'"' "'",',\""r",<:1\fl,chara',I":",' iterR,ie,pr'e~~n~~,d'bY,i,de.ntJ,'fi~r-:l'>a,r¢,re-",'·',""',',}

J~':i9'~riltbTe-:-C!()1l9t:aIlt,~21,,'"

j"

t>',<\i,'<',', " , ' ,;.\' ',',1-:'>"

',1 '

",1'

I~;' .. ',

t

1,;"

'

' l ' , . ' , · .. , ' ,

,

....

"'1

,",':""""'"',',,,':':,,,,'::,:,;'>\~:i,

character.

"

:':1

,.a
'I .If, ,identi£,ier,--1 ' andnbnn'umeri,c-litera-l ~2 'are ,,;',1,
' ',," ",equal,in . ~~ngtll,; ",any, ,epqt:"q.qter, in', . '
','  '-"'.' , ,'.~;'f',·

'~iClen~tf:i.,e'i:-:~.i,s, ,,':r.:ePla~,~ti:,'ll:y",tge,'cQar';~~~R~;~i~il~~i;+~"o~;.>c',:.2ila
c.'

'l,,':,:''-''''

t,', '
'I

t

1
J,

',.··.l,:,;If:, . ~h¢,'lengt:l1··.()~ .noriJlUII\eri~ __ .l,i teiaT~3;.'~s'Qne,,,··' 'byidentifier":l' arer:eplaced,bY ,the single t
, 'I
character given in nonnume,ric,-literal __ 2.,
I

f

'F'

in ,the, da:ta':\.te~:C~pre~e,nted' by't
lidentifier.',.;l,
I
,ideIltifieJ:-Jequal ,to a, ,cha,racteriI)the
I'
VI~O
'
1.',
"da.tGiitemrepreseIlted, by, idelltifi,~r-l is
I
lidentifier:-2
j
replaced by" the, ,cl)aracter ~n ,the'
"1
I
,
corresponding position of the datai tem
' f
I
,
represented by identifier-2~' 'Identifier-l I
!
,
and identifier-2can be one or more
J
t
I
characters. but must be equal in
length.
L _______________ -" _____ .L __ "-_______ - - - - - - - - -____________
_______
.... ______'Ji
l'FROM'

t iAnycharact~t

;.,.;.,.~

Figure 36.

Combinations of FROM ,and TO

Op~ions

(Part 2 of

~)

Data-Manipulation Statements

205

OPEN Statement
INPUT/OUTPUT STATEMENTS

The flow of data through the computer is governed by the Disk
Operating System. The COBOL statements discussed in this section are
used to initiate the flow of data to and from files stored on external
media and to govern low-volume information that is to be obtained from
or sent to input/output devices such as a card reader or console
typewriter.

The Disk Operating System is a record processing system. That is,
the unit of data made available by a READ or passed along by a WRIrE is
the record. The COBOL user need be concerned only with the use of
individual records; provision is automatically made for such operations
as the movement of data into buffers and/or internal storage, validity
checking, error correction (where feasible), unblocking and blocking,
and volume switching procedures.
.
Discussions in this section use the terms volume aqd reel. The term
applies to all input/output devic~s. The term reel applies only
to tape devices. Treatment of mass storage devices in the sequential
access mode is logically equivalent to the treatment of tape files.
vol~

Note: The WRITE statement with the BEFORE/AFTER ADVANCING option is
referred to in some of the discussions that follow as the WRI~E
BEFORE/AFTER ADVANCING statement.

OPEN Statement
The OPEN statement initiates the processing of input, output, and
input-output files.
It performs checking and/or writing of labels and
other input/output operations.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------~

I
I
I

OPEN [INPUT {file-name

[REVERSED~

I

} ••• ]

WITH NO REWIND

I
I

I
I
I
~OUTPUT {file-name [WITH NO REWINQ] } ••. ]
I
I
I
I
[1-0 {file-name} ••• 1
I
L
I ______________________________________________________________________ JI

At least one of the options INPUT, OUTPUT, or 1-0 must be specified.
However, there must be no more than one instance of each option in the
same statement, although more than one file-name may be used with each
option. These options may appear in any order.

206

Part IV -- Procedure Division

1

OPEN Statement
The 1-0 option pertains only to mass storage files.
The file-name must be defined by a file description entry in the Data
Division. The FD entry for the file must be equivalent to that
specified when the file was created.
The OPEN statement must not specify a sort-file; an OPEN statement
must be specified for all other files. The QPEN statement for a file
must be executed prior to the first READ, SEEK, :;~~r{~ or WRITE
statement for that file.
A second OPEN statement for a file cannot be
executed prior to the execution of a CLOSE statement for that file.
The
OPEN statement does not obtain or release the first data record.
A READ
or WRITE statement must be executed to obtain or release, respectively,
the first data record.
When checking or writing the first label, the OPEN statement causes
the user's beginning label subroutine to be executed if one is specified
by a USE sentence in the Declaratives.

The REVERSED and the NO REWIND options can be used only with
sequential single reel files.
The REVERSED option may be specified only
for a file containing fixed-length (F mode) records.
Files with nonstandard header labels must not be opened for reversed
reading unless the last header label is followed by a tape mark.
For tape files, the following rules apply:
1.

When neither the REVERSED nor the NO REWIND option is specified,
execution of the OPEN statement causes the file to be positioned at
its beginning.

2.

When either the REVERSED or the NO REWIND option is specified,
execution of the OPEN statement does not cause the file to be
repositioned.
When the REVERSED option is specified, the file must
have been previously positioned at its end. When the NO REWIND
option is specified, the file must have been previously positioned
at its beginning.

When the REVERSED option is specified, subsequent READ statements for
the file make the data records of the file available in reversed order;
that is, starting with the last record.
If an input file is designated with the OPTIONAL clause in the File
Control paragraph of the Environment Division (sequential file
processing), the clause is treated as comments. The desired effect is
achieved by specifying the IGN parameter in the ASSGN control statement
for the file.
If the file is not present, the first READ statement for
this file causes control to be passed to the imperative statement in the
AT END phrase.
The 1-0 option permits the opening of a mass storage file for both
input and output operations. Since this option implies the existence of
Input/Output Statements

207

'Ii

tne file, it cannot be used if the wass storage file is being initially
created.
When the 1-0 option is used, tIle execution of the OPEN statement
includes the followin~ steps:
1.

The label is checked.

2.

The user's label subroutine, if one is specified by a USE sentence,
is executed.

3.

The label is written.

A file may be opened as I~PUT and OUTPUT and 1-0 in any order (with
intervening CLOSE statements wi th01]t +:he U~H':!:' or REEL Cftion). However"
an-indexed-file may not be opened QUTPUTaridINPU'I orI~C wit.hIn the
same program.

-- .
START Statemen.t
The STPRT statement initiates processing of a segment of a sequentially accessed indexed file at a specified key.

r----------------------------------------------------------------------,
I
Format 1
I
t----------------------------------------------------------------------~

I
I

I

START file-name INVALID KEY imperative-statement

IL______________________________________________________

~

I
I

_______________ J

r----------------------------------------------------------------------,
I
Format 2 (Version 3)
I
t----------------------------------------------------------------------~

I
I
:

STAl"aI)d,··.··~tl.E!',;ASSJG~;;,~

... ~,la'l:i,~~,,:'~y~~t,~,(Il7,n~~t'.··s:~~(:,:~tl'i~,:;~.I'(i:9"r,c;l?,~~:,'9~,:,.~c;T1,a?~1¥:;,~Cc:ef:;'s~~,':pi:r,,~C'~,.·.~·4-1e~'~
,:.In:.!':WR'I.~~'~'S,,~?i,'t:-:ement:' ..,' ':. < ,,;~:,.
.,
:' ',>:\, ':. ':,:',,',,':,:,',:",. ,'" ":,.• ,,,,\,-,:, ::". ':; ", ',',':,';>','"

ACCEPT Statement
The function of the ACCEPT statement is to obtain data from the
system logical input device (SYSIPT), or from the CONSOLE.

r----------------------------------------------------------------------,

!

I

Format

~----------------------------------------------------------------------1

I

I

I
I

ACCEPT identifier [FROM

I
I

S.YSlP$,>;,
):CONSOLE""
mnemonic-nameS

l

I
I

IL ______________________________________________________________________ JI

Identifier may be either a fixed-lengttlg;r?~~ item or anelemE!ntary
alphabetic, alphanumeric, external decimali.:;~~,,~}tt;:~:r:_~:1,fJ:9atin:g,~p():fP;t
item. Identifier may not be any Special Register except TALLY.
rhe
data is read and the a~propriate number of characters is moved into the
area reserved for identifier. No editing or error checking of the
incoming data is done.
If the input/output device specified by an ACCEPT statement is the
same one designated for a READ statement, the results may be
unpredictable.
Mnemonic-name may assume either the meaning SYSIPT or CONSOLE.
Mnemonic-name must be specified in the Special-Names paragraph of the
Environment Division. If mnemonic-name is associated with CONSOLE,
identifier must not exceed 255 character positions in length. If the
FROM option is not specified, SYSIPT is assumed.
When an ACCEPT statement with the FROM mnemonic-name for CONSOLE
option ·.~FROM ,CONSOtE is executed, the following actions are taken:
Input/Output Statements

219

DISPLAY Statement
1.

A system generated message code is automatically displayed followed
by the literal nAWAITING REPLY".

2.

Execution is suspended.
When a console input message is identified
by the control program, execution of the ACCEPT statement is
resumed and the message is moved to the specified identifier and
left justified regardless of the PICTURE.
If the field is not
filled the low-order positions may contain invalid data.

If mnemonic-name is associated with SYSIPTdl:f,it~beFiloM';S'¥l~;rdpijj:;oip£liQn
is specified, an input record size of 80 is assumed.
If the size of the
accepting data item is less than 80 characters, the data must appear as
the first set of characters within the input record; any characters
beyond the length of the accepting identifier are truncated.
If the
size of tne accepting data item is greater than 80 characters, as many
input records as necessary are read until the storage area allocated to
the data item is filled.
If the accepting data item is greater than 80
characters, but is not an exact multiple of 80, the remainder of the
last input record is not accessible.

DISPLAY. Statement
The function of the
device.

DISPL~Y

statement is to write data on an output

r----------------------------------------------------------------------,

I

Format

I

~----------------------------------------------------------------------~

II
I
I
II

:

DISPLAY

jliteral-1!
identifier-1

j

C:ONSOLE~

.•

SYSPCH _ .,

[uPON~~~;

!

[literal-2]

II

identifier-2

I
I
II

1

I

I
. mnemonlc-name
I
L
I ______________________________________________________________________ JI

Mnemonic-name must be specified in the Special-Names paragraph of the
Environment Division. ~illemonic-name may be associated only with the
reserved words CONSOLE, SYSPCH, SYSPUNCH, or SYSLST.
When the UPON option is omitted, the system list device- (SYSLSr) is
assumed.
A maximum logical record size is assumed for each device. For
CONSOLE line •. Any combination
",;0£ t;l,le;<=haracterp>f~pnl't~EBCb~~ set maY,.be, :in~;Luded ..inArea ,A and_
;::~l:"e'a.':'B::rof:that !:ine~::;' .Tbe,~"a$~,~;r:~sk a-rid .the·· characters :\oIi11 .,beproduced

;'9n ·t'ljl.e'\,!isting,
~

234

-

.

;!bt1:tt's~ve:;no;l;otb.er
! , ..t"

~

, ,.'

Part IV -- Procedure Division

purpo&e.

.

PART V --

SPECI~L

FEATURES

• SORT FEATURE

• REPORT WRITER FEATURE

• TABLE HANDLING FEATURE

•

SEG~ENTATION

• SOURCE

FEATURE

PROGR~l

LIBRARY FACILITY

Special Features

235

Sort Feature -- Description
SORT FEATURE

The COBOL programrr~r can gain convenient access to the sorting
capability of the system sort/merge program by including a SORT
statement and other elements of the Sort Feature in his source program.
The Sort Feature provides the capability for sorting files and including
procedures for special handling of these files both before and after
they have been sorted. Within the limits of object-time storage, a
source program may have any number of SORT statements, and each SORT
statement may have its own special procedures.
rhe basic elements of the Sort Feature are the SaRI' statement in tne
Procedure Division and the Sort-File-Description (SD) entry, with its
associated record description entries, in the Data Division. A sorting
operation is based on sort-keys named in the SORT statement. A sort-key
specifies the field within a record on which the file is sorted.
Sort-keys are defined in the record description associated with the SD
entry. The records of a file may be sorted in ascending or descending
order or-in a mixture of the two; that is, the sort-keys may be
specified as ascending or descending, independent of one another, and
the sequence of the sorted records will conform to the mixture
specified. Additional information on the Sort Feature can be found in
the programmer's Guide.'
Note: Language considerations for an ASCII-collated sort are given in
Appendix E.

ELEMENTS OF THE SORT FEATURE
To use the Sort Feature, the COBOL programmer must provide additional
information in the Environment, Data. and Procedure Divisions of the
source program.
The SORT statement in the Procedure Division is the primary element
of a source program that performs one or more sorting operations.
The
term "sorting operation" means not only the manipulation by the Sort
Program of sort~work-files on the basis of the sort-keys designated by
the COBOL programmer, but also includes the method of making records
available to, and retrieving records from, these sort-work-files.
A
sort-work-file is the collection of records that is involved in the
sorting operation as it exists on an intermediate device(s). Records
are made available either by the USING or INPUT PROCEDURE options of the
SORT statement. Sorted records are retrieved either by the GIVING or
OUTPUT PROCEDURE options of the SORT statement.
In the Environment Division, the programmer must write SELECT
sentences for all files used as input and output to the Sort Program
a,n"d"for t,he s,ort-" fil, e., ,4f~,""':','"
,'"
";~f,w~,,"r4*~~,"',tl6b," +mUfi1~~,'~~,""';*"',:,',,,',~f,7,,","",,"

:00,~r,b",,~~\.~~'t~~~m.
~,~:,~.,~ ~~~nEi~J:1;ij.~;,li.~,~~,
:'t . ".'.. "
in- t '..
.'.:.,.<_ ..
~.·.· ...... :, ..• "b.:.t·.

__

.i

.. ~., ..,

:: ..

:.::; .... :.....•.... ~ ...: . : . :

'

..

'~.: •.

:

"oJ,'

:

',,"'

!

I

~. ~

;::.11 ..'..

1.:

••

J .. :

·:.,;.,btti.j/;. 1L:..h':; ..i-,~,: ....'<.tl •..• ',','

"

.. ",...

,..

,>.

....·.....'......i '

" I",
.

,.,'

,i ...,

,'Ililtl! i'" .~.1I1·

.:.

".:."'"

,••,.,'".,

· ". I> . '

. >"":" "..

~l'
"
•. '11t

'

.

..... .....'/

'

'

.

......

..

"

...

..

..

'

,'

.......

.•.

'.,

.• ,"{

,

,:'.'

"",.
...."

................
..,',.....,.. ,..;'

'''

~'

"',.

<4.

.',',.

'........'..... '. '.

>.',

i,>::" . ...,.

<':;:';'.' ::..;- •.•. . •. .

'".'.

,;...

,"'. ,............ cTS.·.·,··.·,·.··.·.· . ., "."".""

·. . . . ,'. '. ,. ,. ,.,....._:: ~;-2~~,<:i .:
:: ",:~i

•. • '.'..'.

TJtI:l,.s "':; ;:',

"".

•. . "' ..,..w,.}; .
_.,~ , j /

'.;:.:, > ,
""','

,~. ".,".......
" ". . .,' 'in.·,.
,
C>( iii
. . ' /i . ·. i':
. .
<,'.,".'.....
""',::
At the "
'
"'

· effe.ct,the ,'.

r () . . .'. . .

<. •.,

ii it

". '

,>,,,,- ...•,.,. '

)i}'

;,;,~ ,;;;..;....
, .'., " • .

". . ' . \ . , · . '•• ,',< . . .<,.",i·

.

\>'r\ i>i .','•. , " " ,
,.,.' '".;.... •. ,,'" ",.....i, '. . . .'. '".,..'.. , ,< • .•.

i',"·i·'. . ' < ) < . , { ,

. . .::

:".', , ',',':::; .,

operation' 'o£i.ilo t:{~'6'
SAME RECORD/SORT AREA Clause
The SAME RECORD/SORT AREA clause specifies that two or more files are
to use the same storage area during processing.

r----------------------------------------------------------------------,
Format
I

I

~----------------------------------------------------------------------~

I

I
I
SAME
AREA
FOR file-name-l {file-name-2} •••
I
SORT
I
IL _____________________________________________________ - - - - - ____________ JI
I
I

1RECORD (

The RECORD option is used when only FD or mixed FD and SD files are
named. The named files share only the processing area of the current
logical record. Although several of the files may be open at the same
time, only the logical record of one of these files can exist in the
record area at one time.
The SORT option is used when only SD files are named. Its function
is to optimize the assignment of storage areas to a given SORT
statement. The system will handle storage allocation automatically;
hence, the SORT storage option, if given, will be ignored.
240

Part V -- Special Features

Page of GC28-6394-4, -5, -6 revised 12/03/76 by TNL GN26-0887
SD (sort-file description) Entry
DATA DIVISION CONSIDERATIONS FOR SORT
In the Data Division the programmer must include File Description
entries for files that are input to or output from the Sort,
sort-file-description entries which describe the records as they appear
on the sort work files, and record description entries for each.

FILE SECTION
The File Section of a program which contains a sorting operation must
furnish information concerning the physical structure, identification,
and record names of the sort work file.
This is provided in the
sort-file-description entry.

'Sort-File Description
A sort-file-description entry must appear in the File section for
every file named as the first operand of a SORT statement.

r----------------------------------------------------------------------,
I

I

Format

~----------------------------------------------------------------------~

I

SD sort-file-name

RECORD IS

[DATA

l

RECORDS

l

ARE~

data-name-1 [data-name-2] .•. J

[RECORD CONTAINS [integer-1 TO] integer-2 CHARACTERS]

There must be a SELECT sentence for sort-file-name that describes the
system-name for the sort work file.
Sort-file-name is also the name
specified in the SORT statement.
The

Sort Feature

241

Page of GC28-6394-4, -5, -6 revised 12/03/76 by TNL GN26-0887
Sort -- Procedure Division Considerations
The DATA RECORDS clause specifies the names of the records in the
file to be sorted. Data-name-l, data-name-2, ••• of the DATA RECORDS
clause refer to the records described in the record descriptions
associated with this SD.
The RECORD CONTAINS clause specifies the size of data records in the
file to be sorted. This clause is optional. The actual size and mode
(fixed or variable) of the records to be sorted are determined from the
level-Ol descriptions associated with a given SD entry. When the USING
and GIVING options of the SORT statement are used, the record length
associated with the SD must be the same length as the record associated
with the FD's for the USING and GIVING files.
If any of the SD data
record descriptions contains an OCCURS clause with the DEPENDING ON
option, variable-length records are assumed. Refer to "Data Division"
for the format assumptions that are made by the compiler when the
RECORDING MODE clause is not specified.
Both the DATA RECORDS and the RECORD CONTAINS clauses are described
in "Data Division."

PROCEDURE DIVISION,CONSIDERATIONS FOR SORT
The Procedure Division must contain a SORT statement to describe the
sorting operation and, optionally, input and output procedures.
rhe
procedure-names constituting the input and output procedures are
specified within the SORT statement.
The Procedure Division -may contain more than one SORT statement
appearing anywhere except in the declaratives portion or in the input
and output procedures associated with a SORT statement.
Note: If DISPLAY or EXHIBIT is used in an input or output procedure
of a SORT verb, each time DISPLAY or EXHIBIT is executed SYSLST will
be opened since it is closed by SORT. To achieve a good performance
of a COBOL program, the DISPLAY and EXHIBIT verbs should only be used
for debugging purposes in input or output procedures for SORT.
SORT Statement
The SORT statement provides information that controls the sorting
operation. This information directs the sorting operation to obtain
records to be sorted either from an input procedure or the USING file to
sort the records on a set of specified sort keys, and in the final phase
of the sorting operation to make each record available in sorted order,
either to an output procedure or to the GIVING file.

242

Part V

special Features

SORT Statement

r----------------------------------------------------------------------,
fu~rt
I

I

~----------------------------------------------------------------------~

I
DESCENDING~
I
KEY {data-name-l} •••
SORT file-name-l ON
I
ASCENDING
I
I
DESCENDING
I
l KEY {data-name-2} ••. 1 •••
[ON
I
ASCENDING
f
I
I
(INPUT PROCEDURE IS section-name-l [THRU section-name-21}
I
tUSING file-name-2
J
I
I
I
OUTPUT PROCEDURE IS section-name-3 [THRU section-name-41}
I
{ GIVING file-name-3
_
I
IL _____________________________________________________________________ _

l

l

File-name-l is the name given in the sort-file-description entry that
describes the records to be sorted.

ASCENDING and DESCENDING: The ASCENDING and DESCENDING options specify
whether records are to be sorted into an ascending or descending
sequence: respectively, based on one or more sort keys.
Each data-name represents a "key· data item and must be described in
the records associated with the sort-file-name.
At least
options may
records are
then within
represented

one ASCENDING or DESCENDING clause must be specified. Both
be specified in the same SORT statement, in which case,
sorted on data-name-l, in ascending or descending order! and
data-name-l, they are sorted on the KEY data item
by data-name-2, in ascending or descending order, etc.

Keys are always listed from left to right in order of decreasing
significance, regardless of whether they are ascending or descending.
The direction of the sort depends on the use of the ASCENDING or
DESCENDING clauses as follows:

1.

When an ASCENDING clause is used, the sorted sequence is from the
lowest value of the key to the highest value, according to the
collating sequence for the COBOL character set.

2.

When a DESCENDING clause is used, the sorted sequence is from the
highest value of the key to the lowest value, according to the
collating sequence of the COBOL character set.

Sort keys must be one of the types of data item listed in Figure 43.
corresponding to each type of data item is a collating sequence that is
used with it for sorting.
A character in the EBCDIC collating sequence (used with alphabetic,
alphanumeric, etc., data items) is interpreted as not being signed. For
fixed-point and internal floating-point numeric data items, characters
are collated algebraically (that is, as being signed).
Sort Feature

243

SORT Statement

r-------------------------------------T--------------------------------1
IType of Data Item Used for Sort Key I
Collating Sequence
I
~-------------------------------------+-----------------------~--------~

I Alphabetic
I Alphanumeric
INumeric Edited
I Group
IExternal Decimal
I Bina

I EBCDIC
I EBCDIC
I EBCDIC
I EBCDIC
I Zoned Decimal
Fixed Point

l:pk:.i:i,1h:t::

I
I
I
I

. " . . ;.

..~:::, ';..

.

I
I
I

. . L~~~-'iL011t{~lif0t1gCJ

I
Figure 43.

SORT Collating Sequences Used for Sort Keys

The EBCDIC collating sequence for COBOL characters in ascending order
is:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.

<
(
+

$

*
/
,

>

(space)
(period or decimal point)
(less than)
(left parenthesis)
(plus symbol)
(currency symbol)
(asterisk)
(right parenthesis)
(semicolon)
(hyphen or minus symbol)
(stroke, virgule, slash)
(comma)
(greater than)

a~It4 .....~,~:_..9~~Di~~i:~~~~J"

15.
16.
17-42.
43-52.

=

(equal sign)
(quotation mark)
A through Z
0 through 9

(The complete EBCDIC collating sequence is given in IBM System/360
Reference Data, Order No. X20-1703.)
The record description for every record that is listed in the DATA
RECORDS clause of an SD description must contain the "key" items
data-name~l, data-name-2, etc.
These "key" items are subject to the
following rules:
1.

Keys must be physically located in the same position and have the
same data format in every logical record of the sort-file. If
there are multiple record descriptions in an SO, it is sufficient
to describe a key-in "only one of the record descriptions.

2.

Key items must not contain an OCCURS clause nor be subordinate to
entries that contain an OCCURS clause.

3.

A maximum of 12 keys may be specified.
keys must not exceed 256 bytes.

4.

All keys must be at a fixed displacement from the beginning of a
record; that is, they cannot be located following a variable table
in a record.

5.

All key fields must be located within the first 4092 bytes of a
logical record.

6.

The data-names describing the keys may be qualified.

244

part V -- Special Features

The total length of all the

SORT Statement
SECTION-NAME-1 AND SECTION-N~ME-2: Section-name-1 is the name of an
input procedure. Section-name-2 is the name of the last section that
contains the input procedure in the COBOL main program. Section-name-2
is required if the procedure terminates in a section other than that in
which it was started.

INPUT PROCEDURE: The presence of the INPUT PROCEDURE option indicates
that the programmer has written an input procedure to process records
before they are sorted and has included the procedure in the Procedure
Division as one or more distinct sections.
The input procedure must consist of one or more sections that are
written consecutively and do not form a part of any output procedure.
The input procedure must include at least one RELEASE statement in order
to transfer records to the sort-file.
Control must not be passed to the input procedure unless a related
SORT statement is being executed, because the RELEASE statement in the
input procedure has no meaning unless it is controlled by a SORT
statement. The input procedure can include any procedures needed to
select, create, or modify records. There are three restrictions on the
procedural statements within an input procedure:
1.

The input procedure must not contain any SORT statements.

2.

The input procedure must not contain any transfers of control to
points outside the input procedur~. ~~fuPn·~ ~ ~L
:i~pHIcl~~'~,~~~'S:~~',~~~~s, ~_~d::~~~

.,' 'J':~~ 'the execution of USE declaratives for label
handling and error processing are not considered transfers of
control outside of an input procedure. Hence, they are allowed to
be activated within these procedures.
t.

,;

!:~~

.,'

j

."

.t~'}~~'h~,;~~i~R:~·"·:;~:,';rq~t;.~n:d:j~E~q~J.cr;'}:",,

<'"

,;,~ ·flr'·:'*;'-,:,~'~.'~~;"~e~&=:,:;~P:;~~tit5~~~~~r~~!ftf~'~~c~::
.

j ) ' ., ,:t::':'~:Ij" ,.' ,%~';',;,>;~t+'::J:S;:"tf}"*=:)u,s~~ ,;q,',::r:;eSP9Il.s)j:pJl:~~t-y' '~?:"'~.:~'."

:lUiu: .1t!a,,"~~d~ptft,r·.,~dd~dU:r:e,,',aft,er'. "'exb::t:±ng'",,throil(:xt•.
't}se;r ciTld ".the, Sort, Feat\lr;~~':~,
J>e:r::fprmanc,e" 'i'J:,.; :,'l,':\',
:.:

..r~.

,L

:.:""'t;F:'L;+f,',, .

,. ". . The 'f'ix:st . three '.. :regi'ster\~ :/nIalY .:hav,e, ;~clqt)~.1;:. ·i:JLn:f:{ql:;nlCm.l~Qr~: jt:)t
thewat:."opj'ect: 'time j~~ .th~'u~",$:pq""".'.",",·:,...,...,,,,,,,,!,

:,.'()~,,',stat~in~nts··:S:uoh:.~~',~PVE;.:'::::lHd'YlWe,:r:·i:'
'!¥f~:,:l;:~,~s:" opera,ndS"irf'ACCEPTi; >q:r:SP,IJAYi',"

:l.n$o~mCit:~.oI,l;'in~st:.:,:oe':pa$~ed:';b~fQre:,'t~f.{:,

::l:-¢gfst~r::? "Gfre;':initi~liz e'd::t;;~,~er(> "b.y, j:~

,':af,tfe~':,a:'$ort':p:rocedur~,;:is:,'~~equ£e ()peratiox(~will:;Re':>i~rl ';the,~:eg~,$Bet:s: :~t.(",t;J~e":QE~Jl;ml'~':tg:i
"tint~s"'m,()ditie:Cl,~"";,,',, ;'~,;:,
,,':,~,::-,:,::,:':' ':: ':i';<'i:j:.~·:J.:? '~::, ,;", :',' ,:Y',

,'f~'~;:SoRT'"'FI1E':;SI.z,E is' the ~'riaime"pf': a
,.

.

.' . ~

. .

....

.

:'"

'.

..:

.

'.

. ' ! '.

.

.'

.

x.

:

. ' '.

binaciy,' "a~t~,: item ,'~hd~~'.·1,l?,~',0'111l,lUt
.

. (.

.

.

:.,'

" . ' . , :'

. : ".

~

." : '.

.".;. <",!

•

r

;59; {':~).',::Lt",j.S' use(i ,.;fpr:'J+h,e,,;estim,aJ:~l~d:numb~:r::::,()f,,:r:~C:?JJ::~q$':.i.
,t(),','be' S9r't,~g.,,':I,i: .. ~o.RT~ F:ILE~ ~TZ,~ 'j~s', (>rilittred "the ,1~9rt" :FE!at:,qr:'e
;as$~s ''"t:hcf,'t::thefil-e' contaTns,' ~he';max,itnulttnum~)~r:"pf,,:ieco,r:

, ,: ',C,(p;l'.':b~, :fJl"O~eS~~d~:wi~h '::tb~', 'a;y(i'i,+,Cib:J.;e'99r~'::,si:z:e ';a'nd,";nJJmh~i:::,Ct~
uIl'its'.,: . ':;.If', 'fhe estim?, te··· ~c~eds ;:the m~x?::muitl, ,:t:he, ,estl.llla t~ . willi~lnored~:: ,::'
'
s6wr~,GORE-~,~E 'is' :the: na.m,e;o~,'a 'binftrY,d,G\ta,j,.telTI:"w~o,S~,P~C.TU~~
'$9' for the file(s) on which the report(s) is to be
produced. The REPORT clause cross references the description of Report
Description entries with their associated File Description entry.

r----------------------------------------------------------------------,
,
,
~----------------------------------------------------------------------~
,
,
fur~t

IREPORT IS

I

report-name-l [report-name-2J •••

I,

I
, ______________________________________________________________________ JI
L

",

254

REPORTS ARE

Part V -- special Features

'RECORDINGMODE/DATARECORDSjRECORD CONTAINS Clauses
Each File Description entry for standard sequential OUTPUT files
within the File Section may include a REPORT clause containing the names
of one or more reports. These reports may be of different sizes,
formats, etc., and the order in which their names appear in the clause
is not significant.

Each unique report-name listed in an FD entry must be the subject of
an RD entry in the Report section. A given report-name may appear in a
maximum of two REPORT clauses.

, . ,

~:'

<,

,

Th~··.:.·UCQRDr~G.·:·.M01)E~ cla:~se ~i~~

us.e"d to

s~p·~c~'fy' the··:··~f.Qrmat:>

of

t·h~

'logical 'records withIIi "the ',file.
If t:h~S' clause,:is,orr.itted t the'"
:'roec9rding mode is, determined as d~sc:r::;ibed.' i~'~nDa:t~:1'"D.tvfs'iori.'~ ,:'

,,'

',., ,

,;'-

,:.'",t~"th~:'D,~TA,·t{E<::ORPSclause is: s'pecif.ied, artd, the' ii'le'is used for
"'()1itput .. ",t,l1e':~fTER.·AnVANeING 'option' inus,the: used wpen w'ri.tin~~~-r~~'~~~:-<,~~-?:~~~~F~;:;l~i\;~!,:reg'j{t~,J:~iit

itmE-rCduNTE~'il:{not;laJ~t,t~r¢d"

"':"

,

,:; i,'~ ,':

'

. '

'.,

••

~

'r ,),:' :,':
,

.'

r:}':",\:J,""~;':"~",:,";)':,~:': ":,',: ":",":::~,1<:",:.", ,;': ":-" ','.
r~'
J';'~:'J,":.',iTh~,:',;~c,t:i()Il,'O£, th~ ,NE~T GROUP clqUSe,' ~f :,Jp,~,i~~e'il;r::$
J;\':;i:::~ql:01i.'p'g.~$'qript±on,·, is
l:.J_~:,:.~·,··~.~.:.:~·,·;i~""

"',<> ..

;~""'~""~':"":"

SPECIAL REGISTERS:

.....,. '.

nullified'
"

":,:'

,<

",~

,"<

,:,': ':

~.

<" '~·h,.~' ,',~.>',,\<~~~~.

,;.·,r'";:~,, ,';',":i"y'
' ';'<~,'::".'<'>

"{)~'S:',,

;',j ,

:~~.',:,·th,~':,\rep~,~~~,::"
~.,~~

, ,.',:,\','

,,"<

PAGE-COUNTER AND LINE-COUNTER

The fixed data-names, PAGE-COUNTER and LINE-COUNTER, are numeric
counters automatically generated by the Report Writer based on the
presence of specific entries; they do not require data description
clauses. The description of these two counters is included here in
order to explain their resultant effect on the overall report format.

PAGE-COUNTER
A PAGE-COUNTER is a counter generated by the Report Writer to be used
as a source data item in order to present the page number on a report
line.
A PAGE-COUNTER is generated for a report by the Report Writer if
a PAGE-LIMIT clause is specified·in the RD entry of the report.
The
numeric counter is a 3-byte COMPUTATIONAL-3 item that is presented
according to the PICTURE clause associated with the elementary item
whose SOURCE is PAGE-COUNTER.
If more than one PAGE-COUNTER is given as a SOURCE data item within a
given report, the number of numeric characters indicated by the PICTURE
clauses must be identical. If more than one PAGE-COUNTER exists in the
program, the user must qualify PAGE-COUNTER by the report name.
PAGE-COUNTER may be referred to in Report Section entries and in
Procedure Division statements. After an INITIATE statement,
P~GE-COUNTER contains one; if a starting value for PAGE-COUNTER other
than one is desired, the programmer may change the contents of the
PAGE-COU~TER by a Procedure Division statement after an INITIATE
statement has been executed. PAGE-COUNTER is automatically incremented
by one each time a page break is recognized by the Report Writer, after
Report Writer Feature

211

LINE-com~TER

Special Register

the production of any PAGE FOOTING report group but before production of
any PAGE HEADING report group.

LINE-COUNTER
A LINE-COUNTER is a counter used by the Report Writer to determine
when a PAGE HEADING and/or a PAGE FOOTING report group is to be
presented.
One line counter is supplied for each report with a PAGE
LIMIT (S> clause written in thc=RC=l?ort Dc=?c:ription entry (RD). The
numeric counter is a 3-byte _ i t e m that is presented
according to the PICTURE clause associated with the elementary item
whose SOURCE is LINE-COUNTER.
LINE-COUNTER may be referred to in Report Section entries and in
Procedure Division statements. If more than one Report Description
entry (RD) exists in the Report Section, the user must qualify
LINE-COUNTER by the report-name.
LINE-COUNTER is automatically tested
and incremented by the Report Writer based on control specifications in
the PAGE LIMIT(S) clause and values specified in the LINE NUMBER and
NEXT GROUP clauses. After an INITIATE statement, LINE-COUNTER contains
zero. Changing the value of LINE-COUNTER by Procedure Division
statements may cause page format control to become unpredictable in the
Report Writer.
The value of LINE-COUNTER during any Procedure Division test statement represents the number of the last line printed by the previously
generated report group or represents the number of the last line skipped
to by a previous NEXT GROUP specification.
In a USE BEFORE REPORTING, if no lines have been printed or skipped
on the current page, LINE-COUNTER will contain zero.
In all other
cases, LINE-COUNTER represents the last line printed or skipped.

278

Part V -- Special Features

Report writer -- Sample Program
SAMPLE REPORT WRITER PROGRAM
Figure 46 illustrates a Report Writer source program. The records
used in the report (i.e., input data) are shown after the STOP RUN card
in the program. Using the first record as an example, the data fields
are arranged in the following card format:

--~-

___

A0 0

~

02

~1

Department
Number

Number of
Purchases

1

1

A0 1 0 1

002 0 0

__ ! _____ l _______ _

Type of
Purchase

Month

Day

Cost

The decimal point in the cost field is assumed to be two places from
the right.

r----------------------------------------------------------------------,
000005 IDENTIFICATION DIVISION.
000010 PROGRAM-ID. ACME.
000015 REMARKS. THE REPORT WAS PRODUCED BY THE REPORT WRITER.
000020 ENVIRON~£NT DIVISION.
000025 CONFIGURATION SECTI~N.
000030 SOURCE-COMPUTER. IBM-360-F50.
000035 OBJECT-COMPUTER. IBM-360-F50.
000040 INPUT-OUTPUT SECTION.
000045 FILE-CONTROL.
000050
SELECT INFILE ASSIGN TO SYSOOO-UT-2400-S.
000055
SELECT REPORT-FILE ASSIGN TO SYS001-UT-2400-S.
1000060 DATA DIVISION.
000065 FILE SECTION.
000070 FD INFILE
000075
LABEL RECORDS ARE OMITTED
000080
DATA RECORD IS INPUT-RECORD.
000085 01 INPUT-RECORD.
PICTURE M.
000090
05 FILLER
PICTURE XXX.
000095
05 DEPT
PICTURE AA.
000100
05 FILLER
000105
05 NO-PURCHASES
PICTURE 99.
PICTURE A.
000110
05 FILLER
000115
05 TYPE-PURCHASE PICTURE A.
000120
05 MONTH
PICTURE 99.
000125
05 DAY-l
PICTURE 99.
PICTURE A.
000130
05 FILLER
PICTURE 999V99.
000135
05 COST
000140
05 FILLER
PICTURE X(59).
000145 FD REPORT-FILE
000150
LABEL RECORDS ARE STANDARD
000151
RECORD CONTAINS 121 CHARACTERS
000155
REPORT IS EXPENSE-REPORT.
000160 WORKING-STORAGE SECTION.
000165 77 SAVED-MONTH
PICTURE 99 VALUE IS O.
1000175
77 CONTINUED
PICTURE X(11) _________________________
VALUE IS SPACE.
L ___________________________________________
_
~

Figure 46.

Sample Program Using the Report Writer Feature (Part 1 of 4)

Report Writer Feature

279

Report Writer -- Sample Program

r----------------------------------------------------------------------,
000180 01 MONTH-TABLE-l.
000185
05 RECORD-MONTH.
000190
10 FILLER PICTURE A(9) VALUE IS "JANUARY "
000195
10 FILLBR PICTURE A(9) VALUE IS "FEBRUARY"
000200
10 FILLER PICTURE A(9) VALUE IS "MARCH
000205
10 FILLER PICTURE A(9) VALUE IS "APRIL
"
000210
10 FILLER PICTURE A(9) VALUE IS "MAY
"
000215
10 FILLER PICTURE A(9) VALUE IS "JUNE
"
000220
10 FILLER PICTURE A(9) VALUE IS "JULY
000225
10 FILLER PICTURE A(9) VALUE IS "AUGUST
000230
10 FILLER PICTURE A(9) VALUE IS "S~PTEMBER".
000235
10 FILLER PICTURE A(9) VALUE IS "OCTOBER "
000240
10 FILLER PICTURE A(9) VALUE IS "NOVE~rnER ".
000245
10 FILLER PICTURE A(9) VALUE IS "DECEMBER ".
000250
05 RECORD-AREA REDEFINES RECORD-MONTH.
000255
10 ~ONTHNAME
PICTURE A(9) OCCURS 12 TIMES.
000260 REPORT SECTION.
000265 RD EXPENSE-REPORT
000270
CONTROLS ARE FINAL MONTH DAY-l
000275
PAGE LIMIT IS 59 LINES
000280
HEADING 1
000285
FIRST DETAIL 9
000290
LAST DETAIL 48
000295
FOOTING 52.
000300 01 TYPE IS REPORT HEADING.
000305
05 LINE NUMBER IS 1
000310
COLUMN NUMBER IS 27
000315
PICTURE IS A(26)
000320
VALUE IS "ACME MANUFACTURING COMPANY".
000325
05 LINE NU~illER IS 3
000330
COLUMN NUMBER IS 26
000335
PICTURE IS A(29)
000340
VALUE IS "QUARTERLY EXPENDITURES REPORT".
000345 01 ~AGE-HEAD
000350
TYPE IS PAGE HEADING.
000355
05 LINE NUMBER IS 5.
000360
10 COLUMN IS 30
000365
PICTURE IS A(9)
000370
SOURCE IS MONTHNAME (MONTH).
000375
10 COLUMN IS 39
000380
PICTURE IS A(12)
000385
VALUE IS "EXPENDITURES".
000390
10 COLUMN IS 52
000395
PICTURE IS X(11)
000400
SOURCE IS CONTINUED.
000405
05 LINE IS 7.
000410
10 COLUMN IS 2
000415
PICTURE IS X(35)
000420
VALUE IS "MONTH
DAY
DEPT NO-PURCHASES".
000425
10 COLUMN IS 40
000430
PICTURE IS X(33)
1000435
VALUE IS· "TYPE COST CUMULATIVE-COST".
L______________________________________________________________________
J1
Figure 46.

280

Sample Program Using the Report Writer Feature (Part 2 of 4)

Part V -- Special Features

Report Writer -- Sample Program

r----------------------------------------------------------------------,

000440 01 DETAIL-LINE TYPE IS DE'l'AIL LINE NUMBER IS PLUS 1.
000445
05 COLUMN IS 2 GROUP INDICATE PICTURE IS A(9)
SOURCE IS MONTHNAME (MONTH).
000450
05 COLU~~ IS 13 GROUP INDICATE PICTURE IS 99
000455
000460
SOURCE IS DAY-l.
000465
05 COLUMN IS 19 PICTURE IS XXX SOURCE IS DEPT.
05 COLUMN IS 31 PICTURE IS Z9 SOURCE IS NO-PURCHASES:
000470
000475
05 COLUMN IS 42 PICTURE IS A SOURCE IS TYPE-PURCHASE.
000480
05 COLUMN IS 50 PICTURE IS ZZ9.99 SOURCE IS COST.,
000485 01 TYPE IS CONTROL FOOTING DAY-l.
05 LINE NUMBER IS PLUS 2.
000490
000495
10 COLUMN 2 PICTURE X(22)
000500
VALUE "PURCHASES AND COST FOR".
000505
10 COLUMN 24 PICTURE Z9 SOURCE SAVED-MONTH.
10 COLUMN 26 PICTURE X VALUE "-no
000510
000515
10 COLUMN 27 PICTURE 99 SOURCE DAY-l.
000520
10 COLUMN 30 PICTURE ZZ9 SUM NO-PURCHASES.000525
10 MIN000530
~MN 49
PICTURE '$$$9.99 SUM COST.·
000535
10 COLUMN 65 PICTURE $$$$9.99 SUM COST·
000540
RESET ON FINAL.
000545
05 LINE PLUS 1 caLUMN 2 PICTURE X(71)
000550
VALUE ALL "*".
000555 01 TYPE CONTROL FOOTING MONTH
LINE PLUS 1 NEXT GROUP NEXT PAGE.
000560
05 COLUMN 16
PICTURE A{14) VALUE "TOTAL COST FOR".
000565
05 COLUMN 31
PICTURE A(9)
000570
000575
SOURCE MONTH NAME (MONTH).
PICTURE; AAA VALUE "WAS".
05 COLUMN 43
1000580
05 INT
000585
000590
COLUMN 48
PICTURE $$$9.99 SUM MIN ••
000595 01 TYPE CONTROL FOOTING FINAL LINE NEXT PAGE:
05 COLUMN 16
PICTURE A(26)
000600
000605
VALUE "TOTAL COST FOR QUARTER WAS".
000610
05 COLUMN 45
PICTURE $$$$9.99 SUM ~
000615 01 TYPE PAGE FOOTING LINE 57.
05 COLUMN 59
PICTURE X(12) VALUE "REPORT-PAGE-".
000620
000625
05 COLUr-iN 71
PICTURE 99 SOURCE PAGE-COUNTER ..
000630 01 TYPE REPORT FOOTING
LINE PLUS 1 COLUMN 32 PICTURE A(13)
000635
000640
VALUE "END OF REPORT".
000645 PROCEDURE DIVISION.
000650 DECLARATIVES.
000655 PAGE-HEAD-RTN SECTION.
USE BEFORE REPORTING PAGE-HEAD.
000660
000665 PAGE-HEAD-RTN-SWITCH.
GO TO PAGE-HEAD-RTN-TEST.
000670
000675 PAGE-HEAD-RTN-TEST.
IF MONTH = SAVED-MONTH MOVE "(CONTINUED)" TO CONTINUED
000680
ELSE MOVE SPACES TO CONTINUED
000685
000690
MOVE M~NTH TO SAVED-MONTH.
GO TO PAGE-HEAD-RTN-EXIT.
000695
000697 PAGE-HEAD-RTN-ALTER.
000698
ALTER PAGE-HEAD-RTN-SWITCH TO PAGE-HEAD-RTN-SUPPRESS.
000700 PAGE-HEAD-RTN-SUPPRESS.
000705
MOVE 1 TO PRINT-SWITCH.
000710 PAGE-HEAD-RTN-EXIT.
000715
EXIT.
000720 END DECLARATIVES.
L ______________________________________________________________________
J
Figure 46.

Sample Program Using the Report Writer Feature (Part 3 of 4)

Report Writer Feature

281

Report Writer -- Sample Program

r----------------------------------------------------------------------,
1000722 NON-DECLARATIVES SECTION.
1000725
1000730
1000735
1000740
1000745
1000760
1000765
1000770
1000780
1000785
1000790

OPEN-FILES. OPEN INPUT INFILE OUTPUT REPORT-FILE.
INITIATE EXPENSE-REPORT.
READATA.
READ INFILE AT END GO TO COMPLETE.
GENERATE DETAIL-LINE.
GO TO READATAe
COMPLETE.
PERFORM PAGE-HEAD-RTN-ALTER.
TERMINATE EXPENSE-REPORT.
CLOSE INFILE REPORT-FILE.
STOP RUN.

I
1
1
1
1

1
1

1

AOO
A02
A02
A01
A04

02
01
02
02
10

A01

06 CQ329 04800

A0101
A010l
C0101
B0102
A0102

00200
00100
01600
00200
01000

1

1
1

1

IL__________________________________________________________________
A03 20 E0331 06000
Figure 46.

~

__ _

Sample Program Using the Report writer Feature (Part 4 of 4)

Key Relating Repo;t to Report Writer Source Program

the

(!»

In the key, the numbers enclosed in circles (for example,
relate
explanatio~ below to the corresponding output line in Figure 47.

The six-digit numbers (for example, 000615) show the source statement
from the program illustrated in Figure 46.
is the REPORT HEADING resulting from source lines 000300-000340.
is the PAGE HEADING resulting from source lines 000345-000435.
is the DETAIL line resulting from source lines 000440-000480 (note
that since it is the first detail line after a control break, the
fields defined with the GROUP INDICATE clause, lines
000445-000460, appear).
is a DETAIL line resulting from the same source lines as ~
In this case, however, the fields described as GROUP INDICATE do
not appear (since the control break did not immediately precede
the detail line).
is the CONTROL FOOTING (for DAY-l) resulting from source lines
000485-000550.
is the PAGE FOOTING resulting from source lines 000615-000625.
is the CONTROL FOOTING (for MONTH) resulting from source lines
000555-000575.
282

Part V -- Special Features

Report Writer -- Sample Program

®

is the CONTROL FOOTING (for FINAL) resulting from source lines
000595-000610.
is the REPORTING
000630-000640.

FOOTI1~G

resulting from source lines

Lines 000650-000715 of the example illustrate a use of USE BEFORE
The effect of the source is that each time a new page is
REPORTING.
started, a test is made to determine whether the new page is being
started because a change in MONTH has been recognized (the definition
for the control footing for MONTH specifies NEXT GROUP NEXT PAGE) or
because the physical limits of the page were exhausted.
If a change in
MONTH has been recognized, spaces are moved to the PAGE HEADING; if the
physical limits of the page are exhausted, "(CONTINUED)" is moved to the
PAGE HEADING.

Report Writer Feature

283

Report writer -- Sample Program

CI)~---------------------------ACME M~NUFACTUPTNr-

COMPANY

QUARTFRLY EXPENDITVRfS RfPrRT

~-------------------JANU~RY

~~MONTH

DAY

@--JANUARY

01

0-

DEPT

NO-PURCHASES

AOO
-A02
A02

2

EXPENDITUPES
TYPE

1

A
A

2

C

COST

CUMULATIVE-COST

2.00
1.00
16.00

~:~:;~!;;;*!~~*;;;:*:~~*!;~!***;*****************!;;;~~***********!;;;~~
JANUARY

Pl'~O.jASES

02

AOI
A04
A04

2
10
10

AND COST FOP. 1-02

22

B
A
C

2.00
10.00
80.00

$92.00

$111.00

*************************************************~*********************
B
2.00
JANUARY
05
A01
2

PUPCHASES

A~O

CrST FOR 1-05

$2.00

2

$113.00

***********************************************************************
JANUARY

08

AO!

10

AO 1

AOI
PURCHASES AND COST FOP 1-08

20

A
B
D

10.00
12.48
38.40

$60.88

38

$173.88

***********************************************************************
JAf'IUAPY

13

AOO
AOO

PURCHASES AND COST FOR 1-13

1

6.24
8.00

5

$14.24

4

$188.12

***********************************************************************
JA f\IUARY
AOO
o
15
10
1°.20
A02
PURCHASES AND Cr.ST FOR 1-15

1

C

8.00
$27.20

11

$21'5.32

***********************************************************************
JANUARY

21

A03
A03
A03

PURCHASES AND COST FOP 1-21

10
10
10

E
F
G

30

30.00
25.00
50.00

$105.00

***********************************************************************
JANUARY

23

AOO

PUPCHASES AMD COST FrR 1-23

5

5

A

5.00

$5.00

$325.32

***********************************************************************

(!)

REPORT-PAGE-Ol

Figure 47.

284

Report Produced by Report writer Feature (Part 1 of 5)

Part V -- Special Features

Report Writer -- Sample Program

~---------------JANUARY

~~rNTH

DAY

OFPT

NO-PURCHASES

PURCHASES AND COST FOR 1-27

EXPENDITURES (CONTINUED)
TYPE

21

(CST

eUMULATIV~-eCST

$12q.36

$467.48

***********************************************************************
JAr'-'UflDV

30

AI)O

AO?
AO?
A04
A04
PURCHASES AND CrST FOR 1-30

2
10
1

15

B
A
C
B

10

e

3.12
10.00
13.00
23.40
80.00

$124.52

38

$592.00

***********************************************************************
31

AOO

1

A

1.00

A04

6

A

6.00

PURCHASES AND erST FeR 1-31

7

~7.00

$599.00

***********************************************************************
\-JAS
$599.00
CD~--------TOTAL e(lST FOR JANUARv

(!)~------------------------------------------------REPORT-PAGE-02

Figure 47.

Report Produced by Report writer Feature (Part 2 of 5)

Report Writer Feature

285

Report Writer -- Sample Program

~Mr"T"

FEBRLIARY EXPHWITURES
rAY

@-FEBPUARY

15

DEPT

t--!O-PUR CH AS ES

A02
A02
A02

10
2
1
15
5

AO?
A04
A05
A05

8

5

TYPE
A
P,

C

G
B

A
C

COST

CUMULA Tl VF:-C(lST

10.00
3.12
8.00
75.00
7,,80
8.00
40.00

~~;:~~!;;;*:.~~*;;;!*:~:*~:;:**:~****************!!;!;;;**********!:;~;;;
FEBFUAPV

16

A02
A06
A07
A07

2
10
10
10

PURCHASES ANn COST FOP 2-16

C
A
A
F

32

16.00
10.00
10.00
25.00
$61.00

$811.92

***********************************************************************
FEBRUARy

PURC~ASE~

AO?
A07

10
10

AND COST FOP 2-17

20

17

30.00
50.00

E
G

$80.00

$~91.92

*****~************************************************ *****************

FFBR !JAR V

21

AOt
AOf

20
20
20
20
20
20
20

AOf.

AOf
AOt
AOt.AOt

A
B
C
[)

E
F
G

PURCHASF.S Af',ID COST FOP 2-21 140

20.00
31.20
160.00
38.40
AO.OO
5(1.00
100.00
$459.60

$1351.52

***********************************************************************
27

PURCHASE~

A~D

AOI

21

C(lST FOR 2-27

40.32

D

$40.32

21

$1391.84

***********************************************************************
FFB~UAPY

28

A02

3

AO?

5
15

A03
PURC~ASES

~ND

CCST Fnp 2-28

4.68
40.00
45.00

B
C
E

$89.68

23

$1481.52

***********************************************************************

Cl)~---------------TrTAL

erST FOR FER.RUARY

WAS

$882.52

(!)~-------------------------------------------------------REPORT-PAGE-03

Figure 47.

286

Part V

Report Produced by Report Writer Feature (Part 3 of 5)

Special Features

Report Writer -- Sample Program

(!)~------------------------------~1AReH
Mor-nH

[lAY

C!r-MAPCH

01

NO-PURCHASES

TYPE

A02

E:;

AO?

1

A
C

A03

25

G

AND COST FOP. 3-01

31

0~DUF'CHASFS

DEPT

EXPENCITURES
COST

CUMULATIVE-COST

5.00
P.OO
125.00
$138.00

$161<;.52

~***********************************************************************
MARCH

06

PURCHAS~S

A02

5

AND erST FOP 3-06

5

A

5.00

$5.00

$1624.52

***********************************************************************
MA.RCI-'

07

A02

PURCHASES AND COST

FO~

5

3-07

A

5.00

$5.00

5

$lA29.52

***********************************************************************
,"1APCH

13

A02

PURCI-'ASES ANQ crST FrR 3-13

10

10.00

10

$10.00

***********************************************************************
MAPCH

1 ')

A01
A02
A03
AOt
AO£-

PURCHASES ANn CCST FOP 3-15

?l

A

1
15

A

F

E:;

F

5

F

47

21.00
1.00
'2.7.50
15.00
12.5C

$87.00

$1726.52

***********************************************************************
MAPCI-1

20

A03

PURCHASES AND (CST FOP 3-20

15

E

15

45.00

$45.00

$1771.52

***********************************************************************
MARCH

A02
AO?

15
15

37.1';0

AND CGST FOR 3-21

30

$52.50

21

PURCHftS~S

15.00

51324.02

***********************************************************************
~ARCH

23

A.02

PUQ(HASES AND eCST FOP 3-23

2

A

2.00

$2.00

2

$1826.02

***********************************************************************
MAFCH

25

AO?

PUR(HASFS AND CCST FQR 3-25

30

30

F

75.0r

!75.C'O

$1901.02

************~**********************************************************

(!)

Figure 47.

~EPORT-PAGE-04

Report Produced by Report Writer Feature (Part 4 of 5)

Report writer Feature

287

Report Writer -- Sample Program

~-----------_ _ _ _ '.1ARrf-J

~MO~TH

DAY

0-~ARCf-J

26

DEPT

EXPENDITURES (CONTINUED)

NO-PURCHASES

A02

TYP~

A

crST

CI..IMUL.ATIVI=-cnST

1.00

r;r-:::PUFCHASES AND erST FOf' 3-26

1
$1.00
$1 0 02.02
~***********************************************************************
MARCH
20
t01
6
C
48.00

PURCHASES AND COST FOP 3-29

$48.00

6

$1950.02

***********************************************************************
MAPCH

PURCH~SES

31

A03

20

AND COST FOR 3-31

20

E

60.00

$60.00

$2010.02

***********************************************************************

(2)~---------------TOTAL

WAC:;

crST FOR MARCH

$528.'50

(!)~-----------------------------------------------------------R~PORT-PAGE-05

@--TOTAL CCST FOR QUARTER WAS

$2010.02

(!)------------------------------------------------------------- REPORT-PAGE-Ob
01-------------------EI\,O

Figure 47.

288

OF REPORT

Report Produced by Report Writer Feature (Part 5 of 5)

Part V -- Special Features

Subscripting and Indexing
TABLE riANDLING

FEA~URE

The Table Handling feature enables the progra~rner to process tables
or lists of repeated data conveniently.
A table may have up to three
dimensions, i.e., three levels of subscripting or indexing can be
nandled.
Such a case exists when a group item described with an OCCURS
clause contains another group iteI~ with an ~ccuas clause, which in turn
contains an item with an OCCURS clause.
To make reference to any
element witnin such a table, each level must be subscripted or indexed.

SUBSCRIPTING
Subscripts are used only to refer to an individual element within a
list or table of elements that have not been assigned individual
data-names.

r----------------------------------------------------------------------,

I

I

Format

r----------------------------------------------------------------------~

I
I
I
data-name (subscript[, subscript] [, subscript])
I
Il ______________________________________________________________________ JI

The §.~bscript, or set of subscripts, that identifies the table
element is enclosed in parentheses immediatelj following the space that
terminates data-name, which is the name of the table element.
When more
than one subscript appears within a pair of parentheses, each subscript
must:.b~ . separC3tedfro~ltt1e n~xtb¥ a. corruTla .followedb¥ a space.
·~2~§~£5~.iL~j:~q~~~l!e._t::;~JJt~:;:;~~:~~.;ito: ::~;:;~i.;t~.d~
No space may
appear between the left parenthesis and the leftmost subscript or
between the riqhtmost subscript and the right parenthesis.
To identify
an element in the table named SALARY by the set of subscripts Y£AR,
MO~TH, and WEEK, the programmer would write:
SALARY (YEAR, MONTH, WE£K).
The subscript can be represented by a numeric literal that is a
positive integer, by the special register TALLY, or by a data-name.
Restrictions on the use of a data-name as a subscript are:
1.

Data-name must be a numeric elementary item that represents a
positive int€qer.

2.

The name itself may be qualified, but not subscripted.

The subscript may contain a sign, but the lowest permissible
subscript value is 1. Hence, the use of zero or a negative subscript is
not permitted.
The highest permissible subscript value in any
particular case is the maximum number of occurrences of the item as
specified in the OCCDRS clause.
Qualification may be used in conjunction with subscripting, in which
case OF or IN follows the ~~~~~narrle being subscripted.
Table Handling Feature

289

Subscripting and Indexing

r----------------------------------------------------------------------,
Fo:cmat

j

I

~----------------------------------------------------------------------~

I
II
I
I

} data-name-l [ { -O:r } data-name-2J...
data-name {OF
IN
, IN

I
II
I
I

I

(suDscript(, sUDscri?tJ (, subscri9tJ)

I

I
Il ______________________________________________________________________ JI

Note:
Data-name is the item being subscripted, not a.ata-name-l. 'llJat
in the statement SALJ._RY OF Et-'lPLOYEE-RECORD (YEAR, MOiJTH, WEEK), ti1e
data item SALARY is 3ubscripted by Y~AR, MO~TH, and W~~K.
lS,

INDEXING
References can be rr-ade to individual elements witnin a Table of
elements by specifying indexing for that reference.
An index is assigned to a given level of a table ny using an INL~XED
bY clause in the definition of the table. A name given in the INDEXED
BY clause is known as an index-name and is used to refer to tl~ assigned
index. An index-name must be initialized by a S~T or PERFORM statement
before it is use~ in a table reference. An index may be modified only
by a SET, SEARCH, or PERFORM statement.

r----------------------------------------------------------------------,

I

Format

I

t----------------------------------------------------------------------~

I

!

I
data-name (index-name [ { : } integer]

I

!

!
I

[.

index-name [ { : } integer]] [. index-name [{: } integer]])

!

Il ______________________________________________________________________ JI

Direct indexing is specified by using an index-name in the forro of a
subscript. For example,
ELEMENT (PRIME-INDEX)
Relative indexing is specified when the terminal space of the
data-name is followed by a parenthesized group of items: the
index-name, followed by a space, followed by one of the operators +
or -, followed by another space, followed by an unsigned integral
numeric literal. For example,
ELEMENT (PRIME-INDEX + 5)
Qualification may be used in conjunction with indexing, in which case
OF or IN follows the data-narr,e being indexed.

290

Part V -- Special Features

Subscripting and Indexing

r----------------------------------------------------------------------,

I

I

Format

~----------------------------------------------------------------------~

I

I

data-name

I:

{OINF}

data-name-1

{OINF}

data~naThe-2]

...

I:

I

I

i

(index-na'1le [{:} integerJ[. index-name

i

[{: } integerll

I

I

!

[. index-naroe [ {:} integer III

I

IL ______________________________________________________________________ JI
Note:
Data items described by the USAGE IS INDEX clause permit storage
of the values of index-names as data without conversion. such items are
called index data items.
RESTRICTIONS ON INDEXING, SUBSCRIPTING, AND QUALIFICATION
Tables may have one, two, or three dimensions.
Therefore, references
to an element in a table may require up to three subscripts or indexes.
1.

A data-name must not be subscripted or indexed when the data-name
is itself being used as an index, subscript, or qualifier.

2.

When qualification, subscripting, or indexing are required for a
given data item, the indexes or sUbscripts are specified after all
necessary qualification is given.

3.

Subscripting and indexing must not be used together in a single
reference.

4.

Wherever subscripting is not permitted, indexing is not permitted.

5.

The commas shown in the formats for indexes and subscripts are
required.

EXAMPLE OF SUBSCRIPTING AND INDEXING
For a table with three levels of indexing, the following Data
Division entries would result in a storage layout as shown in Figure 48.
01

PARTY-TABLE REDEFINES T'ABLE.
02 PARTY-CODE OCCURS 3 TIMES INDEXED BY PARTY.
03 AGE-CODE OCCURS 3 TIMES INDEXED BY AGE.
04 ~-F-INFO OCCURS 2 TIMES INDEXED BY M-F
PICTURE 9(7)V9 USAGE DISPLAY.

PARTY-TABLE contains three levels of indexing.
Reference to
elementary items within PARTY-TABLE is made by use of a name that is
subscripted or indexed.
A typical Procedure Division statement might
be:
MOVE M-F-INFO (PARTY, AGE, M-F) TO M-F-RECORD.
In order to use the Table Handling feature, the programmer must
provide certain information in the Data Division and Procedure Division
of the program.

Tanle Handling Feature

291

Subscripting and Indexing

r----------------------------------------------------------------------,
8 bytes

I
I
I
I
I
I
I
I
I
I
I
I
I
I
I

By tel
No·1

. l\GE-CODE (1, 1)

i

I
01
I
8/

r~=;=~;;;-(~~-~~-~)1
t------------------~

I i"l-F-INFO

(1,

1" 2) I

t------------------~

16

t------------------~

24

------------------~

32

t------------------~

40

IM-F-INFO (1, 2, 1)1
PARTY-CODE (1)

,AGE-CODE (1, 2)

IM-F-INFO (1, 2, 2) I
IM-F-INFO (1, 3, 1)1
AGE-CODE (1, 3)

I M-F-INFO

I

(1,

3, 2) I

t------------------~

48

t------------------~

56

------------------~

64

IM-F-INFO (2, 1, 1)1

I
I

AG.E;-CODE (2, 1)

IM-F-INFO (2, 1, 2) I

II

I PARTY-TABLE
I
I
I

PARTY-CODE (2)

l\GE-COJE

(2, 2)

IM-F-INFO (2, 2, 1)1
~------------------~
IM-F-INFO (2, 2, 2) I

72

------------------~

80

t------------------~

88

t------------------~

96

t------------------~
(3, 1, ·2)1
t------------------~
IM-F-INFO (3, 2, 1)1
t----~-------------~

104

IM-F-INFO (2, 3, 1)1
l\GE-CODE (2, 3)

I~-F-INFO

(2, 3, 2)

I

IM-F-INFO (3, 1, 1)1
AGE-CODE (3, 1)

IM-F-INFO

PARTY-CODE (3)

AGE-CODE (3, 2)

IM-F-INFO

(3,

2, 2)

I

112

120

t------------------~ 128

IM-F-INFO (3, 3, 1)1
AGE-CODE (3, 3)

t------------------1

136

I

IM-F-INFO
(3, 3, 2) J
L
__________________
~~-------

I
I
I
/

IL ______________________________________________________________________
OCCURS 3 TIMES
OCCURS 3 TIMES
OCCURS 2 TIMES
J/
Figure 48.

Storage Layout for PARTY-TABLE

DATA DIVISION CONSIDERATIONS FOR TABLE HANDLING
The OCCURS and USAGE clauses are included as part of the record
description entries in a program utilizing the Table Handling feature.

OCCURS Clause
The OCCURS clause eliminates the need for separate entries for
repeated data, since it indicates the number of times a series of
records with identical format is repeated.
It also supplies information
required for the application of subscripts or indexes.
The OCCURS clause has three formats.

292

Part V -- special Features

Page of GC28-6394-4, -5, -6 revised 12/03/76 by TNL GN26-0887
OCCURS Clause

r----------------------------------------------------------------------,

I

I

Format 1

r----------------------------------------------------- -----------------~

I
I
I
I

OCCU~S

I
I
I

integer-2 TIMES
~ASCENDING I

~

I

KEY IS data-name-2 [data-name-3]

.•. ] •..

I

I
'QESC~~QI~G~
I
I
I
[I~DEXED BY index-name-1[index-name-2] ... ]
I
I
Il ______________________________________________________________________ JI

r----------------------------------------------------------------------,

I

I

Format 2

r----------------------------------------------------------------------~

I

I
I
I
I

OC~URS

integer-1 TO integer-2

1ASCENDING

(

TIM~S

[DEPENDING ON data-name-1]

KEY IS data-name-2 [data-name-3]

.•• ] .••

I
I
I
I

I
DESCE~DING
I
I
I
I
[INDEXED BY index-name-1 [index-name-2] .•. ]
I
Il ______________________________________________________________________ JI

The other data description clauses associated with an entry whose
description includes an OCCUkS clause apply to each occurrence of the
item described.
Since three subscripts or indexes are allowed, three nested levels of
the OCCURS clause are allowed.
That is, 3-dimensional tables can De
specified.
No table may be longer than 32,767 bytes in length, except
for fixed-length tables in the Working-Storage Section or Linkage
Section, which may be as long as 131,071 bytes.
The subject of an OCCURS clause is the data-name of the entry that
contains this OCCURS clause.
The sUbject of an OCCURS clause must be
subscripted or indexed whenever reference is made to it in any statement
other than SEARCH. The subject of an OCCURS clause must not be longer
than 32,767 bytes.
When subscripted, the subject refers to one occurrence within the
table.
When not subscripted (permissible only in the SEARCH statement),
the subject represents the entire table element.

Table Handling Feature

293

OCCURS Clause
The OCCURS clause may not be specified in a data description entry
that:
1.

has a level-Ol or level-77 number

2.

describes an item whose size is variable

(The size of an item is variable if the data description of any
subordinate item within it contains an OCCURS DEPENDING ON clause--that
is, an OCCURS clause with the DEPENDING ON option.)

Except for condition-name entries, a record description entry that
contains an OCCURS clause must not also contain a VALUE clause.

Within a given record description, the VALUE clause must not be used
in a data description entry that is subsequent to a data description
entry that contains an OCCURS DEPENDING ON clause.
In the discussion that follows, the term "computational" refers to
COMPUTA.TIONAL, :::::I_._mm!::;::;::.:::::::_.I~D
:~::::: data items.

••

When a computational elementary item specifies both the OCCURS and
SYNCHRONIZED clauses, any necessary slack bytes for each occurrence of
the item are adde1 by the compiler.
When a group iteuL specifies the
OCCURS clause and also contains SYNCHRONIZED computational elementary
items, any necessary slack bytes for each occurrence of the group are
added by the compiler, as well as the necessary slack bytes for the
computational items (see "Slack Bytes" in "Data Division" for a complete
discussion).
In Format 1, integer-2 represents the exact number of occurrences.
In this case, integer-2 must be greater than zero.

DEPENDING ON OPTION:
In Format 2·::~:nl:::·:·:·lgEml~::.::·:::I:~:; the DEPENDING ON option
is used. This indicates that the subject of this entry has a variable
number of occurrences. This does not mean that the length of the
sUbject is variable, but rather that the number of times the subject may
be repeated is variable, the number of times being controlled by the
value of ~ata-name-l at object time.
In Format 2, integ~r-l represents the minimum number of occurrences,
and intgg§r-~ represents the maximum number of occurrences.
Integer-l
may be zero or any positive integer.
Integer-2 must be greater than
zero, and also greater than integer-i.
Integer-2 must be less than
32,768. The value of 9.~t§::.!:!§:@.~:.l must not exceed integer-2.

294

Part V

Special Features

OCCURS Clause
Data~name-1,

the object of the DEBENDING ON option:

• Must be described as a positive integer
• Must not exceed integer-2 in value
•

~ay

be qualified, when necessary

• Must not be subscripted (that is, must not itself be the subject of,
or an entry within, a table)
• Must, if it appears in the same record as the table it controls,
appear before the variable portion of the record

If the value of data-name-1 is reduced, the contents of data items
whose occurrence numbers exceed the new value of data-narne-1 become
unpredictable.
Unused character positions resulting from the DEPENDING ON option
will not appear on external media.
The DEPENDING ON option is required only when the last occurrence of
the subject cannot otherwise be determined.
Any Data Division entry that contains an OCCURS DEPENDING ON clause,
or which has subordinate to it an entry that contains an OCCURS
DEPENDING ON clause! cannot be the object of a REDEFINES clause.

KEY OPTION: The KEY option is used in conjunction with the INDEXED Bt
option in the execution of a SEARCH ALL statement. The KEY option is
used to indicate that the repeated data is arranged in ASCENDING or in
DESCENDING order, according to the values contained in data-name-2,
data-name-3, etc.
Data-name-2 must be either the name of the entry containing an OCCDRS
clause, or it must be an entry subordinate to the entry containing the
OCCURS clause.
If data-name-2 is the subject of this table entry, it is
the only key that may be specified for this table.
If data-name-2 is
not the subject of this table entry, all the keys identified by
data-name-2, data-name-3, etc.;
• Must be sUbordinate to the subject of

th~

table entry itself

• Must not be subordinate to any other entry that contains an OCCURS
clause
• Must not themselves contain an OCCURS clause
When the KEY option is specified, the following rules apply:
• Keys must be listed in

~escending

order of significance.

• The total number of keys for a given table element must not exceed
12.
• The sum of the lengths of all keys associated with one table element
must not exceed 256 bytes.
• A key may have the following usages:
COMPUTATIONAL.

DISPLAY, COMPUTATIONAL-3, or

Table Handling Feature

295

OCCURS Clau.se
When subordinate entries within the table are variable in length, the
following rule also applies:
• Any key in a table element must beat a fixed displacement from the
beginning of that element (that is, if a table element isot
variable length, then the keys must precede the ,v?~iable portion) ..
The following example sholNs a violation of the last

:precedin~

rule:

WORKING-STORAGE SECTION.
PICTURE 99 ..
71 CURRENT-WEEK
01 TABLE-RECORD.
02 EMPLOYEE-TABLE OCCURS 10,0 TIMES
ASCENDING KEY IS WAGE-RATE,EMPLOYEE-NO
IND,EXED 'BY A, B.
03 WEEK-RECORDOCCDRS 1'1'0 52 'rIMES
DEPENDING ON CURRENT-WEEK
INDEXED BY C ..
04 WEEK-NO
PIC 99.
04 AUTHORIZED~ABSENCES
PIC 9.
04 UNAUTHORIZED-ABSENCES PIC 9.
PIC 9.
04 LP.TENESSES
PIC X(20).
03 EMPLOYEE-NAME
03 EMPLOYEE";' NO
PIC 9 (6) •
03 WAGE.;". RATE
PIC 9999V99.o

I

; ')1
if

,H

·:H WAGE-RATE and EMPLOYEE-NO are invalid as keys,

~fterthe variable portion of the table.

Ll
t ~t

t

'
~

~J The· following example of the KEY option is corre<#' d
I~i

I;t:

\ ; ,~WO~~ING-STORAGE SECTION.
1 fJ7l1 tCU~RE~-WEEK
f &;·l 011 'TABLE-RECORD.
i ; :1:"
",
I!
. '
t'!i "
'(;)2 : 1 EMPLOYEE-TABLE OCCURS 100 TI~..ES
r, l ~ASCENDING KEY IS WAGE-RATE EMPLOYEE-NO'
1~'~I ! ::t ~.·I INt'!EXED BY A, B.
i ll3. .". :EMPLOYE.E-NAME
I ~'f
\ ! ; Td,:f :EMPLOYEE-NO
I >i
i ; 13 ~ WA(iE- RATE
i~l
~ 1Q:~',: :WE~K-R~CORDOCCURS .1 TO 52 :TIMES
; 1,1
DEFENDING ON CURRENT-WEEK; .,
INqEXED BYC.
.
; 'i " .'
Oll! ; ,:WE~-NO
.~
Q~ \ ':AUTHORIZED~ARSENCES' ,:PIiC' 19.'
i
l.
;04,UNAUTHORIZED-AaSENC~sprCi .9.
; " p;'
:04' :'1:,iAT~NEsSES '. '.' ' ."
;:;; :pliQ 1 '9.1 '\ I;:

l1l

\ Ii

H!

': I

'

tH .

::

°

1
:'

1

L;r,

I!; :

l'

i"

,.. j

i'-

.

{.i" .: .. "

~

:.~.~

'.

'{!:f.i:'

it;;;~

~

j,

,',

~;..

~~;~_~~~i:~~~~.
INDEXED-BY OPTION:
The INDEXED BY option is required if the subject of
this entry (the data-name described by the OCCURS clause, or an item
within this data-name, if i t is a group item) is to be referred to by
indexing.
The index-nameCs) identified by this clause is not defined
elsewhere in the program, since its allocation and format are dependent
on the system, and, not being data, cannot be associated with any data
hierarchy.
The number of index-names for a Data Division entry must not exceed
12.
296

Part V -- Special Features

OCCURS Clause
An index-name must be initialized through a SErT or PERFORM staten-,ent
before it is used.
Each index-name is a fullword in length and contains a binary value
that represents an actual displacement from the beginning of the table
that corresponds to an occurrence nillJber in the table. The value is
calculated as the occurrence number minus one, multiplied by the length
of the entry that is indexed by this index-name.
For example, if tne programmer writes
A OCCURS 15 TIMES INDEXED BY Z PICTURE IS X(10)
on the fifth occurrence of A, the binary value contained in Z will be:

Z

=

(5 - 1)

*

10

=

40

Note that, for a table entry of variable length, the value contained in
the index-name entry will become invalid when the table entry length is
changed, unless the user issues a new SET statement to correct the value
contained in the index-name.
The following exarople of the setting of values in index-name is
incorrect:

DATA DIVISION.

77
01

E PICTURE S9(5) CaMP SYNC.
02

A OCCURS 10 INDEXED BY IND-1 .••
03 B OCCURS 10 DEPENDING ON E INDEXED BY IND-2 ••.

PROCEDURE DIVISION.

MOVE 8 TO E
SET IND-l TO 3
SEARCH A ..•

MOVE 10 '1'0 E
SEARCH A ••.
(Moving 10 to E changes the length of the table entry A, so that IND-1
now contains an invalid value.)

Table Handling Feature

297

OCCURS Clause
The following example of the
correct:

settin~

of values in index-name is

DATA DIVISION.

77
77
01

E PICTURE S9(5) COMP SYNC.
D PICTURE S9(5) COMP SYNC.
02

A OCCURS 10 INDEXED BY IND-l .•.
03 B OCCURS 10 DEPENDING ON E INDEXED BY IND-2 .•.

PROCEDURE DIVISION.

MOVE 8 TO E
SET IND-1 TO 3
SET D TO IND-1
SEARCH A •••

MOVE 10 TO E
SET IND-1 TO D
SEARCH A •••

(Here the user has saved the occurrence number in 0, and then later
reset IND-l to obtain the corrected value.)

There are two types of indexing:
Indexing.

Direct Indexing and Relative

Direct Indexing:
If a data-name is used in the procedure text with
index-names, the data-name itself must be the subject of an INDEXED BY
option, or be subordinate to a group(s) that is the subject of the
INDEXED BY option.
In the following example
A (INDEX-l, INDEX-2, INDEX-3)
implies that A belongs to a structure with three levels of OCCURS
options, each with an INDEXED BY option.
However, if'data':':name'(A'~ in
this example) belongs to an OCCURS' struCture that does not use the
INDEXED BY option, this compil,er accepts the, specif ication of
index-names (in this, example INDEX-l, INDEX-2, INDEX-3) and 'assumes tJ1e
l:;lser: has s'et them to values'that correspond to the occu,rrenc-enumber. he
~ishes~to referei~e~
,;
298

Part V -- Speclal Features

USAGE IS INDEX Clause
Relative Indexing: The index-name is followed by a space, followed
by one of the operators + or -, followed by another space, followed by
an unsigned numeric literal. The numeric literal is considered to be an
occurrence number, and is converted to an index value before being added
to, or subtracted from, the corresponding index-name.
Given the following example:
A (Z + 1, J + 3,

K + 4)

where:
table element indexed by Z has an

~r\~ "....,,7
~.&..a.'-..LJ

length of 100

table element indexed by J has an entry length of 10
table element indexed by

K

has an entry length of 2

the resulting address will be computed as follows:

*

(ADDRESS of A) + Z + /100

I

1/ + J + 110

* 31

I

+ K + 14

*

21

conversion of integers
to index values

USAGE IS

IND~X

Clause

The USAGE IS INDEX clause is used to specify the format of a data
item stored internally.

r----------------------------------------------------------------------,
Format
I

I

~---------------------------~------------------------------------------~

I

I
I
IL ______________________________________________________________________ JI
/

[USAGE IS] INDEX

The USAGE IS INDEX clause allows the programmer to specify index data
items.
An index data item is an elementary item (not necessarily connected
with any table) that can be used to save index-name values for future
reference. An index data item must be assigned an index-name value
(i.e., (occurrence number - 1) * entry length) tnrough the SET
statement. Such a value corresponds to a~ occurrence number in a table.
The USAGE IS INDEX clause may be written at any level. If a group
item is described with the USAGE IS INDEX clause, it is the elementary
items within the group that are index data items; the group itself is
not an index data item, and the group name cannot be used in SEARCH and
SET statements or in relation conditions. The USAGE clause of an
elementary item canQot contradict the USAGE clause of a group to whiCh
the item belongs.
An index data item can be referred to directly only in a SEARCH or
SET statement or in a relation condition. An index data i±em can be
part of a group which is referred to in a MOVE or an input/output
Table Handling Feature

299

Table Handling -- Relation Condition
statement. When such operations are executed, however, there is no
conversion of the contents of the index data item.

An index data item cannot be a conditional variable.

The SYNCHRONIZED, JUSTIFIED, PICTURE, BLANK W::-:IEN ZERO, or VALUE
clauses cannot be used to describegrollP ()I:"e~~mentar .+te~~de~Gribed

,;~~~~~~~~~~:~~f~;~~~~~~~~:,'" ',~ ~~-~':~~i1'f' . . '.. :~~

PR~CEDURE

DIVISION CONSIDERATIONS FOR TABLE HANDLING

The SEARCH and the SET statements may be used to facilitate table
handling. In addition, there are special rules involving Table Handling
elements when they are used in relation conditions.

Relation Conditions
Comparisons involving index-names and/or index data items conform to
the following rules:
1.

The comparison of two index-names is actually the comparison of the
corresponding occurrence numbers.

2.

In the comparison of an index-name with a data item (other than an
index data item), or in the comparison of an index-name with a
literal, the occurrence number that corresponds to the value of the
index-name is compared with the data item or literal.

3.

In the comparison of an index data item with an index-name or
another index data item, the actual values are compared without
conversion.
Any other comparison involving an index data item is illegal.

Figure 49 gives permissible comparisons for index-names and index
data items.

300

Part V -- Special Features

SEARCH Statement

----------------T-----------T-----------T-------------T---------------,

I
I
I First
I Operand

Second I
Operandi
I
IIndex-name

r----------------

I Index-name
I
I
I

I
I

I
I

I

Index
IData Item

I
I
Data-name I
Numeric
I
I
(numeric I
literal
I
linteger only) I (integer only) I

-----------f-----------+-------------f---------------~

I compare

I compare
loccurrence Iwithout
I number
Iconversion
I
I

I compare
I occurrence

I compare
I occurrence

I
I

Inumber with

Inumber with

I

I data-name

I literal

I

r----------------f-----------f-----------f-------------+---------------~

IIndex Data Item Icompare
I compare
I illegal
I without
I without
I
I
i conversion i conversion I

I

lillegal

I

I
I
i !

t----------------+-----------+-----------f------------ _i _______________ ~

I Data-name
I compare
(numeric
I occurrence
I integer only) I number
I
I with
I
I data-name

I

I illegal
I
I
I
I

I

I
I
I
I
I

I
I
I

See Figure 23
for
Permissible
Comparisons

r----------------f-----------f-----------~

I

I
I compare
I illegal
I
I
I Numeric
I literal
loccurrence I
I
I
I (integer only) I number
I
I
I
I
I with
I
I
I
Il ________________ iIIi
teral
___________
iI ___________ iI ____________ _________________ JI
Figure 49.

Index-names and Index Data Items -- Permissible Comparisons

SEARCH Statement
The SEARCH statement is used to search a table for an element that
satisfies a specified condition, and to adjust the value of the
associated index-name to the occurrence number corresponding to that
table element~

r----------------------------------------------------------------------,
I
Format 1
I
~----------------------------------------------------------------------~
~index-name-1l

SEARCH identifier-1 [VARYING
tidentifier-2f
[AT END imperative-statement-1]
~imperative-statement-2t
~

condition-l

I~EXT

~

SENTENCE

~imperative-statement-3

{

lNEXT SENTENCE

~

[WHEN condition-2

]

...

l ______________________________________________________________________ J

Table Handling Feature

301

SEARCH Statement

r----------------------------------------------------------------------,
Format 2

I

I

~----------------------------------------------------------------------~

I
I
I

SEARCff ALL identifier-1 [AT END imperative-statement-i]
-\~perative-statement-2.1

I

WHEN condition-i

~

I
I
I

11

}
~

I
l NEXT SENTENCE
I
IL ______________________________________________________________________ JI
The Data Division description of identifier-i must contain an OCCURS
clause with the INDEXED BY option.(L~~'*~:+:e;r:;- index-namE:
for identifier-l is used~
• If index-name-i is an index for another table entry, then when the
index-name for identifier-l is incremented to represent the next
occurrence of the table: index-name-l is simultaneously incremented
to represent the next occurrence of the table it indexes.
A flowchart of the Format 1
options is shown in Figure 50.

S~ARCrl

operation containing two WHEN

Table Handling Feature

303

SEARCH Statement

*
*

* * **11.2*** ** * * **
EXECUTION
*
OF SEARCH
*
BEGINS
*

****** **** * *** *

~-----,l
INDEX SETTING EQUALS
HIGHEST PERMISSIBLE
OCCURRENCE NUMBER

•*
*.

·*

*.

B2

· *. *.

*****B4**********

*. *. GT

*.

.*

rOR

* .. *

.*

*

AT E:-l"D *
*
• *----------------------------------> *

IMPERATIVESTATEMENT-l

*

*
**
*------->

*
*
*
*
*****************

=

C2

·*

· *. *.

*.

*****C4**********

*

.*
*. TRUE
WHE~ C01IDITION-l
*
*. CONDITION-l • *--------------------------------->*

*.

*.

·*

r"

*. . *

D2

.*

.*

· *. *.

*
*

*.

.*

r"

* .. *

**
*------>

*****D!I**********

*

.*

**

*
*
******** *********

•*
*. TRUE
WHE:~ co,mITION-2 *
*
*. CONDITION-2 • *---------------------------------->*

*.

IMPERATIVESTATEMENT-2

*

I~PERATIVE-

STA'C'E!>lE::lT-3

*

**

*------->

*

*****************

**** "'E2 ****"'* * ***
*
INCREMENT
*
*INDEX-NAME FOR *
* IDENTIFIER-l *
* IINDEX-NA."IE-l *
* IF APPLICABLE) *
* * **** * * ****** ***

1

*****F2*** ***** **
*
INCREMENT
*
* INDEX-NAME-l *
---* (FOR ANOTHER *
*
TABLE) OR
*
* IDENTIFIER-2 *

******* ***** *****

THESE OPERATIONS ARE INCLUDED ONLY WHEN CALLED FOR
IN THE STATEMENT.

*'"

EACH OF THESE CONTROL TRANSFE~S IS TO THE NEXT
SENTENCE UNLESS THE IMPERATIVE-STATEMENT ENDS WIT"
A GO TO STATEMENT.

Figure 50.

304

Part V

Format 1 SEARCH Operation Containing Two WHEN Options

Special Features

SEARCH Statement
Format 2 Considerations -- The first index-name assigned to
identifier-l will be used for the search.
The description of identifier-l must contain the KEY option in its
OCCURS clause.
Condition-l must consist of one of the following:
• A relation condition incorporating the EQUALS, EQUAL TO, or equal
sign ( = ) relation.
Either the subject or the object (but not
both) of the relation condition must consist solely of one of the
data-names that appear in the KEY clause of identifier-i.
• A condition-name condition in which the VALUE clause describing the
condition-name consists of a single literal only. The conditional
variable associated with the condition-name must be one of the
data-names that appear in the KEY clause of identifier-i.
• A compound condition formed from simple conditions of the types
described above, with AND as the only connec~ive.
Any data-name that appears in the KEY clause of identifier-l may be
tested in condition-i. However, all data-names in the KEY clause
preceding the one to be tested must alsQ be so tested in condition-i.
No other tes·ts may be made in condition-i.
For example, if the following table were defined in the Data
Division:
77

VALUE-l PICTURE 99.

02

A OCCURS 10 TIMES ASCENDING KEY IS KEY1, KEY2, KEY3, KEY4
INDEXED BY I.
03 KEYl PICTURE 9.
03 KEY2 PICTURE, 99.
03 KEY3 PICTURE 9.
03 KEY4 PICTURE 9.
88 BLUE VALUE 1.

in the Procedure Division, valid WHEN phrases could be:
WHEN KEY1 (I)

3 AND KEY2 (I)

10 AND KEY3 (I)

5 •••

WHEN KEYl (I)
3 AND KEY2 (I)
VALUE-l
AND' KEY3 (I) = 5 AND BLUE (I) •••

During execution of a.X()rmat 2 SEARCH st.atement, a binary search
takes place; the setting of index-name is varied during the search so
that at no time is it less than the value that corresponds to the first
element of the table, nor is it ever greater than the value that
corresponds to the last element of the table.
If condition-l cannot be
satisfied for any setting of the index within this permitted range,
control is passed to imperative- statement-l when the AT END option
appears, or to the next sentence when this clause does not appear.
In
either case, the final setting of the index is not predictable.
If tEe
index indiCates--.iii-·-6-ccu:ct'ence---ili-a-£--allows-C-orrd1ffo-n-T'To"~sa ti s f ied,
control passes to imperative-statement-2.
Table Handling Feature

305

SET Statement
SET Statement
The SET statement establishes reference points for table handling
operations by setting index-names to values associated with table
elements. The SET statement must be used when initializing index-name
values before execution of a SEARCH statement; it may also be used to
transfer values between index-names and other elementary data items.

r----------------------------------------------------------------------,
,
Format 1
,
~----------------------------------------------------------------------~
,
,
I
lindex-name-1 [index-name-2J •••
lindex-name-3)
,
I SET
t TO identif ier- 3 (
I
j

identifier-1 [identifier-2J ..• ,
literal-1'
I
IL ______________________________________________________________________ JI

,

r----------------------------------------------------------------------,

,
Format 2
I
~----------------------------------------------------------------------~

I

'I

SET index-name-4 [index-name-SJ

,

,L _____

•••

I

UP BY

DOWN
~

~

i

I

identifier-

4(

literal-2

I
I

I
I

________________________________________________________________ J

All identifiers must name either index data items or fixed-point
numeric elementary items described as integers; however, identifie~-4
must not name an index data item.
When a literal is used, it must be a
positive integer or zero. Index-names are related to a given table
through the INDEXED BY option of the OCCURS clause; when index-names are
specified in the INDEXED BY option, they are automatically defined.
All references to index-name-1, identifier-1, and index-name-4 apply
to index-name-2, identifier-2, and index-name-S, respectively.

eq~ally

Format 1 considerations -- When the SET statement is executed, one of
the following actions occurs:
1.

Index-name-1 is converted to a value that corresponds to the same
table element to which either index-name-3, identifier-3, or
literal~l corresponds.
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. To be valid, the resultant value of
index-name must correspond to the occurrence number of an element
in the associated table.

2.

If identifier-1 is an index data item, it is set equal to either
the contents of index-name-3 or identifier-3, where identifier-3 is
also an index data item.
Literal-1 cannot be used in this case.

3.

If identifier-1 is not an index data item, it is set to an
occurrence number that corresponds to the value of index-name-3.
Neither identifier-3 nor literal-1 can be used in this case.

Format 2 Considerations -- When the SET statement is executed, the
contents of index-name-4 (and index-name-S, etc., if present) are
incremented (UP BY) or decremented (DOWN BY) by a value that corresponds
to the number of occurrences represented by the value of literal-2 or
identifier-4.

306

Part V -- Special Features

Table Handling -- Sample Program
SAMPLE TABLE HANDLING PROGRAM
The program in Figure 51 illustrates the Table Handling feature,
including the use of indexing, of the SET statement, and of the SEARCh
statement (including the VARYING option and the SEARCH ALL format).
The census bureau uses the program to compare:
1.

The number of births and deaths that occurred in anyone of the 50
states in anyone of the past 20 years with

2.

The total number of births and deaths that occurred in the same
state over the entire 20-year period

The input file, INCARDS, contains the specific information upon which
the search of the table is to be conducted. INCARDS is formatted as
follows:
STATE-NAME

a 4-character alphabetic abbreviation of the state name

M-F-CODE

1 = male; 2 = female

YEARCODE

a 4-digit field in the range 1950 through 1969

A typical run might determine the number of females born in New York
in 1953 as compared with the total number of females born in New York in
the past 20 years.

r----------------------------------------------------------------------,
IDENTIFICATION DIVISION.
I
PROGRAM-ID. TABLES.
I
ENVIRONMENT DIVISION.
I
CONFIGURATION SECTION.
I
SOURCE-COMPUTER. IBM-360.
I
OBJECT-COMPUTER. IBM-360.
I
SPECIAL-NAMES. CONSOLE IS TYPEWRITER.
I
INPUT-OUTPUT SECTION.
I
FILE-CONTROL.
SELECT INFILE ASSIGN TO SYS007-UT-2400-S-INTAPE.
SELECT OUTFILE ASSIGN TO SYS012-UR-1403-S-PRTOUT.
SELECT INCARDS ASSIGN TO SYS013-UR-2540R-S-ICARDS.
DATA DIVISION.
FILE SECTION.
FD INFILE LABEL RECORDS ARE OMITTED.
01 TABLE-l PIC X(28200).
01 TABLE-2 PIC X(1800).
FD OUTFILE LABEL RECORDS ARE OMITT~D.
01 PRTLINE PIC X(133).
FD INCARDS LABEL RECORDS ARE OMITTED.
01 CARDS.
02 STATE-NAME PIC X(4).
02 M-F-CODE PIC 9.
02 YEARCODE PIC 9(4).
02 FILLER
PIC X(71).
WORKING-STORAGE SECTION.
101 PRTAREA-20.
I
02 FILLER
PIC X VALUE SPACES.
I
02 YEARS-20 PIC 9(4).
I
02 FILLER
PIC X(3) VALUE SPACES.
I
02 BIRTHS-20 PIC 9(7).
I
02 FILLER
PIC X(3) VALUE SPACES.
I
02 DEATHS-20 PIC 9(7).
IL ______________________________________________________________________
02 FILLER
PIC X(108) VALUE SPACES.
J
Figure 51.

Sample Table Handling Program (Part 1 of 2)

Table Handling Feature

307

Table Handling -- Sample Program

r----------------------------------------------------------------------,
01 PRTAREA.
02 FILLER
PIC X.
02 YEAR
PIC 9(4).
02 FILLER
PIC X(3) VALUE SPACES.
02 BIRTHS
PIC 9(5).
02 FILLER
PIC X(3) VALUE SPACES.
02 DEATHS
PIC 9(5).
02 FILLER
PIC X(112) VALUE SPACES.
01 CENSUS-STATISTICS-TABLE.
02 STATE-TABLE OCCURS 50 TI~illS INDEXED BY ST.
03 STATE-ABBREV
PIC X(4).
03 M-F OCCURS 2 TIMES INDEXED BY SE.
04 STATISTICS OCCURS 20 TIMES ASCENDING KEY IS YEAR
INDEXED BY YR.
05 YEAR
PIC 9(4).
05 BIRTHS
PIC 9(5).
05 DEATHS
PIC 9(5).
01 STATISTICS-LAST-20-YRS.
02 M-F-20 OCCURS 2 TIMES INDEXED BY SE-20.
03 STATE-20 OCCURS 50 TIMES INDEXED BY ST-20.
04 YEARS-20
PIC 9(4).
04 BIRTHS-20
PIC 9(7).
04 DEATHS-20
PIC 9(7).
PROCEDURE DIVISION.
OPEN-FILES.
OPEN INPUT INFILE INCARDS OUTPUT OUTFILE.
READ-TABLE.
READ INFILE INTO CENSUS-STATISTICS-TABLE
AT END GO TO READ-CARDS.
READ INFILE INTO STATISTICS-LAST-20-YRS
AT END GO TO READ-CARDS.
READ-CARDS.
READ INCARDS
AT END GO TO EOJ.
DETERMINE-ST.
SET ST ST-20 TO 1.
SEARCH STATE-TABLE VARYING ST-20 AT ENB GO TO ERROR-MSG-1
WHEN STATE-NAME = STATE-ABBREV (ST) NEXT SENTENCE.
DETERMINE-SE.
SET SE SE-20 TO M-F-CODE.
DETERMINE-YR.
SEARCH ALL STATISTICS AT END GO TO ERROR-MSG-2
WHEN YEAR OF STATISTICS (ST, SE, YR) = YEARCODE
GO TO WRITE-RECORD.
ERROR-MSG-1.
DISPLAY "INCORRECT STATE" STATE-NAME UPON TYPEWRITER.
GO TO READ-CARDS.
ERROR-MSG-2.
DISPLAY "INCORRECT YEAR"
YEARCODE UPON TYPEWRITER.
GO TO ~EAD-CARDS.
WRITE-RECORD.
MOVE CORRESPONDING STATISTICS (ST, SE, YR) TO PRTAREA.
WRITE PRTLINE FROM PRTAREA AFTER ADVANCING 3.
MOVE CORRESPONDING STATE-20 (SE-20, ST-20) TO PRTAREA-20.
WRITE PRTLINE FROM PRTAREA-20 AFTER ADVANCING 1.
GO TO READ-CARDS.
IEOJ.
I
CLOSE INFILE INCARDS OUTFILE.
IL ______________________________________________________________________
STOP RUN.
J
Figure 51.

308

Sample Program for the Table Handling Feature (Part 2 of 2)

v --

Special Features

Segmentation -- Organization
SEGMENTATION FEATURE

The segmentation feature allows the problem programmer to specify
object program overlay requirements. The segmentation feature permits
segmentation of procedures only. The Procedure Division and Environment
Division are considered in determining segmentation requirements for an
object program.

ORGANIZATION
Although it is not mandatory, the Procedur~ Division for a source
program is usually written as several consecutive sections, each of
which is composed of a series of closely related operations that are
designed to-perform collectively 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,toone of the independent segments of the object
program. segmentation in no way affects the need for qualification of
procedure-names to ensure uniqueness.

FIXED PORTION
The fixed portion is defined as that part of the object program that
is logically treated as if it were always in computer storage. This
portion of the program is composed of two types of computer storage segments, permanent segments and overlayable fixed segments.
A permanent segment is a segment in the fixed portion that cannot be
overlaid by any other part of the program.
An overlayable fixed segment is a segment in the fixed portion which,
although logically 'treated as if it were always in storage, can be
overlaid (if necessary) by another segment to optimize storage utilization. However, such a segment, if called for by the program, is always
made available in the state it was in when it was last used.
Depending on the availability of storage, the numoer of permanent
segments in the fixed portion can be varied through the use of a special
facility called SEGMENT-LIMIT, which is discussed in "Structure of
Program Segments."

INDEPENDENT SEGMENTS
An independent segment is defined as that part of the object program
which can overlay, and be overlaid by, either an overlay able fixed segment or another independent segment. An independent segment is always
considered to be in its initial state each time it is made available to
the program.
Segmentation Feature

309

Segmentation control and Structure
SEGMENT CLASSIFICATION
Sections that are to be segmented are classified by means of a system
of priority numbers.
The following criteria should be used:
•

Logical requirements: Sections that 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 that are less frequently used are normally
classified as belonging either to one of the overlayable fixed
segments or to one of the independent segments, depending on logic
requirements.

•

Frequency of use: Generally, the more frequently a section is
referred to, the lower its priority number should be; the less
frequently it is referred to, the higher its priority number should
be.

•

Relationship to other sections: sections that frequently
communicate with one another should be given equal priority
numbers. All sections with the same priority number constitute a
single program segment.

SEGMENTATION CONTROL
The logical sequence of the program is the same as the physical
sequence except for specific transfers of control. A reordering of the
object module will be necessary if a given segment has its sections
scattered throughout the source program. However, the compiler will
provide transfers to maintain the logic flow of the source program. The
compiler will also insert instructions necessary to load and/or initialize a segment when necessary.
Control may be transferred within a
source program to any paragraph in a section; that is, it is not
mandatory to transfer control to the beginning of a section.

STRUCTURE OF

PROG~

SEGMENTS

PRIORITY NUMBERS
Section classification is accomplished by means of a system of
priority numbers. The priority number is included in the section
header.

r----------------------------------------------------------------------,
I
Format
I
~----------------------------------------------------------------------i

I

I

section-name SECTION [priority-number].

I

I

IL ______________________________________________________________________ JI

All sections that have the same priority-number constitute a program
segment with that priority.
The priority-number must be an integer ranging in value from 0
through 99.
310

Part V -- Special Features

SEGMENT-LIMIT Clause
Segments with priority-numbers 0 through 49 belong to the fixed
portion of the object program.
Segments with priority-numbers 50 through 99 are independent
segments.
Sections in the declaratives portion of the Procedure Division must
not contain priority-numbers in their section headers. They are treated
as fixed segments with a priority-number of zero.
If the priority-number is omitted from the section header, the
priority is assumed to be zero.
When a procedure-name in an independent segment is referred to by a
PERFORM statement contained in a segment with a different priority
number, the segment referred to is made available in its initial state
for each execution of the PERFORM statement.

SEGMENT LIMIT
Ideally, all program segments having priority-numbers ranging from 0
through 49 are treated as permanent segments. However, when insufficient storage is available to contain all permanent segments plus the
largest overlayable segment, it becomes necessary to decrease the number
of permanent segments. The SEGMENT-LIMIT feature provides the user with
a means by which he can reduce the number of permanent segments in his
program, while these permanent segments still retain the logical
properties of fixed portion segments (priority numbers 0 through 49).

r----------------------------------------------------------------------,
I
Format
I
~----------------------------------------------------------------------~

I
I
I
[SEGMENT-LIMIT IS priority-number]
I
IL ______________________________________________________________________ JI

The SEGMENT-LIMIT clause is coded in the OBJECT-COMPBTER paragraph.
Priority-number must be an integer that ranges in value from 1
through 49.
When the SEGMENT-LIMIT clause is specified, only those segments
having priority-numbers from 0 up to, but not including, the priority
number designated as the segment limit are considered as permanent
segments of the object program.
Those segments having ~iority numbers from the segment limit through
49 are considered as overlayable fixed segments.
When the SEGMENT-LIMIT clause is omitted, all segments having
priority numbers from 0 through 49 are considered to be permanent
segments of the object program.
Segmentation Feature

311

Segmentation Restrictions
RESTRICTIONS ON PROGRAM FLOW
When segmentation is used, th~. . ",.f.• . /. Ol}-.?~.~."._.... ,.r.,.~..~.~~"f;"l.:.,.c.."t.,}.:.:-"". ().,,n.~s are placed on
the ALTER and PERFORM st-atemen.t.s!~~:m~. . . :

ALTER Statement

1.

A GO TO statement in a section whose priority number is 50 or
higher must not be referred to by an ALTER statement in a section
with a different priority number.

2.

A GO TO statement in-a section whose priority number is lower than
50 may be referred to by an ALTER statement in any section, even if
the GO TO statement to which the ALTER refers is in a segment of
the program that has not yet been called for execution.

PERFORM Statement

1.

2.

A PERFORM statement that appears in a section whose priority number
is iower than the segment limit can have within its range only the
following:
a.

Sections with priority numbers lower than 50.

b.

Sections wholly contained in a single segment whose priority
number is higher than 49.

A PERFORM statement that appears in a section whose priority number
is equal to or higher than the segment limit can have within its
range only the following:
a.

Sections with the same priority number as the section
containing the PERFORM statement.

b.

sections with priority numbers that are lower than the segment
limit.

When a procedure-name in a permanent segment is referred to by a.
PERFORM statement in an independent segment, the independent segment is
reinitialized upon exit from the performed paragraphs.

312

Part V -- Special Features

COpy Statement
SOURCE PROGRAM LIBRARY

F~CILITY

Prewritten source program entries can be included in a source program
at compile time. Thus, an installation can use standard file
descriptions, record descriptions, or procedures, without recoding them.
These entries and procedures are contained in user-created libraries;
they are included in a source program by means of a COpy statement.

COpy statement
The COpy statement permits the user to include prewritten Data
Division entries, Environment Division clauses, and Procedure Division
procedures in his source program.

r----------------------------------------------------------------------,
Format
I

I

t---------------------------------------------------------~------------~

I
I
I
I
I
I
I
:

I
I
I
I
I
I
I

COpy library-name ~~
[REP~ACING

[word-3

word-l

BY

BY

lword-2
J
literal-l
~
identifier-l\

l~~~~~~l-2

(

I

]. .• ].

IL ______________________________________________________________________
identifier-2 ~
JI

statement or clause may aJ?pear in the same

en~:s¥.a~, ~"h~

/;OPY

When the library text is copied from the library, compilation is the
same as though the text were actually part of the source program.

The COpy statement processing is terminated by the end of the library
text.

The text contained in the library must not contain any COpy
statements.

Library-name is the name of the library text contained in the user's
library. Library-name must follow the rules of formation for
program-name. The first eight characters are used as the identifying
name.

Source Program Library Facility

313

COpy Statement

r----------------------------------------------------------------------,
,
General Format
I
~--------------------------------------------------------------------~-1

I
I
I
I
I

,Option 1  in a particular
statement
op1--first operand in a generated arithmetic statement
op2--second operand in a generated arithmetic statement
d1,d2--number of decimal places defined for opl or op2, respectively
ir--intermediate result field obtained from the execution of a generated
arithmetic statement or operation. Irl, ir2, etc., represent
successive intermediate result q • These intermediate results are
generated either in registers or in storage locations. Successive
intermediate results may have the same location.
In the case of an arithmetic statement containing only a single pair
of operands, no intermediate results are generated, except when the
TRUNC option is specified for COMPUTATIONAL items. Intermediate results
are possible in the following cases:
1.

In an ADD or SUBTRACT statement containing multiple operands
immediately follo~ing the verb.

2.

In a COMPUTE statement for a series of arithmetic operations.

3.

In arithmetic expressions contained in IF or PERFORM statements.

In such cases, the compiler treats the statement as a succession of
operations
For example, the following statement:
COMPUTE Y

A + B

*

C - D / E + F

**

G

is replaced by

... * F
MULTIPLY B
DIVIDE E
ADD A
SUBTRACT ir3
ADD ir5

BY G
BY C
INTO D
TO ir2
FROM ir4
TO irl

yielding
yielding
yielding
yielding
yielding
yielding

irl
ir2
ir3
ir4
ir5
Y

COMPILER CALCULATION OF INTERMEDIATE RESULTS
The number of integer places in an ir is calculated as follows:
• The compiler first determines the maximum value the ir can contain
b,y performing the statement in which the ir occurs.
Appendix A:

Intermediate Results

333

1.

If an operand in this statement is a data-name, the value used
for the data-name is equal to the numerical value of the
PICTURE for data-name (e.g., PICTURE 9V99 has value 9.99).

2.

If an operand is a literal, the literal's actual value is used.

3.

If an operand is an intermediate result, the value determined
for the intermediate result in a previous arithmetic operation
is used.

4.

If the operation is division:
a.

If op2 is a data-name, the value used for op2 is the
minurnum nonzero value of the digit in the PICTURE for the
data-name (e.g., PICTURE 9V99 has the value 0.01).

b.

If op2 is an intermediate result, the intermediate result
is treated as though it had a PICTURE, and the mlnlmum
nonzero value of the digits in this PICTURE is used.

• When the maximum value of the ir is determined by the above
procedures, i is set equal to the number of integers in the
maximum 'tralue .
• The number of decimal places contained in an ir is calculated as:
Operation
+ or -

Decimal Places
dl or d2, whichever is greater
dl + d2
dl - d2 or dmax, whichever is greater
dmax if op2 is nonintegral or a data-name;
dl * op2 if op2 is an integral literal

*

/

**

Figure 53 indicates the action of the compiler when handling
intermediate results.

r--------T---------T-------------T-------------------------------------,
Value
Value
Value

I

I
I

I

of

I

of
i + did
I

I
I

I

of
i + dmax

I

I
I

Action Taken

I
I

~--------+---------+-------------+-------------------------------------~
I

<30

I

~--------~

I =30

I

Any
value

I

Any value

I
I

I

~

I
I

integer and £ decimal places
are carried for ir

I

I
I

~--------+---------+-~-----------+-------------------------------------~
I

I
I
I

>30

I

dmax

I

<30

I

~-------------~

=30

~

integer and 30 - ~ decimal places I
are carried for ir
I

I

I

I

I

I

~-------------+-------------------------------------~

I

I

I

I

I

L ________ L _________

Figure 53.

334

>30

I
I

I

30 - dmax integer and dmax decimal

I

I _____________ I _____________________________________
places are carried for ir
JI

~

~

Compiler Action on Intermediate Results

Supplementary Material

APPENDIX B:

SAMPLE PROGRAMS

The three programs 1n this appendix illustrate several" methods of
accessing mass storage files.
The three programs are:

1.
."

CREATION OF A DIRECT FILE
.
~

~

," :'"" ' . J ' . ,; ;; :. :,:
~,

ii-·

-~

'::.", "i~ r--"";-;:"

l~-~.;"··- ~'-"

"

.-

. • "::

--

:.: -. .

Appendix B:

Sample Programs

335

CREATION OF A DIRECT FILE

This program creates a file with direct organization through use of
an ACTUAL KEY -- using 'actual track addressing. The ACTUAL KEY has two
components:
1.

A track identifier, which is the actual track address, calculated
through a simple remainder randomizing technique. A field from the
input record CCD-ITEM-CODE) is converted to a track address
(TRACK1). CD-ITEM-CODE is divided by 19; the remainder is placed
in TRACK1. This gives a valid track address ranging in value from
o to 18. The program assumes that the file must begin on cylinder
102; therefore, a displacement value of 1020 is added to assure
that the CC field will contain the value of decimal 102.

2.

A unique record identifier, in this case TRACK-NAME, that contains
the CD-ITEM-NAME of the input record.

The UPDATING prQgram in the introduction updates the file that this
program creates.

IDENTIFICATION DIVISION.
PROGRAM-ID. CREATEDF.
REMARKS. ILLUSTRATE CREATION OF A DIRECT FILE.
THE FILE MAY BE
USED AS THE MASTER FILE FOR THE SAMPLE PROGRAM ~LLUSTRATED
IN THE INTRODUCTION TO THIS MANUAL.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-360-F50.
OBJECT-COMPUTER.
IBM-360-F50.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT DA-FILE ASSIGN TO SYS015-DA-2311-A-MASTER
ACCESS IS RANDOM
ACTUAL KEY IS FILEKEY.
SELECT CARD-FILE ASSIGN TO SYS007-UR-2540R-S.
DATA DIVISION.
FILE SECTION.
FD DA-FILE
DATA RECORD IS DISK
LABEL RECORDS ARE STANDARD.
01 DISK.
02 DISK-ITEM-CODE
PICTURE X(3).
PICTURE X(29).
02 DISK-ITEM-NAME
02 DISK-STOCK~ON-HAND PICTUkE S9(6) USAGE COMP SYNC.
PIC'I'URE S999V99 USAGE COMP SYNC.
02 DISK-UNIT-PRICE
PICTURE S9(9)V99 uSAGE COMP SYNC.
02 DISK-STOCK-VALUE
PICTURE S9(3) USAGE COMP SYNC.
02 DISK-ORDER-POINT
FO CARD-FILE
LABEL RECORDS ARE OMITTED
DATA RECOrtD IS CARDS.
01 CARDS.
PICTURE X(3).
02 CD-ITEM-CODE
PICTURE XC 29) •
02 CD-ITEM-NAME
PICTURE S9(6).
02 CD-STOCK-ON-HAND
02 CD-UNIT-PRICE
PICTURE S999V99.
PICTURE S9(9)V99.
02 CD-STOCK-VALUE
PICTURE S9(3).
02 CD-ORDER-POINT
PICTURE X(23).
02 FILLER

336

Supplementary Material

WORKING-STORAGE SECTION.
PICTURE S9(5) USAGE COMP SYNC.
77 SAVE
PICTURE S9(4) USAGE COMP SYNC.
77 QUOTIENT
PICTURE 9999.
01 TRACK1
01 TRACK2 REDEFIN~S TRACK1.
PICTURE 999.
02 CYL
PICTURE 9.
02 HEAD
01 KEY-1.
PICTURE S999 CO~W SYNC VALUE ZEROES.
02 M
PICTURE S9
COMP SYNC VALUE ZERO.
02 BB
PICTURE 8999 COMP SYNC.
02 CC
COMP SYNC.
PICTURE S999
02 HH
PICTURE X
VALUE LOW-VALUE.
02 R
02 TRACK-N~ill
PICTURE X(29).
01 THE-KEY REDEFINES KEY-1.
02 FILLER
PICTURE X.
02 FILEKEY
PICTURE X(37).
PROCEDURE DIVISION.
BEGIN.
OPEN INPUT CARD-FILE.
OPEN OUTPUT DA-FILE.
PARA-1.
READ CARD-FILE AT END GO TO BND-JOB.
MOVE CD-ITEM-CODE TO SAVE.
DIVIDE 19 INTO SAVE GIVING QUOTIENT
REMAINDER TRACK1.
ADD 1020 TO TQACK1.
MOVE CD-ITEM-NAME TO l'RACK-NAl.vili.
MOVE CYL TO CC.
MOVE HEAD TO HH.
MOVE CD-ITEM-COD3 TO DISK-ITEM-CODE.
MOVE CD-ITEM-NAME 'I'O DISK-ITEM-NAME.
MOVE CD-STOCK-ON-HAND TO DISK-STOCK-ON-HAND.
MOVE CD-UNIT-PRICE TO DISK-UNIT-PRICE.
MOVE CD-STOCK-VALUE TO DISK-STOCK-VALUE.
MOVE CD-ORDBR-POINT TO DISK-ORDER-POINT.
WR.
WRITE DISK INVALID KEY GO TO ERROR-ROUTINE.
GO TO PARA-1.
END-JOB.
CLOSE CARD-FILE DA-FILE.
DISPLAY "END OF JOB".
STOP RUN.
ERROR-ROUTINE.
DISPLAY "UNABLE TO WRITE RECORD".
DISPLAY TRACK-NAME.
GO TO PARA-1.

Appendix B:

Sample Programs

337

I ;:'; "~,

"'~

,

'

"'

~

,I
l-

N

q;

:: f"t1¥, 1!::'~!l:11~
'" ';
_~j'~1;)~ ~~ _~,:. ",":..'~ ~'" !~ .. ~
....

~

..

~.

','1'•

~

;

This program creates an indexed file. These records are presented in
ascending sequence by RECORD KEY. The APPLY clause builds the master
index.
IDENTIFICATION DIVISION.
PROGRAM-ID. CREATEIS.
REMARKS. ILLUSTRATE CREATION OF INDEXED SEQUENTIAL FILE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-360-FSO.
OBJECT-COMPUTER. IBM-360-FSO.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IS-FILE ASSIGN TO SYS01S-DA-2311-I-MASTER
ACCESS IS SEQUENTIAL
RECORD KEY IS REC-ID.
SELECT CARD-FILE ASSIGN TO SYS007-UR-2S40R-S
RESERVE 1 ALTERNATE AREA.
I-a-CONTROL. APPLY MASTER-INDEX TO 2311 ON IS-FILE.
DATA DIVISION.
FILE SECTION.
FD IS-FILE BLOCK CONTAINS 5 RECORDS
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD.
01 DISK.
02 DELETE-CODE
PICTURE X.
02 REC-ID
PICTURE 9(10).
02 DISK-FLDl
PICTURE X(10).
02 DISK-NAME
PICTURE X(20).
02 DISK-BAL
PICTURE 99999V99.
02 FILLER
PICTURE X(S2).
FD CARD-FILE RECORDING MODE IS F
LABEL RECORDS ARE OMITTED.
01 CARDS.
PICTURE 9(10).
02 KEY-ID
PICTURE X(20).
02 CD-NAME
PICTURE 99999V99.
02 CD-BAL
PICTURE X(43).
02 FILLER
PROCEDURE DIVISION.
BEGIN.
OPEN INPUT CARD-FILE.
OPEN OUTPUT IS-FILE.
PARA-l.
READ CARD-FILE AT END GO TO END-JOB.
MOVE LOW-VALUE TO DELETE-CODE.
MOVE KEY-ID TO REC-ID.
MOVE CD-NAME TO DISK-NAM~.
MOVE CD-BAL TO DISK-BAL.
WRITE DISK IiWALID KEY GO TO ERR.
GO TO PARA-l.
ERR.
DISPLAY "DUPLICATE OR SEQ-ERR" UPON CONSOLE.
DISPLAY KEY-ID UPON CONSOLE.
GO TO PARA-l.
END-JOB.
CLOSE CARD-FILE IS-FILE.
DISPLAY "END OF JOB" UPON CONSOLE.
STOP RUN.

338

Supplementary Material

This program randomly updates an existing indexed file.
The READ
IS-FILE statement causes a search of indexes for an equal compare
between the NOMINAL KEY obtained from the input record and the RECORD
KEY of the I-O file. If an equal compare occurs, the record is updated,
and the details of this update are printed. If a matching recora is not
found, the invalid key branch is taken.
IDENTIFICATION DIVISION.
PROGRAM-ID. RANDOMIS.
REMARKS. ILLUSTRATE ~ANDOM RETRIEVAL FROM IS-FILE.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-360-FSO.
OBJECT-COMPUTER. IBM-360-FSO.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IS-FILE ASSIGN TO SYS01S-DA-2311-I-MASTER
ACCESS IS RANDOM
NOMINAL KEY IS KEY-ID
RECORD KEY IS REC-ID.
SELECT CARD-FILE ASSIGN TO SYS007-UR-2S40R-S
RESERVE 1 ALTERNATE AREA.
SELECT PRINT-FILE ASSIGN TO SYS008-UT-2400-S-PROUT
RESERVE NO ALTERNATE AREAS.
I-O-CONTROL.
APPLY MASTE~-INDEX TO 2311 ON IS-FILE.
RERUN ON SYS002-UT-2400-S-CKPT EVERY 10000 RECORDS
OF IS-FILE.
DATA DIVISION.
FILE SECTION.
FD IS-FILE
BLOCK CONTAINS S RECORDS
RECORD CONTAINS 100 CHARACTERS
LABEL RECORDS ARE STANDARD
RECORDING MODE IS F
DATA RECORD IS DISK.
01 DISK.
PICTURE X.
02 DELETE-CODE
PICTURE 9(10).
02 REC-ID
PICTURE X(lC).
02 DISK-FLDl
PICTURE X(20).
02 DISK-NAME
PICTURE 99999V99.
02 DISK-BAL
PICTURE X(S2).
02 FILLER
FD CARD-FILE
RECORDING MODE IS F
LABEL RECORDS ARB OMITTED
DATA RECORD IS CARDS.
01 CARDS.
n .....
KEY~IDA
V,G
PICTURE 9 (10) •
02 CD-NAME
PICTURE X(20).
02 CD-AMT
PICTURE 99999V99.
02 FILLER
PICTURE X(43).
FD PRINT- F'ILE
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD
DATA RECORD IS PRINTER.

Appendix B:

-Sample Programs

339

01

PRINTER.
02 FORMSC
PICTURE X.
02 PRINT-ID
PICTURE X(lO).
02 FILLER
PICTURE X(lO).
02 PRINT-NAME
PICTURE X(20).
02 FILLER
PICTURE X(lO).
02 PRINT-BAL
PICTURE $ZZZ,999.99-.
02 FILLER
PICTURE X(10).
02 PRINT-AMT
PICTURE $ZZZ,ZZZ.99-.
02 FILLER
PICTURE X(10).
02 PRINT-NEW-BAL
PICTURE $ZZZ,ZZZ.99-.
WORKING-STORAGE SECTION.
77 KEY-ID
PICTURE 9(10).
PROCEDURE DIVISION.
BEGIN •
.oPEN INPUT CARD-FILE.
OPEN OUTPUT PRINT-FILE.
OPEN 1-0 IS-FILE.
PARA-l.
MOVE SPACES TO PRINTER.
READ CARD-FILE AT END GO TO END-JOB.
MOVE KEY-IDA TO KEY-ID.
READ IS-FILE INVALID KEY GO TO NO-RECORD.
MOVE REC-ID TO PRINT-ID.
MOVE DISK-NAME TO PRINT-NAME.
MOVE DISK-BAL TO P~INT-BAL.
MOVE CD-AMT TO PRINT-AMT.
ADD CD-AMT TO DISK-BAL.
MOVE DISK-BAL TO PRINT-NEW-BAL.
REWRITE DISK INVALID KEY GOTO NO-RECORD.
WRITE PRINTER AFTER POSITIONING 2 LINES.
GO TO PARA-l.
NO-RECORD.
DISPLAY 'NO RECORD FOUND' UPON CONSOLE.
DISPLAY KEY-ID UPON CONSOLE.
GO TO PARA-l.
END-JOB.
CLOSE CARD-FILE PRINT-FILE IS-FILE.
DISPLAY 'END OF JOB' UPON CONSOLE.
STOP RUN.

340

Supplementary Material

APPENDIX C:

AMERICAN NATIONAL STANDARD COBOL FORMAT SUMMARY AND RESERVED WORDS

t..'"

The Formats and Reserved words in tilis appendix have beerL printed iu a specially reduced size '\-!i
·pages n1JTIl.bereo in
sequence to make up a pocket-sized reference booklet for use while coding IBM American National Standard COBOL
programs. Al though mas t readers may prefer to retain this reference rna terial wi thin the manual, the booklet can be
prepared as follows:
Cut along trim lines.
Place sheets so that page numbers at lower right-hand corner are in ascending order in odd-number progression
(i.e., 1, 3, 5, etc.); lower left-hand page numbers will then be in descending order in even-number progression
(i.e., 16, lQ, 12, etc.).

~I

Fold trimmed sheets after collating.
Staple along fold if desired.
Punch for six-hole bin4er.

-----------------------------------~~-~~-----------------------------------

IBlf1 Reference Data n
DOS

e e

IBM Pull
American
National
Standard

COBOL

Appendix C: IBM Full American
National Standard COBOL

-

e
!:>
0

U
w

0:0:

::l

I-

..
C

°i

:z:

~
Ii:
II
-£

:e

-0

U

III
l1li:

11.1

•.

.:
II

~

J!

..

=<

"0

.Sl

E

;t;

e e

Format Summary and
Reserved Words

The general format of a COBOL program is illustrated
in these format summaries. Included within the general format is the specific format for each valid COBOL statement.
All clauses are shown as though they were required by the
COBOL source program, although within a given context
many are optional. Repetition of clauses has not been indicated. Several formats are included under special headings,
which are different from, or additions to, the general format.
Under t.~ese special headings are included formats peculiar
to the following COBOL features: Sort, Report Writer, Table
Handling,
Source Program Library Facility,

of this publication is
IBM DOS Full American National Standard COBOL, Order
No. GC28-6394-4.

e e
e e
IntenuIIIonaI B - ' - 1IechI_ Corpondlon
Data "-Ins! DI¥IIIon
1133"""'" A - . . . . PIHIs, New York 10804
(U.s.A. onIr)
Prin1lld in U.s.A.

IBII World Tracie CorpondIon
121 UnIted ~.PIUII
N_ York, " - York 10017
(InIerndonIII)

EXtr8Cled from GC28-6394-4

Not orderable S8~IV

~-------------------------------------------------------------------------.
TRIM HERE

9

2

Appendix C:

Format Summary and Reserved Words

341

o

2
TRIM
HERE
._--------------------------------------------------------------------------,
READ Statement

IDENTIFICATION DIVISION - BASIC FORMATS

FORMAT

{i~1~ON DIVISION.}

1

READ file-name [1':EXT] RECORD [INTO identifier]
[AT END imperative-statement]

PROGRAM-ID. program-name.
AUTHOR. [comment-entry] ...

FORMAT

2

~

INSTALLATION. [comment-entry] .. .

file-name RECORD [lliIQ identifier]
imperati~e-statement]

[INVALID KEY

DATE-WRITTEl\. [comment-entry] .. .
DATE-COMPILED. [comment-entry] .. .

REWRITE Statement

SECURITY. [comment-entry] .. .

~

REMARKS. [comment-entry] .. .

record-name [FROM identifier]

[I.KVALID KEY imperative-statement]
START Statement

1

:'QUALTO
START file-name [KEY IS

--

-

GREATER THAN]

>

{ 1':OT LESS THA1':
NOT~

ENVIRONMENT DIVISION - BASIC FORMATS

[INVALID KEY imperative-statement]

ENVIRONMENT DIVISION.

USE Sentence
CONFIGURATI01': SECTION.
SOURCE-CO~PUTER.

USE AFTER STA'ID-OF-PAGE
EXDIXG
E:\TER
EI\TRY

(xa)

(xac)

EXVIROX~fE:\T

(xa)
i

('a)

(spn)

w

~

w

::E:
~

...iX

(ca)
(xa)
(xac)
(xa)
ixac)

EOP
EQCAL
EQUALS
ERROR
ESI
EVERY
EXA\fIXE
EXCEEDS
EXCEPTlOl\
EXHIBIT
EXIT
EXTEND
EXTEXDED-SEARCH

(ca)
(ca)

(xa)

( xac)

\HSTER-IXDE:X

(xa)

\lERGE
,iESSAGE
:'fODE

(XiiC)

I

ca)

( xac)

I ,ac)

( ,ac)

(C'a)

(ca)

Il"rt)

( cal
(ca'

i idcllliji,

I-I TO idcllliti,

I-~

[H()l":\J)ED]

"\1."11':1{ SI"h-IiH lit

;ALTER

~IODCLES
~IORE-lABELS

lJrof"('cilll"C"-I/(l1Ill'-i".!.i2

[I'HOCEEV

[p/{lU"dUI"f"-IWflH'.31Q

XA\IED
XEGATl\'E
XEXT
XO
XO}.fIX_-\L
KOT
:\OTE
XSTD-REElS
XnlBER
XnlERIC
XDIERIC-EDITED

Til]

[PHOCEED

P((JfCCltllf"-II11ll/{"-:]
.~] 1!({/("('(h:r("·'l(lHll"."J.] .

Cl.OSE S!;.!i-n1l"llt

!~ HEW!\DI ]
(lSI : ./,"I c-II(/1I1( .-,' [HEEL]
C!-_._C\n [\\·ITII ll.OCK

r

[\\·1· -[I \ Vl HE"·[:\D/
[til "-IIIiIl'C-~0 [HEELJ
l'XIT
[IWC:~!

]J - . -

OBJECT-PROCRA~f

C:O\!l'l"TE Statemellt

OCCl-RS
OF
OFF

Co\IPl'TI·: hlllllif' I-I [HOl·:\DED]

O~IITTED

=

ha)
(xac)

(,po)

( ,ac)

.1 :;'t;,';;;;';:;'·XIII'''iOl/
LlOcUli-]

0:\

1-0
'xac-)

liN/if

OBJECT-CO\IPl-TER

GEXER_-\TF
GI\"IXC
GO
GOBACK
GREATER
GROUP

I-O-CO:\TROL
ID
lDEXTIFIC_-\TIOl\
iF
11\
I:\DE:X
I'\DEX-n
I,\DEXED
I,\DIG.-\TE
1,\ITlAl
I\HI.\UZE

l~ilt."!'()"Dl"C

[jdfli/('1(11-3 r-3J -

\lO\'E
\IlTrIPI.E
\IClTIPLY

FILE
FILE-CO"-TROI.
FIlE-LIWT

HEADI:\G
HIGH-VALUE
HIGH-\,.-\IXES
HOLD

_-\1)1)

I \.

idlll!i/icr-2/
\ /I"md-2
\

ME~IORY

( ,pn)

FILE-LI~fITS

I xac)

_-\I)D IIi/md-1

[O:\" SIZE CHBOl{ iIllJJ(Tatirf"-,.;fafc"IIICllr]

FD

FilLER
FI:\AL
FIRST
FOOTl:\C
FOR
FROM

liclell/ilil r-/

LIXAGE
LIXAGE-COUXTER
LI:\E
U:\E-COl-XTER
LI:\ES
LIXKAGE
LOCK
lOW-\,ALCE
LO\\,-\,ALCES

OPEX
OPTIO:\:>'!.
OR
ORG.-ISIZATIOX
OTHERWISE
Ol-TPl-T
OVERFLOW

t

)

[():\SIZI·:~ill""./"{/Ii •.,.-,/(//,'/II(""t]

IJITl. ..\HATI\-E S(,,·tillll

PROCEDUlE DIVISIO);_

DECLAH.\TI\-ES.

PAGE
1'_-\CE-COl-:\TER
PASSWORD
PERFOR\!
PE

{s('cfioll-'WIIII'

SECTlO);. LOSE

'("III('lIce.

{pau:"r.::aJd:-1HW1C" :"~('II/('nc(': ... } ... } ..

E:\D DFCL\IL\TI\-ES.

PH

(,spn)
(xac· )

PIC
PICn-RE
PLl'S
POI:\TER
POSITIO:\
I'OSITIOXIXG
P(NTIVE

DIS!'I .\ Y St"km .."t

irl' I/lili,
[ li/r"/(j1-2

1-2J .

.[~

5

16

-----------------------~------------------------------------------------TRIM HERE

Appendix

c:

Format Summary and Reserved Words

345

o

2
TRIM
HERE
------------------------------------------------------------------------,
OlnDE Statement

IBM AMERICAN NATIONAL STANDARD
COBOL RESERVED WORDS

li~l('nlifier-1jI I:\TO id('IIlificr-:! [ROl':\DED]

DIVIDE

--III('f(Il-1

No word in the following list should appear as a programmer defined name.
['he keys that appear before some of the words, and their meanings, are:

[0:\ SIZE EHROH illl/lemlirt'-.-Ialclllenl]

2

FORMAT

(xa)

before a word means that the word is an IBM extension to American
National Standard COBOL.

(xac)

hefore a word means that the word is an IB~1 extension to both
American National Standard COBOL and CODASYL COBOL.

(ca)

before a word means that the word is a CODASYL COBOL reserved word not incorporated in American National Standard
COBOL or in IBr-1 American l\ational Standard COBOL.

(sp)

before a word means that the word is an IBM function-name established in support of the SPECIAL-NAMES function.

(spn)

before a word means that the word is used by an IBM American
National Standard COBOL compiler, but not this compiler.

(asn)

before a word means that the word is defined by American National
Standard COBOL. hut is not used by this compiler,

,
.. jid('lIli/iU-11 \I:\TO) lid",wfi,'r-21 "
"
"
"_
m\IDE lileml-I
Il!!l' I/Iil('/(/I-:! I (,I\I':\(.rc/croll/iCT-3 [ROl:\DI-.D]
[RE\I.-\I:\DEH id"rolifi(,T-4] [0:\ SIZE EHHOH illl}l('f(Ilirr'-"llIlelll,'nl]

Ei\TER St,ltemcnt
E:"TEH

lllllt!UlI:.!£'-nallU'

[roulillC-namc].

EXA\II,:\E Statenwllt
1

FORMAT

JLXnL FIHST "1
l;~~~D1:\(;
J IUeTul-l

EXAl\II:\E ici.'nlifj(,T llL.Ll.!hli
[HEI'L\CI:\G

e e

!!I 1i/('ral-2]

2

FORMAT

(aSll)

EXAl\II;>\E identifier REI'LACIl'I:G

J~t~~_I:\G

Jl

lil('",/-[

~'/ilC'I'OI-2

l l':\TIL FIRST

(ca)
(ca)

EXIT Statement

-

l1lJrol!ra"ll-namc, EXIT _ _ .

(xa)

ACCEPT
ACCESS
ACTUAL
ADD
ADDRESS
ADVA!'ICING
AFTER
ALL
ALPHABETIC
ALPHANUMERIC
ALPHAl\:U~IERIC-EDITED

ALTER
ALTERNATE
AND
APPLY
ARE
AREA
AREAS
ASCENDING
ASSIGN
AT
AUTHOR

G O TO Statement

FORMAl'

(xac)

I

QQ IQ l' roceclrrrc-uamc-l
2

FORMAT

gQ

I9 /lTocedllr('-llCIme-l

[flTo('C'dllre-numc-2] ... DEPE:\DIl\:C 0;>\ ie/ell/ifier

e e

3

FORMAT

(ca)

(xa)

gQIQ.

IF Statl'ment
I,I\I-:\.T SE:\TE:\CE}

e e

(spn)
(spn)
(spn)
(xac)

(xa)

/.-lal('/l1('1I1-2

(a,.. )
(asn)

\IO\,E Statement
I

FORMAT

I identijier-llI TIl ic/clllifier-2
'

MOVE lliteral

[idC'/I/ifi"r-3] ,

e e

(Kill')

(spn)

BASIS
BEFORE
BEGINNING
BLANK
BLOCK
BOTTOM
BY
CALL
CANCEL
CBL
CD
CF
CH
CHANGED
CHARACTER
CHARACTERS
CLOCK. UNITS
CLOSE
COBOL
CODE
COLUMN
COM-REG
CmfMA
COMMU:XICATION
COMP

COMP-I
COMP-2
COMP-3
COMP-4
COMPUTATIO:-iAL
(xa)
COMPUTATlONAL-I
(xa)
COMPUTATIO,",AL-2
(xa)
COMPUTATIONAL-l
(Ia)
COMPUTATIONAL-4
COMPUTE
CO;>\FIGURATION
CONSOLE
('1')
CONTAINS
CONTROL
CONTROLS
COpy
(xac) CORE-INDEX
CORR
CORRESPONDING
(spo) COUNT
(sp)
CSP
CURRE]';CY
(xac) CURRENT-DATE
(xar) CYL-INDEX
(xac) CYL-OVERFLOW
(sp)
Cal
(sp)
CO2
(xa)
(xa)
(xa)
(xa)

('1')
(sp)
('1')
(sp)
(sp)
(sp)
(sp)
(sp)
(sp)
(sp)

III
DC
III

:z:
~

ii2
t-

coo
cos
coo
C04

C07
C08
C09
CIa
Cli
Cl2

DATA
DATE
DATE-COMPILED
DATE-WRITTEN
(spo) DAY
(ca)
DAY-OF-WEEK
DE
(xac) DEBUG
(ca)
DEBUG-CO;\;TEl\:TS
(spo)

(ca)

DEBUG-ITE~I

(ca)
(ca)

DEBUG-L1:\,E
DEBUG-NA~fE

2

FOR!\JAT

, jCOHHESI'O'\DI':\G/

MOVE

I

Qlill!

''

ic/C'lItl/l('r-l

"
IQ lC/ent·fier-2

.-----________________________________________________ -----------------_1
15

6

TRIM

346

Supplementary Material

HERE

___________________________________~!1~~__________________________________ _
:\1CLTIPLY Statement
FORMAT

1

Procedure Division Debugging Formots

, {identi fi er-ll
literal-I
)

~1ULTIPLY

EXHIBIT Statement

"
lrr ,dentifier-2

,'

[ROCNDED]

[O:\I SIZE ERROR imperat;,;e-statement]

r ~AMED

CHA:'I:CED :\"A:\1ED
,EXHIBIT
- - - ~l CHA:"IGED--

{identifier-I
} [identi fier -2
]
nonnumeric-literal-I
nonnumeric-literal-2'"

}

FORMAT

2

MULTIPLY {identifier-I} BY {identi fie r-21 GIVIl\G 'den 'fi -3
- - - hteral-l
_
l,teral-2 I __"_,
t, er
[ROL'::-IDED] [OK SIZE ERROR imperative-statement]

ON (Count-conditional) Statement

1

FORMAT
~

integer-I [AND EVERY integer-21 [UNTIL integer-31

:-';OTE Statement

} {statement , , '
}
imperative-statement, , '} {ELSE
{ NEXT SENTENCE
OTHERWISE ~~

ON
-

~Version

2

FORMAT

3)

{~nteg~-I } [AND EVERY {integer-2 }
,dent.fier-l

KOJ"E character string

-

--

identifier-2

OPE]\; Statement

]

, {file-name [REVERSED
OPEN.
[INPUT
WITH ~ REWIKD ] },' ,]

{integer-3 } ] {imperative-statement}
[ UNTIL
-'identifier-3
KEXT SE~TE:"ICE
ELSE
}
{ OTHERWISE

{statement",

l

[OUTPUT {file-name [WITH

:\EXT~f

~

RE\\ (greater than)
27-52. A through Z
________________________________
J

EBCDIC and ASCII Collating Sequences for COBOL
Characters -- in Ascending Order

SORT FEATURE

For ASCII-collated sorts, there are special considerations in the
Environment Division and in the Data Division.

ENVIRONMENT DIVISION

For ASCII-collated sorts, there are special considerations for the
ASSIGN clause ~_III"i

ASSIGN Clause

The ASSIGN clause for an ASCII collated sort has the same format as
for an EBCDIC collated sort.
However, the system-name must be in
the following format:
SYSnnn-class-device-C-name
The following considerations apply:
SYSnnn must specify the fixed sort work units assigned to the
sort-file. The first work unit for every sort-file in the program
must be assigned to SYS001, the second to SYS002, etc.
class may be specified as UT or DA.
360

Supplementary Material

device may specify a utility or mass storage device.

£

in the organization field specifies an ASCII collated sort.

specifies the external-name by which the sort-file is known to
the system. If the file has standard labels, the name field must be
specified as SORTWK1 for SYS001, SORTWK2 for SYS002, etc.

~

Note: For an ASCII-collated
permitted.

sort~

the buffer offset field is not

DATA DIVISION
., there are special considerations for the
'USAGE caluse.

USAGE Clause
If an ASCII-collated sort is requested, the sort keys must be
DISPLAY items, explicitly or implicitly.

Appendix E:

ASCII Considerations

361

Program Product Information -- Version 3

APPENDIX F:SYMBOLIC DEBUGGING FEATURE

A programmer uS1ng IBM Full American National Standard COBOL,
Version 3, under the Disk Operating System, has several methods
available to him for testing and debugging his progrwus. USe of the
symbolic debugging feature is the easiest and most efficient method
for testing and debugging and is described in detail in this
appendix.
The symbolic debug option produces a symbolic formatted dump of
the object program's data area when the program abnormally
terminates. It also enables the programmer to request dynamic dumps
of specific data-names at strategic points during program execution.
If two or more COBOL programs are link edited together and one of
them terminates abnormally, the program causing termination and any
callers compiled with the symbolic debug option, up to and including
the main program, will be given a formatted dump.
The abnormal termination dump consists of the following parts:

1.

Abnormal termination message, including the number of the
statement and of the verb being executed at the time of an
abnormal termination.

2.

Selected areas in the Task Global Table.

3.

Formatted dump of the Data Division including:
(a) for an SD, the card number, the sort-file-name, the type,
and the sort record.
(b) for an FD, the card number, the file-name, the type, SYSnnn,
DTF status, the contents of the Pre-DTF and DTF in
hexadecimal, and the fields of the record.
(c) for an RD, the card number, the report-name, the type, the
report line, and the contents of PAGE-COUNTER and
LINE-COUNTER if present .

.

(d> For an index-name, the name, the type, and the contents in
decimal.
Note: For DTFDA when ACCESS IS RANDOM, the actual key is not
provided in the Pre-DTF.
Operation of the symbolic debug option is dependent on
object-time control cards placed in the input stream. These cards
are discussed below.

Object-Time Control Cards
The operation of the symbolic debug option is determined by two
types of control cards:
Program-control card -- required if abnormal termination and/or
dynamic dumps are requested.
Appendix F:

Symbolic Debugging Feature

363

Line-control card -- required only if dynamic dumps are
requested.
Program-Control Cards: h program-control card must be present at
execution time for any program requesting symbolic debugging. A
program-control card must contain the following information:
The 1-8 character program-name of the COBOL program compiled
using symbolic debugging.
The logical unit and file-name assigned to the file produced at
compile time on SYS005.
Additional optional parameters can also be specified:
An entry used to provide a trace of a program-name when several
programs are link edited together.
Each time the specified
program is entered, its program name is displayed.
Two formats of the Data Division area in the abnormal
termination dump are allowed:
1.

Level-Ol items are provided in hexadecimal. Items
subordinate to level-Ol items are printed in EBCDIC if
possible. Level-77 items are printed both in hexadecimal
and EBCDIC.

2.

Level-71 items and items subordinate to level-Cl items are
provided in EBCDIC. If these items contain unprintable
characters, hexadecimal notation is provided. This is the
default option.

Line-Control Cards:
information:

A line-control card must contain the following

The card number associated with the point in the Procedure
Division at which the dynamic dump is to be taken. The number
specified is the compiler-generated card number.
Additional optional parameters can also be specified:
The position of the verb in the specified line number at which
the dynamic dump is to be taken.
When the verb position is not
specified, the first verb in the line is assumed. Any verb
position not exceeding 15 may be specified.
An equivalent to the COBOL statement nON n AND EVERY m UNTIL k
This option limits the request dynamic dumps to
n
specified times. For example "ON n" results in one dump,
produced the Qth time the line number is reached during
execution.
"ON n AND EVERY m" results in a dump the first time
at the Qth execution of the specified line number, anq
thereafter at every ~th execution until end-of-job.
Two formats of the Data Division areas displayed in the dynamic
dump are allowed:

364

1.

Level-Ol items are provided in hexadecimal. Items
subordinate to level-Ol items are provided in EBCDIC, if
possible. Level-77 items are provided both in hexadecimal
and EBCDIC.

2.

Level-77 items subordinate to level-Ol items are provided
in EBCDIC. If these items contain unprintable characters,
hexadecimal notation is provided.
Note that if a group
item is specified, neither the group nor the elementary
items in the group are provided in hexadecimal. This is
the default option.

Supplementary Material

Selected areas of the Data Division to De dumped. A single
data-name or a range of consecutive data-names can be
specified.
(If the programmer wishes to see a subscripted
item, he specifies the name of the item without the subscript;
this results in a dump of every occurrence of the subscripted
item. )
A dump of everything that would be dumped in the event of an

abnormal termination can also be specified. This allows the
programmer to receive a formatted dump at normal end-of-job.
To do this, the programmer must specify the generated statement
number of the STOP RUN, GOB~CK, or EXIT PROGRAM statement.

Sample Program -- TESTRUN
Figure 57 is an illustration of a program that utilizes the
symbolic debugging features.
In the following description of the
program and its output, letters identifying the text correspond to
letters in the program listing.
Because the SYMDMP option is requested on the CBL card, the
logical unit SYS005 must be assigned at compile time.

®

The CBL card specifications indicate that an alphabetically
ordered cross-reference dictionary, a flow trace of 10
proced~res, and the symbolic d~bug option are being requested.
An alphabetically ordered cross-reference dlctionary of
data-names and procedure-names is produced by the compiler as a
result 'of theSXREF specification on the CBL card.

®

The file assigned at compile time to SYS005 to store
information is assigned to SYSOU9 at execution time.

®

The SY~~MP control cards placed in the input stream at
execution time are printed along with any diagnostics.

~

SY~illMP

The first card is the program-control card where:
(a) TESTRUN is the PROGRAM-ID.
(b) 9 is the logical unit t9 which the SYMDMP file is
assigned.
(c) MT indicates that the SYMDMP file is on tape.
(d)

o

(HEX) indicates the
dump.

fo~mat

of the abnormal termination

The.second card is a line-control card which requests a
(HEX) formatted dynamic dump of COUNT, J.~AME-FIELD,
NO-OF-DEPENDENTS, and RECORD-NO prior to the first and
every fourth execution of generated card number 71.
The third card is also a line-control card which requests a
(HEX) formatted dynamic dump of wORK-RECORD and B prior to
the execQtion of generated card number 80.

®

The type code combinations used to identify data-names in
abnormal terrrdnation and dynamic dumps are defined. Individual
codes are illustrated in Figure 56.
The dynamic dumps requested by the first line-control card.
Appendix F:

Symbolic Debugging Feature

365

®

The dynamic dumps requested by the second line-control card.
Program interrupt information is provided by the system when a
program terminates abnormally.
The statement number information indicates the number of the
verb and of the statement being executed at the time of the
abnormal termination.
The name of the program containing the
statement is also provided.
A flow trace of the last 10 procedures executed is provided
because FLOW=10 was specified on the CBL card.
Selected areas of the Task Global Table are provided as part of
the abnormal termination dump.

®

For each file-name, the generated card number, the file type,
SYSnnn, the DTF status, and the fields of the Pre-DTF and DTF
in hexadecimal are provided.

®

The fields of records associated with each FO are provided in
the format requested on the program-control card.

®

The contents of the fields of the Working-storage Section are
provided in the format requested on the program-control card.

®

The values associated with each of the possible subscripts are
provided for data items described with an OCCURS clause.
Asterisks appearing within the EBCDIC representation of the
value of a given field indicate that the type and the actual
content of the field conflict.

Note: When using the symbolic debugging option, level numbers
appear "normalized" in the symbolic dump produced.
For example, a
group of data items described as:
01

RECORDA.
05 FIELD-A.
10 FIBLD-Al PIC X.
10 FIELD-A2 PIC X.

will appear as follows in symbolic debugging output:
01
02
03
03

RECORDA •.•
FIELD-A •••
FIELD-Al •••
FIELD-A2 •••

Debugging TESTRUN

366

1.

Referring to the statement number information J
provided by
the symbolic debug option, it is learned that the abend
occurred during the execution of the first verb on card 80.

2.

Generated card number 80 contains the statement COMPUTE B
1.

3.

Verifying the contents of B at the time of the abnormal
termination R it can be seen that the usage of B (numeric
packed) conflicts with the value contained in the data area
reserved for B (numeric display).

Supplementary Material

=B

+

4.

The abnormal termination occurred while trying to perform an
addition on a display item.

More complex errors may require the use of dynamic dumps to
isolate the problem area.
Line~control cards are included in
TESTRUN merely to illustrate how they are used and the output they
produce.

r--------------------T---------------------------------------------,
I
Code
I
Meaning
I
~--------------------+---------------------------------------------~
Alphabetic
I
A
Binary
B
I
Display
D
I
Edited
E
I
i

I
*
I
I
I
I
I
I
I
IL ___________________ _
Figure 56.

Individual Type Codes Used in

I I JOB DEElUGL
I I OPTION NODECK, LINK, LIST, LISTX, SYM, ERRS
I I ASSGN SYS005,X' 183' ~
/ I EX£C FC:OBOL

SY~IDMP

Output

20.36.22

\.V

Figure 57.

Using the Symbolic Debugging Features to Debug the
Program TESTRUN (Part 1 of 11)

Appendix F:

Symbolic Debugging Feature

367

IBM DOS AMFRICAN NATIONAL STANDARD COBOL

VERSION 3 REL 3.0 PP ;<0. 5736-C32

----®

CBL SXREF,FLOW=10 ,sn:m:p, QUOTE.,SEQ
00001
000010 IDENTIFICATION DIVISIOl~.
00002
000020 PROGRAM-ID. TESTRUN.
00003
000030
AUTHOR. PROGRAMMER :"AM,.
00004
INSTALLATION.
NEW YORK DEVELOPMENT CENTER.
00005
DATE-WRITTEN.
APRIL 18,1973.
00006
DATE-COMPILED. 04/27/13.
00007
REMARKS.
THIS PROGRAM HAS BEEN WRITTEN A.S A SAMPLE. PROGRAM FOi(
00008
COBOL USERS.
IT CREATES AN OUTPUT FILE AND READS IT BACK
00009
AS INPUT.
00010
000100
00011
000110 ENVIaONi'lENT DIVISION.
00012
000120 CONFIGURATION SECTION.
00013
000130 SOURCE-COMPUTER. IBM-360-H50.
00014
000140 OBJECT-Cmr.PUTER. IBM-360-d50.
00015
000150 INPeT-OUTPUT S;';CTION.
00016
000160 FILE-CONTROL.
SELECT FILE-l ASSIGN TO SYS008-UT-2400-S.
00017
000170
00018
000180
SELECT FILE-2 ASSIGN TO SYS008-UT-2400-S.
00019
000190
00020
000200 DATA DIVISION.
00021
000210 FILE SECTION.
00022
000220 FD FILE.-l
00023
000230
LABEL RECORDS ARE OMITTED
00024
000240
BLOCK CONTAINS 5 RECORDS
00025
000250
RECORDING MODE IS F
00026
000255
RECORD CONTAINS 20 CHARACTERS
00027
000260
DATA RECORD IS RECORD-I.
RECORD-l.
00028
000270 01
05 FIELD-A PIC X(20).
00029
000290 FD FILE-2
00030
000300
LABEL RECORDS ARE OMITTED
00031
000310
BLOCK CONTAINS 5 RECORDS
00032
RECORD CONTAINS 20 CHARACTE~S
000320
00033
RECORDING MODE IS F
000330
00034
DATA RECORO IS RECORD- 2.
00035
000340
RECORD-2.
00036
000350 01
05 FIELD-P.. PIC X(20).
00037
00038
000370 WORKING-STORAGE SECTION.
FILLER.
00039
000380 01
00040
02 KOUNT PIC S99 COMP SY,~C.
02 ALPHABET PIC X(26) VALUE wABCDEFGHIJKLMNOPIdRSl'UVWXYZ w•
00041
02 ALPHA REDEFINES ALPHABET PIC X OCCURS 20 TIMES.
OC042
02 NUMBR PIC S99 COMP SYNC.
00043
000420
02 DEPENDENTS PIC X(26) VALUE w01234012340123401234012340 w•
00044
02 DEPEND REDEFINES DEPENDENTS PIC X OCCURS 2b TIMES.
00045
C00450 01 WORK-RECORD.
00046
C00460
05 NAME-FIELD PIC X.
00047
000Ll8
0001170
05 FILLER PIC X.
00049
000480
05 RECORD-NO PIC 9999.
05 FILLER PIC X VALUE IS SPACE.
00050
000490
05 LOCATION PIC AAA VALUE IS wNYC w•
00051
GO:; FILLER PIC X VALUE IS SPAC:.
00052
000510
(5 NO-OF-DEPENDENTS PIC XX.
00053
000520
05 FILLER PIC X(7) VALUE IS SPACES.
00054
01 R!>CORDA.
00055
02 A PICTURE 89(4) VALUE 1234.
00056
02
B REDEFINES A PICTURE S9(7) COMPUTATIONAL-3.
00057
000550 PR:lCE0URE DIVISION.
00058
BEGIN.
00059
NOTE THAT l'hE FOLLOWING OPENS THE OUTPUT FILE
00060
TO BE CREATED AND INITIALIZES THE COUNTERS.
00061
STEP-l.
OPEN OUTPUT FILE-I.
MOVE ZERO TO KOUNT, NUl-;BR.
00062
NOTE rHAT THE FOLLOWING C.il.EII.TES INTERNII.LLY THE
00063
RECORDS TO BE CONTAINED IN THE FILE, WRITES THE.r'.
00064
ON TAPE, AND DISPLAYS THEN ON THE CONSOLE.
00065
STEP-2.
ADD 1 TO KOUNT, NUMBR.
MOVE ALPHA (KOUN'I) TO
00066
NAME-FIELD.
00067
MOVE DEPEND (KOUNT) TO NO-OF-DEPENDENTS.
00068
MOVE NUMBR TO RECORD-NO.
00069
000660
STEP-3.
DISPLAY WORK-RECORD UPON CONSOLE.
00070
WRITE RECORD-l FROM WORK-RECORD.
00071
STEP-4.
PERFORM STEP-2 THRU STEP-3
00072
UNTIL KOUNT IS EQUAL TO 26.
00073
NOTE THAT THE FOLLOWING CLOSES THE OUTPUT FILE
00074
AND REOPEl'IS IT AS INPUT.
00075
000720 STJ;;P- 5. CLOSE FILE-l. OPEN INPUT FILE- 2.
00070
NOTE THAT THE FOLLOwING READS BACK THE FILE
00077
AND SINGLES OUT EMPLOYEES WITH ,~O DEPENDENTS.
00078
STEP-6.
READ FILE-2 RECORD INTO WORK-RECORD AT END GO TO STEP-S.
00079
COMPUrE B = B + 100080
SThP-7.
IF NO-OF-DEPENDENTS IS J"QUAL TO ·0· MOIiE ·Z· TO
00081
NO-OF-DEPENDENTS.
EXHIBIT NAMED WORK-RECORD.
00082
GO TO STEP-6.
00083
000780 STEP-8. CLOSE FILE-2.
00084
000790
STOP RUN.
00085

Figure 57.

368

Using the Symbolic Debugging Features to Debug the
Program TESTRUN (Part 2 of 11)

Supplementary Material

20.30.27

04/27173

TESTRUN

20.36.27

INTRNL NAt'£

THT

SOURCE NP-_M..£

DN~I=1-11l8

FD
01
02
FD
01
02
01
02
02
02
02
02
02
01
02
02
02
02
02
02
02
02
01
02
02

FILE-l
RECORD-l
FIELD-A
FILE-2
RECORD-2
FIELD-A
FILLER
KOUNT
ALPHABET
ALPHA
NUMBR
DEPENDENTS
DEPEND
wORK-RECORD
NAL'1E- FIELD
FILLER
ReCORD-NO
FILLER
LOCATION
FILLER
NO-OF- DEPENDENTS
FILLER
RECORDA
A
B

DNM=1-179
DNM.=1-200
DNM=1-2l7
DNM=1-248
D;I!M=1-269
DNM.=1-289
DNM=1-308
DNM=1-323
DNM=1-3111
DNM=1-359
DNM=1-374
DNM=1-3911
DNM=1-1I10
DNM=I-434
DNM=1-454
[jN~;=1-lI73

DNM=I-492
DNM=2-000
DNM=2-018
DNM=2-037
DNM=2-063
DNM=2-082
DNM=2-102
DNM=2-113

04/27/73
flll.SE

DTF=Ol
BL=l
BL=l
DTF=02
BL=2
BL=2
BL=3
BL=3
BL=3
BL=3
BL=3
BL=3
BL=3
BL=3
BL=3
BL=3
SL=3
BL=3
BL=3
BL=3
BL=3
BL=3
BL=3
BL=3
BL=3

DISPL

000
000

INTRNL NAME

DeFINITION

DNM=1-148
DN!r.=1-179
DNM=1-200

DS OCL20
DS 20C

DN~j=1-2l7

000
000
000
000
002
002
OlC
OlE
OlE
038
038
039
03A
03E
03F
042
0113

DNr.;=1-2118
DNM=1-269
DNM=1-289
DNlt.=1-308
DNM=1-323

DS
DS
DS
DS
DS

DN~:=1-34l

os

m:IM=1-359
DNM=1-374
DNM=I-394
DNM=1-4l0
DNM=I-11311
DNM=I-4511

DS
DS
DS

DN~:=1-473

DS

DNM=1-492
DNM=2-000
DNM=2-0l8
DNM=2-037

DS
DS
DS
DS

V""
050

DNM.=2-063

DS 7C

DNM=2-082

050
050

DN~;=2-l02

DS OCL4
DS 4C
DS liP

DNM=2-113

DS

DS
DS

OCL20
20C
OCL56
lH
26C
lC
lH
26C
lC
OCL20
lC
lc
lIC
lC
3c
lC
2c

USAGE
DTFMT
GR:>UP
DISP
DTFMT
GROUP
DISP
GROUP
COMP
DISP
DISP

R

0

Q

M
F
F

R

0

R

0

CO~;P

DISP
DISP
GRJUP
DISP
DISP
DISP-NM
DISP
DISP
DISP
DISP
DISP
GRJUP
DISP-NM
COM.P-3

R

MEMORY MAP
001100

TGT
SAVE AREA
SwITCH
TALLY
SORT SAVE
ENTRY-SAVE
SORT CORE SIZE
NSTD-REELS
SORT RET
WORKING CELLS
SORT FILE SIZE
SJRT MODE SIZE
PGT-VN TBL
TGT-VN TBL
SORTAS ADDRESS
LENGTH OF VN TBL
LNGTH OF SORrAB
PGM ID
ACINITll
UPSI SWITCHES
DEBUG TABLE PTR
CURRENT PRIORITY
TA LENGTH
PROCEDURE BLOCKI PTR
UNUSED
OVERFLOW CELLS
BL CELLS
DTFADR CELLS
TEMP STORAGe
TEMP STORAGE-2
TEMP STORAGE-3
TEMP STORAGE-II
ELL CELLS
VLC CELLS
SBL CELLS
INVEX CELLS
SUBADR CELLS
ONCTL CELLS
PFMCTL CELLS
PFMSAV CELLS
VN CELLS
SAllE AREA =2
XSASW CELLS
XSA CELLS
PARMl CELLS
RPTSAV "..REA
CHECKPT CTR
IOPTR CELLS

Figure 57.

00400
001l1l8

0044C
001150

001154
00458
001l5C

001l5E
001160
00590
005911
00598
0059C
005AO
005Al1
005A6
005A8
005BO
005B4
005EC

oosco

005Cl
005C4
005C8
005CC
005CC
005D8
OOSEO
005E8
005E8
005E8
005E8
005EC
005EC
005EC
005EC
005FlI
005F4
005FlI

005F8
005FC
005FC
005FC
005FC
00600
00600
00600

Using the Symbolic Debugging Features to Debug the
Program TESTRUN (Part 3 of 11)

Appendix F:

Symbolic Debugging Feature

369

TESTRUN

04/27/73

20.36.27

LITERAL POOL (HEX)
00668 (LIT+O)
00680 (LIT+24)

00000001
5BC2C6C3

001A1C5B
D4ElID300

5BC2D6D7
COOOOOOO

C505405B

5BC2C303

ObE2C55B

DISPLAY LIrERALS (BCD)
, WORK-RECORD'

0068C (LrL+36)

PGT

00610

DEBUG LINKAGE AREA
OVERFLOW CELLS
VIRTUAL CELLS
PROCEDURE NAME CELLS
GENERATED NAME CELLS
SUBOTF ADDRESS CELLS
VNI CELLS
LITERALS
DISPLAY LITERALS
PROCEDURE BLOCK CELLS

00610
00618
00618
0063C
0064C
00660
00660
00668
0068C
00698

REGISTER ASSIGNMENT
REG 6
REG 7
REG S

BL =3
BL =1
BL =2

WORKING-STORAGE STARTS AT LOCATION 00100 FOR A LENGTH OF 00058.
59

62

62

*S'lATISTICS*
*STATISTICS*
*OPTIONS IN EFFECT*
*OPTIONS IN EFFECr*
*OPTIONS IN EFFECT*
*OPTIONS IN EFFEC:::*

Figure 57.

370

000698
000698
00069C
00069E
0006A2
0006Al1
0006A6
0006AA
0006AC
0006BO
0006B2
0006B4
0006B8
0006BA
0006BE
0006C2
0006C6
0006C8
0006CA
0006CC

START
58 FO
05 EF
58 FO
05 IF
003B
58 FO
05 EF
58 FO
05 IF
003E
58 FO
05 EF
58 20
41 10
58 00
18 1I0
07 00
05 FO
50 00

C 018
C 01C
C 018
C OlC
C 018
D ICC
C 05F
0 1D8

F 008

SOURCE RECORDS
85
PARTITION SIZE
495560
PMAP RELOC ADR
NONE.
LISTX
QUOTE
FLAGW
NOCLIST
NOSTATE
TRUI'C

EQU
[,

BALR
L
BALR
DC
L
BALR
L
BALR
DC
L
BALR
L
LA
L
LR
BCR
BALR
ST

*
15,018(0,12)
111,15
15,OlCCO,12l
1,15
X'OO3B'
15,018CO,12)
14,15
15,01CCO,12)
1,15
X'003E'
15,018(0,12)
14,15
2 , ICC ( 0 ,13 )
1,05F(0,12)
0,108 (0,13)
4,0
0,0
15,0
0, 008 (0,15)

OArA IT El>lS
LINE COUNT
SPACI,'/G
SYM
NOCATALR
ZWE
NOSUPMAP
SYMDMP
SEQ

25
56
1

V EPENDENTS

AN

00713A

000049

02 RECORD-NO

@

Figure 57.

00C9

Using the Symbolic Debugging Features to Debug the
Program TESTRUN (Part 7 of 11)

A.ppendix F:

Symbolic Debugging Feature

373

TBSTRUN
LOC
007100

AT CARD 000071
CARD
LV NAME
OOOOqO

02 KOUNT

TYPE

VALUE

NB-S

+13
OOOD

AN

M

(HEX)
007138

0000q7

02

00nq3

000053

02 NO-OF-DEPENDENTS

AN

00713A

0000q9

02 RECORD-NO

ND

TESTRUN
LOC

l~AME-FIELD

AT CARD 000071
CARD
LV NAME

TYPE

VALUE

NB-S

+17
0011

02 NAME-FIELD

AN

Q

000053

02 NO-OF-DEPENDENTS

AN

0000Q9

02 RECORD-NO

ND

0017

TYPE

VALUE

NB-S

+21
0015
U

007100

OOOOqO

02 KOUNT

007138

0000Q7

0071Q3
00713A

(HEX)

TESTRUN
LOC
007100

0013

AT CARD 000071
CARD
LV NAME
OOOOQ 0

02 KOUNT
(HElD

007138

OOOOQ 7

02 NAME-FIELD

AN

0071Q3

000053

02 NO-OF-DEPENDENTS

AN

00713A

GOOOQ9

02 RECORD-NO

ND

0021

TYPE

VALUE

NB-S

+25
0019
y

TESTRUN
LOC
007100

AT CARD 000071
CARD
LV NAME
OOOOQO

02 KOUNT
(hEX)

007138

000U47

02 NAME-FIELD

AN

007143

000053

02 NO- OF- DEPENDENTS

AN

00713A

000049

02 RECORD-NO

ND

0025

TYPE

VALUE

®
TESTRUN
L0C

AT CARD 000080
CARD
LV NAl-1E
000046

01 WORK-RECORD

007138
007138
007139
00713A
00713L
00713F
007142
0071li3
007145

0000Q7
0000li8
000049
000050
000051
000052
000053
00005Q

02
02
02
02
02
02
02
02

007150

000057

02 B

(HEX)
NAME-FIELD
FILLER
RECORD-NO
FILLER
LOCATION
FILLER
NO-OF-DEPE)lDENTS
FILLER

AN
AN
ND
AN
A
AN
AN
AN
NP-S
(hEX)

Figure 57.

374

C1C1FOFO FOFlQOD5 E8C3liOFO
A
A
0001

4040li040 1I040liOliO

NYC

*1*2*3*
F1F2F3C4

Using the Symbolic Debugging Features to Debug the
Program TESTRUN (Part 8 of 11)

Supplementary Material

COBOL ABEND DIA.GNOSTIC AIDS

I,i'i'E~RiJ2r

CODE 7

LAST PSW ADDR BEFORE ABEllO D000790E

~

PROGRA.;'GT-V~

Figure 57.

VALUE
00000000
0000001A.
1I000790E
3COOOOllB
00000000
00000000
00007698
00000000
0000
7E10
000071E8
F2F640D5
31007116C
00000000
00008201l
0000001A
00007137
00007610
10007E08
1C7ECBE3
00000000
00000000
ClIE2D7FO
F3F090EC
010896FF
F7C9
D201
TESTRUN
00007000
1I7FOl"030
00000200
00
000101l
91B01000
41110002

0105010B 00009998 80007BEE
000071EB 500079FA. 00007100
00007610

.000072C8
E8C340FO
1I0000005
00000000
00000103
01000800
500079FA
81100CEBO
00000109
8B030141

0000001A.
404040110
0800711A.0
00000101
000075118
00007700
00007100
0700751A
3100751C
1B130B61

000071E8
4040ti040
00000000
00000000
00000000
000uBDC8
00007260
40000006
1I0000005
5C10C6E2

00007908 1I000790A 000071E8 00007330
000072711 00007330 000079ClI 00007000

500079FA
00007F10
06007E10
00000000
OllOOABEO
00007137
00007330
3100751C
08007568

00000000
BOOOCEBO
60000101
00000000
2008C4D2
000077E4
000079c4
40000005
00000000

FF000100 E9C1FOFO

0700746h 40000006
920074CO
00000000
E2D8FOFl
0000001A
00007000
000271;50
1E007578

00000008
00000000
000077E2
0000001A
700077EA
000071;78
30000001

4160007C

00007274 ()0007330 00007100
00007170 00007IE8
00000000 0000026C
00000000

0000711B 00007137 0000780C 0000780C
06704450

4780FlFil. OAOOOMO 000009AA 5F431B75

Using the Symbolic Debugging Features to Debug the
program TESTRUN (Part 9 of 11)

Appendix F:

Symbolic Debugging Feature

375

DATA DIVISION 'JUMP OF TESTRUN
LOC

CARD
000017

TYPE

LV NAl'lE

®

FD F'ILE-1

PRE-DTF
DTFMT

007158
007170
007190
0071BO
0071DO

007274
007274

000028

01 RECORD-1

000029

02 FIELD-A

000018

FD FILE-2

®

007330
007330
007100
007118
007130
007100
007102

®

007102
007103
007104
007105
007106
007107
007108
007109
00710A
00710B
00710C
00710D
00710E
00710F
007110
007111
007112

000036

01 RECORD-2

000037

02 FIELD-A

000039

01 FILLER

376

®

00000000
000071BO
8bBCF018
0000732B
00000000

OCOOOOCO
00007AC8
41EOE001
00640063
OCOOOOOO

D8C1FOFO F'lF740D5 E8C340F1
QA0017 NYC 1

01010014
00008200
10000000
00007330
00000000

00000000
OCOO0108
24007902
00007330
00000000

(HEX)
AN

CD

(HEX)
NB-S
AN
*AN

(SUBll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

17

Figure 57.

00000000
000071A8
00000000
00000014
00000000

OOOOOliOO
1160E2E8
58201044
00000000
00000000

E2F'OFOF8
01007260
00000000
00008200

40400162
20000064
C3009A98
OCOO0108

40404040 404040 lL O

STANDARD SEQUENTIAL, ASSIGNED TO SYS008, OPEN INPUT

02 KOUNT
02 ALPHABET
02 ALPHA

®

00000000
OCOOO108
00000000
000072C8
00000000

(HEX)

PRE-OTF
DTFMT

000040
000041
000042

01010014
00009200
00000000
000072C8
01010014

AN

0071DO
0071E8
007208
007228
007248

VALUE

STANDARD SEQUENTIAL, ASSIGNED TO SYS008, CLOSED

00000000
00007220
00000001
00000014
00000000

00000000
00007228
86BCF018
00007393
00000000

OCOOOOOO
00007 AC8
41EOE001
00640063
07000700

00000000
11E8E2E8
58201044
00000000
07000700

E2FOFOF8
02007398
00009AA;:;
E9ClFOFO

C1C1FOFO FOF'l40D5 E8C340FO
AA0001 NYC 0

40404040 40404040

001AC1C2 C3C4C5C6 C7C8C901
E6):;7E8E9 001AFOF1 F2F3F4FO
F3F4FOF1 F2F3F4FO
+26
ABCOEFGHIJKLMNOPQkSTUVWXYZ

02D30405 0607D809 E2E3E4E.5
F1F2F3E'4 FOF1F2F3 F4FGFlF2

A

B
C
D
E

F
G
H

I
J
K
L
M
N

o
P
Q

Using the Symbolic Debugging Features to Debug the
Program TESTRUN (Part 10 of 11)

Supplementary Material

40400272
00000064
00009A98
F2F640D5

D1\.TA DIVISION DUl'.? OF TESTRUN

LOC
007113
007114
007115
007116
007117
007118
007119
00711A
00711B
00711C
00711E

CARD

000043
000044
000045

007150
007150
007150

ST
U

V
W
X
y
Z

NB-S
AN
*AN

02 NUl'iBR
02 DEPENDENTS
02 DEPEND

@

(SUBD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

000046

01 WORK-RECORD

000047
000048
000049
000050
000051
000052
000053
000054

02
02
02
02
02
02
02
02

000055

01 RECORDA

000056
000057

02 A
02 B

VALUE
R

18
19
20
21
22
23
24
25
26

00711E
00711F
007120
007121
007122
007123
007124
007125
007126
007127
007128
007129
00712A
007120
00712C
00712D
00712E
00712F
007130
007131
007132
007133
007134
007135
007136
007137
007138
007138
007139
00713A
00713E
00713F
007142
007143
007145

TYPE

LV N1\.ME

+26
01234012340123401234012340

4
0
1
2
3
4
0
1
2
3
4
0
1
2
3
4
0

0

NAME-FIELD
FILLER
RECORD-NO
FILLER
LOCATION
FILLER
NO-OF-DEPENDENTS
FILLER

0

(HEX)

C1C1FOFO FOF140D5 E8C340FO
A
A
0001

AN
AN
ND
AN
A
AN
AN
AN

40404040 40404040

NYC

(HEX)
ND-OT
@--NP-S

F1F2F3C4
+1234
*1*2*3*

END OF' COBOL DIAGNOSTIC AIDS

Figure 57.

Using ~he Symbolic Debugging Features to Debug the
Program TESTRUN (Part 11 of 11)

~ppendix

F:

Symbolic Debugging Feature

377

Program Product Information -- Version 3

APPENDIX G:

COMBINED FUNCTION CARD PROCESSING

The IBM System/370 card punch devices offer more flexible
processing capabilities than former card devices. When equipped
with appropriate special features, these devices can be used
separately as a card reader, as a card punch, or as a card printer.
Any two or all three of these functions can be combined, so that
those functions specified are all performed during one pass of a
card through the device.
For anyone data card, the operations, when specified, must be
performed in the following order: read, punch, print. Anyone
function may be omitted -- that is, no file need be defined for that
function.
The remaining functions must still be performed in the
order shown. All operations on one card must be completed before
operations on the next card are begun, or there is an abnormal
termination of the job. When such combined function processing is
to be used, the programmer must be aware of the special
considerations needed to accomplish the desired results.
COBOL handles each of the separate functions to be combined as a
separate logical file.
Each such logical file has its own file
structure and procedural processing requirements. However, because
such combined function files (also called associated files) refer to
one physical unit, the user must observe certain restri'ctions during
processing. The following sections explain the programming
requirements for combined function processing in DOS American
National Standard COBOL.

I -- ENVIRONMENT DIVISION CONSIDERATIONS
For combined function processing there are special considerations
for the SPECIAL-NAMES Paragraph, and for the SELECT, ASSIGN, and
RESERVE Clauses.

SPECIAL-NAMES Paragraph

~,·i::':~~,f~~1~*~~~~~~:~~~~~s~~~.l~~"~~~¢A~e. ·.<,o~~~~~.;.;X~. ,:.~~§i~~d;t:~enti1ii~tt~

'::f:?+(~~ ·p~rms,e . . ~~., ,.•. ~··:sp~:~fJ;ed ·l;ll 't:be<~ECfJ\L-;~S ,]?a.ra:9'ra'Pl1;;~
"~pe' ·~on:ie:.....,.~a;mes

··:~t:i.ori
501
S02

503
5.04

S05

raay l?e. . ;equ.at~ .wiW,thefAJl;lowing:

function-'na:me~$:

M~aIling
St~cl<~~'l (for 25,6:(),.
Stacker '2 (f'or 256.0:,
Stacker 3' (for 2.56Q)

Stacker: 4

(for

2566'}

Stacker 5 (for 2560)
Appendix G:

Combined Function Card Processing

379

For the 3525 device, if line control of multiline printed output is
desired, mnemonic-names may be equated with the following
function-names:
Function Name
C02
C03
C04

Meaning
Line 3
Line 5
Line 7

C12

Line 23

(Note that these function-names are not valid for 2-line 3525 print
files, or for the 2560 print features.)

SELECT Clause
For each of the functions (reading, punching, printing) to be
combined, a unique file-name must be defined.

ASSIGN Clause
For combined function card files, the ASSIGN clause has the
following formats:

sYsnnn-UR-35251~~ -1;~:~~
SYSnnn-UR-2560

W

V[R]

M

Z

[-name]

n} -1; ~r:]}

[-name]

where nnn is a 3-digit number between 000 and 221, inclusive. Each
of the associated logical files must be specified with the same
SYSnnn field.
(The field represents the symbolic unit to which the
logical file is assigned.) The name field has the same meaning it
has for other files.
The device and organization fields are interdependent.
following entries are valid:
Device
3525R
(reader)

Organization

V[R]
{ X[R]
Y[R]

The

Meaning
read/print associated file
read/punch/print associated file
read/punch associated file

Note: The optional R code in the
organization field specifies RCE
(Read Colu~n Eliminate) card reading.

v [p]

2560R
(reader)

l

VS
X[P]

380

Supplementary Material

read/print associated file~ primary
input hopper
read/print associated file,
secondary input hopper
read/punch/p~int associated file,
primary input hopper

Device
2560R
(reader)
(continued)

anization
XS

y[p]

YS
3525P
(punch)

{

x
Y

Z

X[p]
XS

Y[P]

2560P
(punch)

YS

Z[p]

ZS
3525W
(2-line
printer)

\

~

v
X

Z

V[P]
VS

2560W
(1 to 6
line
printer)

X[p]
XS

Z[P]

\
3525M
(multiline
printer)

{

ZS

v
X
Z

Meaning
read/punch/print associated file,
secondary input hOfper
read/punch associated file, primary
input hopper
read/punch associated file,
secondary input hOfper
read/punch/print associated file
read/punch associated file
punch/print associated file
read/punch/print associated
primary input hopper
read/punch/print associated
secondary input hopper
read/punch associated file,
input hopper
read/punch associated file,
secondary input hopper
punch/print associated file,
input hopper
punch/print associated file,
secondary input hopper

file,
file,
primary

primary

read/print associated file
read/punch/print associated file
punch/print associated fiie
read/print associated file, primary
input hopper
read/print associated file,
secondary input hopper
read/punch/print associated file,
primary input hopper
read/punch/print associated file,
secondary input hopper
punch/print associated file, primary
input hopper
punch/print associat~d file,
secondary input hopper
read/print associated file
read/punch/print associated file
punch/print associated file

Note: For the 2560 device, all input hopper specifications in cne
combined function file structure must be identical.
RESERVE Clause
For a combined function structure, the files assigned to the read

function and the punch function must eaCh specify RESERVE NO
ALTERNATE AREA(S).
A file assigned to the print function may specify either NO or 1
ALTERNATE AREA(S).
II -- DATA DIVISION CONSIDERATIONS
For each logical file defined in the Environment Division for the
combined function structure, there must be a corresponding FD entry
and 01 record description entry in the File Section of the Data
Division.
Appendix G:

Corr.bined Function Card Processing

381

III -- PROCEDURE DIVISION CONSIDERATIONS
When combined function processing is to be used, input/output
operations must proceed in a specified order in the Procedure
Division. The card passes first through the reading station, next
through the punching station, and last through the printing station.
Therefore, the following combined functions may be specified, in the
order shown:
Functions to be
Combined
read/punch/print

Order of
Operations
read
punch
[print]

read/punch

read
punch

read/print

read
[print]

Associated COBOL
Statement
READ ••• AT END
WRITE ,""ji>;..;;~~~liNt.1:f'~~t:l?Q$:~W:~Q~:ttJ~~l,
WRITE
~2~66)'
..
WRITE
[AFTER ADVANCING~J?9$-*-~4t;g~j;~q] (3525)
READ .... AT END
WRITE ,?,~¥~'{:';;;l~@:lf~*:J~4~1?~~~~tq~~m~J/
READ ••.. AT END
WRITE
(2560)
WRITE ......
[AFTER ADVANCINGlt~'
~

punch/print

punch
[print]

.. ' :;- . :i.;.' . ~

WRITE ;~'~;~;:::;I~~!If~iji~~~
WRITE
(2560)
WRITE ....
[AFTER ADVANCING ,
(3525)

All operations on one card must be completed before the next card
is obtained, or there is an abnormal termination of the job.
The following Procedure Division considerations in the COBOL
source program apply:
OPEN Statement
Combined function files may be opened in any sequence. The read
function file must be opened INPUT; the punch and print function
files must be opened OUTPUT. All files must be opened before
processing begins: if they are not, the job is terminated.
READ Statement
For combined function files, the READ statement, if the function
is specified, must be the first input/output operation specified. A
second READ statement must not be issued before all necessary
combined function operations for the same card have been completed,
or abnormal termination of the job results.

WRITE statement -- Punch Function Files
When the punch function is used, then after the READ statement is
issued, the next input/output operation must be tl WRITE statement
for the punch function file.

382

supplementary Material

If the user wishes to punch additional data into some of the
cards and not into others, he must issue a dummy WRITE statement for
the null cards, first filling the output area with SPACES.

WRITE Statement -- Print Function Files
After the punch function operations (if specified) are completed,
the user can issue WRITE statement(s) for the print function file.
If the user wishes to print additional data on some of the data
cards and not on others, he may omit the WRITE statement for the
null cards ..

2560 DEVICE: One WRITE statement may be issued for each card. 'I'he
print feature allows a maximum of 64 characters per line and 6 lines
per card; thus the maximum logical record size is 384 characters.
Line control may not be specified (that is no WRITE
ADVANCINGl:'1?PSITIOrUNG statements are allowed).
3525 DEVICE: Depending on the capabilities of the specific model in
use, the print file may be either a 2-line print file or a
multi-line print file.
Up to 64 characters may be printed on each
line.
For a 2-line print file, the lines are printed on line 1 (top
edge of card) and line 3 (between rows 11 and 12). Line control may
not be specified. Automatic spacing is provided.
For a multi-line print file up to 25 lines of characters may be
printed.
Line control may be specified.
If line control is not
specified, automatic spacing is provided.
Line control is specified by issuing WRITE AFTER ADVANCING
statements, or WRITE AFTE~,POSJTIONING statements for the print
function file.
If line control is used for one such statement, it
must be used for all other WRITE statements issued to the file.
'Ihe
maximum number of printable characters, including any SPACE
characters, is 64. The first character of the record defined must
be reserved by the programmer for the line control character;
therefore, the record may be defined as containing up to 65
Appendix G:

Combined Function Card Processing

383

charactersn
Such WRITE statements must not specify space
suppr2ssion ..
Ijentifier and integerl'lC!:Yt?ot:,p~§9-J:Ilt?,}t1~B,ni,:ng§ they have for other
WRITE AFTER ADVANCING ;olZ::'aR.I:i!E:>A~ER.,ipOS;$'1'ION;tN(#, statements.
However, such WRITE statements must not increase the line position
on the card beyond the card limits, or abnormal termination results.
The mnemonic-name of the WRITE AFTER ADVANCING statement may also
be specified.
In the SPECIAL-NAMES Paragraph, the following
function-names may be associated with the mneroonic-names:
Function Name
C02
C03
C04

Meaning
Line 3
Line 5
Line 7

C12

Line 23

(See also "System/370 Card Devices" in the Procedure Division WRITE
Statement jocumentation.)

CLOSE Statement
When processing is completed. a CLOSE statement must be issued
for each of the combined function files.
After a CLOSE statement
has been issued for anyone of the functions, an attempt to perform
processing for any of the functions results in abnormal termination.

384

Supplementary Material

ACCESS
IBM

~~RICAN

NATIONAL STANDARD COBOL GLOSSARY

ACCESS:
The manner in which files are referenced by the computer.
Access can be sequential (records are referred to one after another in
the order in which they appear on the file), or it can be random (the
individual records can be referred to in a nonsequential manner).
Actual Decimal Point: The physical representation, using either of the
decimal point characters (. or ,), of the decimal pOint position in a
data item.
When specified, it will appear in a printed report, anj i t
requires an actual space in storage.
ACTUAL KEY:
A key which can be directly used by the system to locate a
logical record on a mass storage device.
Alphabetic Character: A character which is one of the 26 characters of
the alphabet, or a space.
In COBOL, the term does not include any other
characters.
Alphanumeric Character:

Any character in the computer's character set.

Alphanumeric Edited Character:
~ character within an alphanumeric
character string which contains at least one B or o.
Arithmetic Expression: A statement containing any combination of datanames, numeric literals, and figurative constants, joined together by
one or more arithmetic operators in such a way that the statement as a
whole can be reduced to a single numeric value;
Arithmetic~erator:

~ symbol (single character or two-character set)
which directs the systeffi to perform an arithmetic operation.
rhe
following list shows arithmetic operators:

Meaning
Addition
Subtraction
Multiplication
Division
Exponentiation

Symbol
+

*
**
/

Assumed Decimal Point:
A decimal pOint position which does not involve
the existence of an actual character in a data item.
It does not occupy
an actual space in storage, but is used by the compiler to align a value
properly for calculation.
BLOCK:
In COBOL, a group of characters or records which is treatej as
an entity when moved into or out of the computer.
rhe term is
synonymous with the term Physical Record.
Buffer~
A portion of main storage into which data is read or from which
it is written.

Byte: A sequence of eight adjacent binary bits.
When properly aligned,
two bytes form a halfword, four bytes a fullword, and eight bytes a
doubleword.
Channel: A device that directs the flow of information between the
computer main storage and the input/output devices.
Character: One of a set of in1ivisible symbols that can be arranged in
sequences to express information.
These symbols include the letters A
through Z, the decimal digits 0 through 9, punctuation symbols, and any
other symbols which will be accepted by the data-processing system.
IBM ~erican National Standard COBOL Glossary

385

Character Set
Character Set: All the valid COBOL characters.
The complete set of 51
characters is listed in "Language Considerations."
Character String:
A connected sequence of characters.
characters are valid.

All COBOL

Checkpoint:
A reference point in a program at which information about
the contents of core storage can be recorded so that, if necessary, the
program can be restarted at an intermediate point.
Class Condition: A statement that the content of an item is wholly
alphabetic or wholly numeric.
It may be true or false.
Clause: A set of consecutive COBOL words whose purpose is to specify an
attribute of an entry. There are three types of clauses: data,
environment, and file.
COBOL Character: Any of the 51 valid characters (see CHARACTER) in the
COBOL character set.
The complete set is listed in "Language
Considerations."
Collating Sequence: The arrangement of all valid characters in the
order of their relative precedence.
The collating sequence of a
computer is part of the computer design -- each acceptable character has
a predetermined place in the sequence.
A collating sequence is used
primarily in comparison operations.
COLUMN Clause:
~ COBOL clause used to identify a specific position
within a report line.
Comment: An annotation in the Identification Division or Procedure
Division of a COBOL source program.
A comment is ignored by the
compiler. As an IBM extension, comments may be included at any point in
a COBOL source program.
Compile Time:
The time during which a COBOL source program is
translated by the COBOL compiler into a machine language object program.
Compiler:
A program which translates a program written in a higher
level language into a machine language object program.
Compiler Directing Statement:
A COBOL statement which causes the
compiler to take a specific action at compile time, rather than the
ooject program to take a particular action at execution time.
Compound Condition: A statement that tests two or more relational
expressions.
It may be true or false.
Condition:
•

One of a set of specified values a data item can assume.

•

A simple conditional expression:
relation condition, class
condition, condition-name condition, sign condition, switch-status
condition, NOT condition.

Conditional Statement: A statement which 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.
Conditional Variable: A data item that can assume more than one value;
one or more of the values it assumes has a condition-name assigned to
it.
Condition Name:
The name assigned to a specific value, set of values,
or range of values, that a data item may assume.
386

Supplementary Material

Condition-name Condition
Condition-name Condition: A statement that the value of a conditional
variable is one of a set (or range) of values of a data item identified
by a condition-name. The statement may be true or false.
CONFIGURATION SECTION: A section of the Environment Division of the
COBOL program. It describes the overall specifications of computers.
Connective:
following:

A word or a punctuation character that does one of the

• Associates a data-name or paragraph-name with its qualifier
• Links two or more operands in a series
• Forms a conditional expression
CONSOLE:

A COBOL mnemonic-name associated with the console typewriter.

Contiguous Items: Consecutive elementary or group items in the Data
Division that have a definite relationship with each other.
Control-Break: A recognition of a change in the contents of a control
data item that governs a hierarchy.
Control-Bytes: Bytes associated with a physical record that serve to
identify the record and indicate its length, blocking factor, etc.
Control-Data Item: A data item that is tested each time a report line
is to be printed. If the value of the data item has changed, a control
break occurs and special actions are performed before the line is
printed.
CONTROL-FOOTING: A report group that occurs at the end of the control
group of which it is a member.
Control Group: An integral set of related data that is specifically
associated with a control data item •
CONTROL-HEADING: A report group that occurs at the beginning of the
control group of which it is- a member.
Control-Hierarchy: A designated order of specific control data items.
The highest level is the final control; the lowest level is the minor
control.
Core storage: storage within the central processing unit of the
computer, so called because this storage exists in the form of magnetic
cores.
Cylinder-Index: A higher level index, always present in indexed data
organization. Its entries point to track indexes.
Data Description Entry: An entry in the Data Division that is used to
describe the characteristics of a data item. It consists of a level
number, followed by an optional data-name, fo~lowed by data clauses that
fully describe the format the data will take. An elementary data
description entry (or item) cannot logically be subdivided further. A
group data description entry (or item) is made up of a number of related
group and/or elementary items.
DATA DIVISION: One of the four main component parts of a COBOL program.
The Data Division describes the files to be used in the program and the
records contained within the files. It also describes any internal
Working-Storage records that will be needed (see -Data Division for
full details).
ft

IBM American National Standard COBOL Glossary

387

Data Item
Data Item: A unit of recorded information that can be identified by a
symbolic name or by a combination of names and subscripts. Elementary
data items cannot logically be subdivided.
A group data item is made up
of logically related group and/or elementary items and can be a logical
group within a record or can itself be a complete record.
Data-name: A name assigned by the programmer to a data item in a COBOL
program. It must contain at least one alphabetic character.
DECLARATIVES: A set of one or more compiler-directing sections written
at the beginning -of the Procedure Division of a COBOL program.
The
first section is preceded by the header DECLARATIVES. The last section
is followed by the header END DECLARATIVES. There are three options:
1.

Input/output label handling

2.

Input/output error-checking procedures

3.

Report Writing procedures

Each has its standard format (see "Procedure Division").
Device-number:

The reference number assigned to any external device.

Digit: Any of the numerals from 0 through 9.
used in reference to any other symbol.
DIVISION:

In COBOL, the term is not

One of the four major portions of a COBOL program:

• IDENTIFICATION DIVISION, which names the program.
• ENVIRONMENT DIVISION, which indicates the machine equipment and
equipment features to be used in the program.
• DATA DIVISION, which defines the nature and characteristics of data
to be processed.
• PROCEDURE DIVISION, which consists of statements directing the
processing of data in a specified manner at execution time.
Division Header: The COBOL words that indicate the beginning of a
particular division of a COBOL program. The four division headers are:
• IDENTIFICATION DIVISION.
• ENVIRONMENT DIVISION.
• DATA DIVISION.
• PROCEDURE DIVISION.
Division-name:
program.

The name of one of the four divisions of a COBOL

EBCDIC Character: Anyone of the symbols included in the eight-bit
EBCDIC (Extended Binary-Coded-Decimal Interchange Code) set. All 51
COBOL characters are included.
Editing Character: A single character or a fixed two-character
combination used to create proper formats for output reports (see
"Language Considerations" for a complete list of editing characters).
388

Supplementary Material

Elementary Item
Element~ry

Item:

A data item that cannot logically be subdivided.

Entry: Any consecutive set of descriptive clauses terminated by a
period, written in the Identification, Environment, or Procedure
Divisions of a COBOL program.
Entry-name: A programmer-specified name that establishes an entry pOint
into a COBOL subprogram.
ENVIRONMENT DIVISION: One of the four main component parts of a COBOL
program. The Environment Division describes the computers upon which
the source program is compiled and those on which the object program is
executed, and provides a linkage between the logical concept ot files
and their records, and toe physical aspects of the devices on which
files are stored (see "Environment Division" for full details).
Execution Time: The time at which an object program actually performs
the instructions coded in the Procedure Division, using the actual data
provided.
Exponent: A number, indicating how many times another number (the base)
is to be repeated as a factor.
Positive exponents denote multiplication, negative exponents denote division, fractional exponents denote a
root of a quantity. In COBOL, exponentiation is indicated with the
symbol ** fo~lowed by the exponent.
F-mode Records: Records of a fixed length, each of which is wholly
contained within a block. Blocks may contain more than one record.
Figurative Constant: A reserved word that represents a numeric value, a
character, or ~ string of repeated values or characters. The word can
be written in a COBOL program to represent the values or characters
without being defined in the Data Division (see "Language Considerations" fo~ a complete list).
FILE-CONTROL: The name and Header of an Environment Division paragraph
in which the data files for a given source program are named and
assigned to specific input/output devices.
File Description: An entry in tbe File Section of the Data Division
that provides information about the identification and physical
structure of a file~
File-name: A name assigned to a set of input data or output data.
file-name must include at least one alphabetic character.

A

FILE SECTION: A section of the Data Division that contains descriptions
of all externally stored data (or files) used in a program. such
information is given in one or more file description entries.
Floating-point Literal: ~ numeric literal whose value is expressed in
floating-point notation -- that is, as a decimal number followed by an
exponent which indicates the actual placement of the decimal point.
Function-name: A name, supplied by IBM, that identifies system logical
units, printer and card punch control characters, and report codes.
When a function-name is associated with a mnemonic-name in the
Environment Division, the mnemonic-name can then be substituted in any
format in which substitution is valid.
Group Item: A data item made up of a series of logically related
elementary items. It can be part of a record or a complete record.
Header Label:
or a volume.

~

record that identifies the beginning of a physical file

IBM American National Standard COBOL Glossary

389

High-Order
High-Order

Tne leftmost position in a string of characters.

IDENTIFICATION DIVISION: One of the four main component parts of a
COBOL program. The Identification Division identifies the source
program and the object program and, in addition, may include such
documentation as the author's name, the installation where written, date
written~ etc.
(see "Identification Division" for full details).
Identifier: A data-name, unique in itself, or made unique by the
syntactically correct combination of qualifiers, subscripts, and/or
indexes.
Imperative-statement: A statement consisting of an imperative verb and
its operands, which specifies that an action be taken, unconditionally.
An imperative-statement may consist of a series of imperativestatements.
Index: A computer storage position or register, the contents of which
identify a particular element in a table.
Index Data Item: A data item in which the contents of an index can be
stored without conversion to subscript form.
Index-name: A name, given by the programmer, for an index of a specific
table. An index-name must contain at least one alphabetic character.
It is one word (4 bytes) in length.
Indexed Data-name: A data-name identifier which is subscripted with one
or more index-names.
INPUT-OUTPUT SECTION: In the Environment Division, the section that
names the files and external media needed by an object program.
It also
provides information required for the transmission and handling of data
during the execution of an object program.
INPUT PROCEDURE: A set of statements that is executed each time a
record is released to the sort file.
Input procedures are optional;
whether they are used or not depends upon the logic of the program.
Integer: A numeric data item or literal that does not include any
character positions to the right of the decimal point, actual or
assumed. Where the term "integer" appears in formats, "integer" must
not be a numeric data item.
INVALID KEY Condition: A condition that may arise at execution time in
which the value of a specific key associated with a mass storage file
does not result in a correct reference to the file (see the READ,
REWRITE, START, and WRITE statements for the specific error conditions
involved).
I-a-CONTROL: The name, and the header, for an Environment Division
paragraph in which object program requirements for specific input/output
techniques are specified. These techniques include rerun checkpoints,
sharing of same areas by several data files, and multiple file storage
on a single tape device.
KEY: One or mor~ data items, the contents of which identify the type or
the location of a record, or the ordering of data.
Ke~ Word:
A reserved word whose employment is essential to the meaning
and structure of a COBOL statement. In this manual, key words are
indicated in the formats of statements by underscoring. Key words are
included in the reserved word list.

390

Supplementary Material

Level Indicator
Level Indicator: Two alphabetic characters that identify a specific
type of file, or the highest position in a hierarchy. The level
indicators are: PD, SD, RD.
Level Number: A numeric character or two-character set that identifies
the properties of a data description entry.
Level numbers' 01 through 49
define group items, the highest level being identified as 01, and the
subordinate data items within the hierarchy being identified with level
numbers 02 through 49. Level numbers 66, 77, and 88 identify special
properties of a data description entry in the Data Division.
Library~name:

The name of a member of a data set containing COBOL
entries, used with the COpy and BASIS statements.

LINKAGE SECTION: A section of the Data Division that describes data
made available from another program.
Literal: A character string whose value is implicit in the characters
themselves. The numeric literal 7 expresses the value 7, and the
nonnumeric literal "CHARACTERS" expresses the value CHARACTERS.
Logical Operator: A COBOL word that defines the logical connections
between relational operators. The three logical operators and their
meanings are:
OR (logical inclusive -- either or both)
AND (logical connective -- both)
NOT (logical negation)
(See "Procedure Division" for a more detailed explanation.)
Logical Record: The most inclusive data item, identified by a level-01
entry. It consists of one or more related data items.
Low-Order:

The rightmost position in a string of characters.

Main Program: The highest level COBOL program involved in a step.
(Programs written in other languages that follow COBOL linkage
conventions are considered COBOL programs in this sense.)
Mantissa: The decimal part of a logarithm. Therefore, the part of a
floating-point number that is expressed as a decimal fraction.
Mass storage: A storage medium -- disk, drum, or data cell -- in which
data can be collected and maintained in a sequential, direct, or indexed
organization.
Mass Storage File:
device.

A collection of records assigned to a mass storage

Mass Storage File segment:
A part of a mass storage file whose
beginning and end are define5 by the FILE-LIMIT clause in the
Environment Division.
Master Index: The highest level index, which is optional, in the
indexed data organization.
Mnemonic-name: A programmer-supplied word associated with a specific
function-name in the Environment Division. It then may be written in
place of the function-name in any format where such a substitution is
valid.
MODE:

The manner in which records of a file are accessed or processed.
IBM American National Standard COBOL Glossary

391

Name
Name: A word composed of not more than 30 characters, which defines a
COBOL operand (see "Language Considerations" for a more complete
discussion).
Noncontiguous Item: A data item in the working-Storage section of the
Data Division which bears no relationship with other data items.
Nonnumeric Literal: A character string bounded by quotation marks,
which means literally itself.
For example, "CHARACTER" is the literal
for and means CHARACTER. The string of characters may include any
characters in the computer's set, with the exception of the quotation
mark. Characters that are not COBOL characters may be included.
Numeric Character:
o through 9.

A character that belongs to one of the set of digits

Numeric Edited Character: A numeric character which is in such a form
that it may be used in a printed output. It may consist of external
decimal digits 0 through 9, the decimal point, commas, the dollar sign,
etc., as the programmer wishes (see "Data Division" for a fuller
explanation).
Numeric Item: An item whose description restricts its contents to a
value represented by characters from the digits 0 through 9. rhe item
may also contain a leading or trailing operational sign represented
either as an overpunch or as a separate character.
Numeric-Literal: A numeric character or string of characters whose
value is implicit in the characters themselves. Thus, 777 is the
literal as well as the value of the number 777.
OBJECT-COMPUTER: The name of an Environment Division paragraph in which
the computer upon which the object program will be run is described.
Object Program: The set of machine language instructions that is the
output from the compilation of a COBOL source program. The actual
processing of data is done by the object program.
Object Time:

The time during which an object program is executed.

Operand: The "object" of a verb or an operator. That is, the data or
equipment governed or directed by a verb or operator.
Operational Sign: An algebraic sign associated with a numeric data
item, which indicates whether the item is positive or negative.
Optional Word: A reserved word included in a specific format only to
improve the readability of a COBOL statement.
If the programmer wishes,
optional words may be omitted.
OUTPUT PROCEDURE: A set of programmer-defined statements that is
executed each time a sorted record is returned from the sort file.
Output procedures are optional; whether they are used or not depends
upon the logic of the program.
Overlay: The technique of repeatedly using the same areas of internal
storage during different stages in processing a problem.
PAGE: A physical separation of continuous data in a report. The
separation is based on internal requirements and/or the physical
characteristics of the reporting medium.
PAGE FOOTING: A report group at the end of a report page which is
printed before a page control break is executed.
PAGE HEADING: A report group printed at the beginning of a report page,
after a page control break is executed.
392

Supplementary Material

Paragraph
Paragraph: A set of one or more COBOL sentences, making up a logical
processing entity, and preceded by a paragraph-name or a paragraph
header.
Paragraph Header: A word followed by a period that identifies and
precedes all paragraphs in the Identification Division and Environment
Division.
Paragraph-name:
a paragraph.

A programmer-defined word that identifies and precedes

Parameter: A variable that is given a specific value for a specific
purpose or process.
In COBOL, parameters are most often used to pass
data values between calling and called programs.
Physical Record: A physical unit of data, synonymous with a block.
can be composed of a portion of one logical record, of one complete
logical record, or of a group of logical records.
Print Group:

It

An integral set of related data within a report.

Priority-Number: A number, ranging in value from 0 to 99, which
classifies source program sections in the Procedure Division (see
"Segmentation" for more information).
Procedure: One or more logically connected paragraphs or sections
within the Procedure Division, which direct the computer to perform some
action or series of related actions.
PROCEDURE DIVISION: One of the four main component parts of a COBOL
program. The Procedure Division contains instructions for solving a
problem. The Procedure Division may contain imperative-statements,
conditional statements, paragraphs, procedures, and sections (see
"Procedure Division n for full details).
procedure-name: A word that precedes and identifies a procedure, used
by the programmer to transfer control from one point of the program to
another.
Process;

Any operation or combination of operations on data.

Program-name: A word in the Identification Division that identifies a
COBOL source program.
Punctuation Character: A comma, semicolon, period, quotation mark, left
or right parenthesis, or a space.
Qualifier: A group data-name that is used to reference a non-unique
data-name at a lower level in the same hierarchy, or a section-name that
is used to reference a non-unique paragraph.
In this way, the data-name
or the paragraph-name can be made unique.
Random Access:
An access mode in which specific logical records are
obtained from, or placed into, a mass storage file in a nonsequential
manner.
RECORD: A set of one or more related data items grouped for handling
either internally or by the input/output systems (see "Logical Record").
Record Description: The total set of data description entries
associated with a particular logical record.
Record~name:

Reel:

A data-name that identifies a logical record.

A module of external storage associated with a tape device.
IBM American National Standard COBOL Glossary

393

Relation character
Relation Character: A character that expresses a relationship between
two operands.
The following are COBOL relation characters:
Character

>

Meaning
Greater than

<

Less than
Equal to

Relation Condition: A statement that the value of an arithmetic
expression or data item has a specific relationship to another
arithmetic expression or data item.
The statement may be true or false.
Relational Operator: A reserved word, or a group of reserved words, or
a group of reserved words and relation characters. A relational
operator plus programmer-defined operands make up a relational
expression. A complete listing is given in "Procedure Division."
REPORT:
File.

A presentation of a set of processed data described in a Report

Report Description Entry: An entry in the Report Section of the Data
Division that names and describes the format of a report to be produced.
Report File: A collection of records, produced by the Report writer,
that can be used to print a report in the desired format.
REPORT FOOTING: A report group that occurs, and is printed, only at the
end of a report.
Report Group:
report.

A set of related data that makes up a logical entity in a

REPORT HEADING: A report group that occurs, and is printed, only at the
beginning of a report.
Report Line:

One row of printed characters in a report.

Report-name:

A data-name that identifies a report.

REPORT-SECTION: A section of the Data Division that contains one or
more Report Description entries.
Reserved Word: A word used in a COBOL source program for syntactical
purposes. It must not appear in a program as a user-defined operand.
Routine: A set of statements in a program that causes the computer to
perform an operation or series of related operations.
Run Unit: A set of one or more object programs that function, at object
time, as a unit to provide problem solutions. This compiler considers a
run unit to be the highest level calling program plus all called
subprograms.
S-mode Records: Records that span physical blocks.
Records may be
fixed or variable in length. Blocks may contain one or more segments.
A segment may contain one record or a portion of a record. Each segment
contains a segment-length field and a control field indicating whether
or not it is the first and/or last or an intermediate segment of the
record.
Each block contains a block-length field.
SECTION: A logically related sequence of one or more paragraphs.
section must always be named.

A

Section-Header: A combination of words that precedes and identifies
each section in the Environment, Data, and Procedure Divisions.
394

Sl.!pplementary Material

Section-name
Section-name: A word specified by the programmer that precedes
identifies a section in the Procedure Division.

an~

Sentence: A sequence of one or more statements, the last ending with a
period followed by a space.
Separator:

An optional word or character that improves readability.

sequential Access: An access mode in which logical records are obtained
from, or placed into, a file in such a way that each successive access
to the file refers to the next subsequent logical record in the file.
The order of the records is established by the programmer when creating
the file.
seguential Processing: The processing of logical records in the order
in which records are accessed.
Sign Condition: A statement that the algebraic value of a data item is
less than, equal to, or greater than zero. It may be true or false.
Simple Condition: An expression that can have two values, and causes
the object program to select between alternate paths of control,
depending on the value found. The expression can be either true or
false.
Slack Bytes: Bytes inserted between data items or records to ensure
correct alignment of some numeric items. Slack bytes contain no
meaningful data. In some cases, they a~e inserted by the compiler; in
others, it is the responsibility of the programmer to insert them. The
SYNCHRONIZED clause instructs the compiler to insert slack bytes when
they are needed for proper alignment. Slack bytes between records are
inserted by the programmer.
Sort File: A collection of records that is sorted by a SORT statement.
The sort file as created and used only while the sort function is
operative.
Sort File Description Entr~: An entry in the File Section of the Data
Division that names and describes a collection of records that is used
in a SORT statement.
Sort-file-name:
Sort-key:

A data-name that identifies a Sort File.

The field within a record on which a file is sorted.

sort-work-file: A collection of records involved in the sorting
operation as this collection exists on intermediate device(s).
SOURCE-COMPUTER: The name of an Environment Division paragraph.
the computer upon which the source program will be compiled is
described.
Source Program:

In it,

A problem-solving program written in COBOL.

Special Character: A character that is neither numeric nor alphabetic.
special characters in COBOL include the space ( ), the period(.), as
well as the following:
+

* /

$

)

The name of an Environment Division paragraph, and the
paragraph itself, in which names supplied by IBM are related to
mnemonic-names specified by the programmer. In addition, this paragraph
can be used to exchange the functions of the comma and the period, or to
specify a substitution character for the currency sign, in the PIcrURE
string.
SPECIAL~NAMES:

IBM American National Standard COBOL Glossary

395

Special Register
SQecial Register:
Compiler-generated storage areas primarily used to
store information produced with the use of specific COBOL features.
lhe
special registers are:
ThLLY, LINE-COUNTER, PAGE-COUNTER, CURRENT-DATE:
TIME-OF-DhY, COM-REG, SORT-RETURN, SORT-FILE-SIZE, SORT-CORE-SIZE,
SORT-MODE-SIZE, and NSTD-REELS.
Standard Data Format: The concept of actual physical or logical record
size in storage. The length in the Standard Data Format is expressed in
the number of bytes a record occupies and not necessarily the number of
characters, since some characters take up one full byte of storage and
others take up less.
statement:
A syntactically valid combination of words and symbols
written in the Procedure Division.
A statement combines COBOL reserved
words and programmer-defined operands.
Subject of entry: A data-name or reserved word that appears immediately
after a level indicator or level number in a Data Division entry.
It
serves to reference the entry.
Subprogram:
A COBOL program that is invoked by another COBOL program.
(Programs written in other languages that follow COBOL linkage conventions are COBOL programs in tpis sense.)
Subscript: An integer or a variable whose value references a particular
element in a table.
Switch-status Condition: A statement that an UPSI switch has been set
to an ON or OFF condition.
The statement may be true or false.
SYSIPT:

The system input device.

SYSLST:

The system output device.

SYSPCH:

The system punch device.

SYSPUNCH:

An alternate Qame for the system punch device.

System-name:
A name, specified by IBM, that identifies any particular
external device used with the computer, and characteristics of files
contained within it.
Table:
A collection and arrangement of data in a fixed form for ready
reference.
Such a coilection foliows some logical order, expressing
particular values (functions) corresponding to other values (arguments)
by which they are referenced.
Table Element:
A data item that belongs to the set of repeated items
comprising a table.
Test Condition: A statement that, taken as a whole, may be either true
or false, depending on the circumstances existing at the time the
express~on is evaluated.
Trailer Label:
A record that identifies the ending of a physical file
or of
volume.

a

U-mode Reoords: Records of undefined length.
They may be fixed or
variable 'in length; there is only one record per block.
Unary Operator: An arLthmetic operator C+ or -) that can precede a
single variable, a literal, or a left parenthesis in an arithmetic
expression.
The plus sign multiplies the value by +1; the minus sign
multiplies the value by -1.
UNIT:
IBM.
396

A module of external storage.

supplementary Material

Its dimensions are determined by

V-mode Records
V-mode Records: Records of variable length, each of which is wholly
contained within a block.
Blocks may contain more than one record.
Each record contains a record length field, and each block contains a
block length field.
Variable: A data item whose value may be changed during execution of
the object program.
Verb: A COBOL reserved word that expresses an action to be taken by a
COBOL compiler or an object program.
Volume: A module of external storage.
for mass storage devices it is a unit.

For tape devices it is a reel;

Volume Switch Procedures: Standard procedures executed automatically
when the end of a unit or reel has been reached before end-of-file has
been reached.
Word:
1.

In COBOL: A string of not more than 30 characters, chosen from the
following: the letters A through Z, the digits 0 through 9, and
the hyphen (-). The hyphen may not appear as either the first or
last character.

2.

In Systern/360: A fullwora is 4 bytes of storage; a doubleword is 8
bytes of storage; a halfword is 2 bytes of storage.

Word Boundary: Any particular storage position at which data must be
aligned for certain processing operations in System/360. The halfword
boundary must be divisible by 2, the fullword boundary must be divisible
by 4, the doubleword boundary must be divisible by 8.
WORKING~STORAGE SECTION:
A section-name (and the section itself) in the
Data Division. The section describes records and noncontiguous data
items that are not part of external files, but are developed and
processed internally.
It also defines data items whose values are
assigned in the source program.

IBM American National Standard COBOL Glossary

397

(When more than one page reference is given. the major reference appears first.
Entries
ending in "(DOS/vS)" apply only to the DOS/VS COBOL implementation. All other entries
apply both to DOS/VS COBOL and DOS Full American National Standard COBOL.)
Special Characters
[ (see braces)
{ (see brackets)
(see pound sign)
• (see period)
••• (see ellipsis)
< in relation conditions 158,159
( and ) in
arithmetic expressions 153,154
compound conditions 162-165
PICTURE clause 118-120
subscripting and indexing 289-291
+ (see plus symbol)
$ (see currency symbol, dollar sign)
* in
arithmetic expressions 153,154
intermediate results 333,334
(see also asterisks, used in PICTURE
clause)
** in
arithmetic expressions 153,154
intermediate results 333,334
in Data Division and Procedure Division
entries 109,149
(see also semicolon)
(see either hyphen, or minus symbol)
/ in
arithmetic expressions 153,154
intermediate results 333,334
sterling report items 327-329
, (see comma)
> in relation conditions 158,159
in
COMPUTE statement 182
relation conditions 158,159
• or II in nonnumeric literals 42,37
(see also quotation mark)

A, in PICTURE clause
alphabetic items 120
alphabetic symbol 118
alphanumeric edited items 124
alphanumeric items 120
abbreviations
ADD CORRESPONDING statement 181
compound conditions 164,165
CORRESPONDING option 179
END-OF-PAGE option 213
Identification Division Header 57,46
JUSTIFIED clause 116
MOVE CORRESPONDING statement 198
PICTURE clause 117
relation conditions 164.165

relational operators 158
reserved words 40
SUBTRACT CORRESPONDING statement 185
SYNCHRONIZED clause 130
TYPE clause 267
USAGE clause 136
absolute
column number 269
line spacing in a report 263-265
values in MOVE statement 199
ACCEPT statement 219,220
ACCEPT statement enhancement
(DOS/VS) xxxvi
access methods
direct files 60,61
indexed files 61,62
sequential files 60
ACCESS MODE and VSAM capabilities
(DOS/VS) xiv
ACCESS MODE clause 78
ACCESS MODE clause, VSk~ (DOS/vS) vii,v
acknowledgment 4
actual decimal point
description 119
in editing 124-128
ACTUAL KEY clause
description and format 79-81
READ statement
211,212
REWRITE statement 218,,219
SEEK statement 210
WRITE statement 218
ACTUAL KEY clause for 3340 (DOS/vS) xxxv
ADD statement
description and formats 181,182
addition operator 153~154
addressing schemes
direct 59,60
indexed 60
sequential 59
VSAM (OOS/VS)
iv
algebraic value in a sign condition 162
algorithm
ACTUAL KEY example 336
direct indexing 298
intermediate results 333,334
relative indexing 299
slack bytes
computational items 119
inter-record 135,136
intra-record 132-135
alignment of data items
comparisons 159,160
decimal point 119,199
editing 125-128
File Section Items 131
JUSTIFIED clause 116

Index

399

Linkaqe section Items 131
PICTURE clause 119,125-128
SYNCHRONIZED clause 130.131
USING option 229
VALUE clause 143
Working-Storage items 131
ALL literal figurative constant
description 43
MOVE statement 200
relation condition 161
STOP statement 196
alphabetic character 118
alphabetic class test 156
alphabetic collating sequence 244
alphabetic data items
allowable symbols 120
in a class test 156
description 118
internal representation 120,137
JUSTIFIED clause 116
MOVE statement 199,200
relation condition 159-161
USAGE clause 136,137
VALUE clause 143
alphabetized cross-reference listing
(SXREF) 12
alphanumeric character 119
alphanumeric collating sequence 244
alphanumeric data item
allowable symbols 120
class test 156
description 120
internal representation 120,137
JUSTIFIED clause 116
MOVE statement 199,200
relation condition 159-161
USAGE clause 136,137
VALUE clause 143
alphanumeric data item (DOS/VS)
FILE STATUS clause, VSAM viii
RECORD KEY clause, VSAM Vll,Vlll
alphanumeric edited character 124
alphanumeric edited item
allowable symbols 124
description 124
MOVE statement 199,200
relation condition 159-161
USAGE clause 136,137
VALUE clause 143
alphanumeric literals (see nonnumeric
literals)
ALTER statement
and called programs 227
in debug packets 322
description and format 188
effect on GO TO statement 188
segmentation 312
sort procedure 245,246
altering characters 201-205
altering execution sequence 187-197
altering usage of data items 114,115
alternative grouping of data
REDEFINES clause 112-115
RENAMES clause 144-146
AND logical operator
compound conditions 162-165
order of evaluation 163
apostrophe (see quotation mark)

400

APPLY clause
CORE-INDEX option 89
CYL-INDEX option 89
CYL-OVERFLOW option 88
EXTENDED-SEARCH option 87
MASTER-INDEX option 89
WRITE-ONLY option 87
WRITE-VERIFY option 88
APPLY CYL-OVERFLOW clause for 3340
(DOS/VS) xxxv
APPLY WRITE-VERIFY invalid for 3540
(DOS/vS) xxxv
arabic numerals 122,123
Area A and Area B in reference
format 50,51
arithmetic expressions
characters used 153
COMPUTE statement 182
conditions 158
description 153,154
evaluation rules 154
arithmetic operators
description and list 153,39
order of evaluation 153
symbol pairs 154
arithmetic statements
ADD 181,182
COMPUTE 182
CORRESPONDING option 179
DIVIDE 183
GIVING option 179
intermediate results 333,334
MULTIPLY 184
overlapping operands 180
REMAINDER option 183
ROUNDED option 179,180
SIZE ERROR option 180
SUBTRACT 185,186
ascending sequence
ASCII character set 360
EBCDIC character set 159,244
sort 243,244
table handling 293,295,296
ascending sequence, merge
(DOS/vS) xxv, xxvi
ASCII considerations 355-361
ASSIGN clause
ASCII considerations 355,356
description and format 69-75
NSTD-REELS special register 70,45
sort
ASCII considerations 360,361
file in GIVING option 238,239
sort work units 239
system-name 70-75
Version ,3 considerations 72-75
ASSIGN clause (DOS/VS)
merge facility xxii
VSAM files v,vi
3340 and 3540 devices xxxiv
assumed
decimal point
description 119
numeric edited items 124
numeric items 122,123
sterling nonreport items 325,326
decimal scaling positions 119,122-124
pound and shilling separators 325

asterisk
arithmetic expressions 153,154
comments 52,234
PICTURE clause
check protect symbol 120
numeric edited items 124,128
sterling report items 327-329
AT END phrase
READ statement 211,212
RETURN statement 248
SEk~CH statement
301-305
AUTHOR paragraph 57
automatic
advancing of printer page 214
end-of-volume 212
error procedures 175,178
label handling 171,105
B, in PICTURE clause
alphanumeric edited items 124
numeric edited items 124
space symbol 118
sterling report items 327-329
BASIS card 316
BEFORE REPORTING declarative 276,277
binary collating sequence 244
binary data item
in PICTURE clause 118
description 138,139
internal representation 140
MOVE statement 200
relation condition 161
SYNCHRONIZED clause 130,131
USAGE clause 136,138-140
blank (see space)
BLANK clause (see BLANK WHEN ZERO clause)
blank figurative constant (see SPACE
figurative constant)
blank line
definition and use 52
for spacing reports 265,266
blank (space) as word separator 40
BLANK WHEN ZERO clause
description and format 115
with sterling report items 329
BLOCK CONTAINS clause
ASCII considerations 356
description and format 100,101
BLOCK CONTAINS clause (DOS/VS)
for 3540 xxxv
VSAM ix
block-descriptor control field 103,104
block size 100,101
blocked records
APPLY WRITE-ONLY clause 87
BLOCK CONTAINS clause 100,101
inter-record slack bytes 135,136
recording mode 103,104
body print group 258-260
boundary alignment 131-136,138
braces and brackets in formats 53
British Standards Institution (BSI)
324
buffer
allocation 77
ASCII considerations 356
combined function processing 381
truncation 87

buffer allocation VSAM (DOS/VS) vi
bypassing label processing
LABEL RECORDS clause 105,106
MULTIPLE FILE TAPE clause 86,87
byte, contents of
alphabetic and alphanumeric items 137
binary item 138,140
external decimal items 137,140
external floating-point items 137,141
internal decimal items 139,141
internal floating-point items 138,141

C, in sterling PICTURE 327-329
CALL statement
boundary alignment in 229
description and format 226,227
limitations with segmentation 312
USING option 228-231
CALL statement for 3886 OCR processing
(DOS/VS) xxviii
capitalized words in formats 53
carriage control character
definition 68
System/370 card devices
combined function processing 383,384
WRITE statement 216,217
WRITE statement 212-216
categories of data (see PICTURE clause)
changing description of data
items 112-115,144-146
character set
arithmetic expressions 153,39
ASCII 360
COBOL 37
EBCDIC 37
editing 39
punctuation 38
relation-conditions 158,39
words 37
character string
and item size 118
NOTE statement 233,234
PICTURE clause 117-121
truncation 116
check protect symbol (see asterisk)
checkpoint
description and format 84,85
sort considerations 240
class test 156
classes of data 117
CLOSE statement
description and format 221-225
OPEN REVERSED statement 207
random file options 224,225
sequential file options 222-224
CLOSE statement (DOS/VS)
VSAM xx,xxi
3540 device xxxvi
CODE clause 256,257,66,67
description and format 256,257
SPECIAL-NAMES paragraph 66,67
coding form, COBOL 50
collating sequence
ASCII 360
EBCDIC 159,244
for sort 244
Index

401

COLUMN clause 269
combined function processing 379-384
combined function processing, 5425
(DOS/VS) xxxvi
comma, exchanging with period
international considerations 330
SPECIAL-NAMES paragraph 66,67
comma
in editing 124-128
PICTURE string 119,121
as punctuation 38
comment-entry
asterisk preceding 52,233,234
DATE-COMPILED paragraph 58
Identification Division 57,58
NOTE statement 233,234
comment lines
in every division 234,52
in Procedure Division 233,234
common exit point for procedures
and PERFORM statement 190
in program 196,197
common processing facilities, VSAM (DOS/VS)
current record pointer x
INTO/FROM identifier option xi
INVALID KEY condition xi
status key x
communication
operating system
sort special registers 249
system special registers 44,45
operator
ACCEPT statement 219,220
ASSIGN clause 69
STOP statement 196
sort feature 249
subprogram 226-232
COMP items (see binary data items)
COMP-l items (see short precision internal
floating-point items)
COMP-2 items (see long precision internal
floating-point data items)
COMP-3 items (see internal decimal items)
COMP-4 items (see binary data items)
comparison
index data items 300,301
index-names 300,301
operands 158
in relation conditions 161
compilation of
copied text 313-315
debugging packet 322
compile-time debugging packet 322
compiler directing statements
BASIS 316
COpy 313-315
DEBUG 322
description 152
DELETE 316,317
EJECT 323
ENTER 233
INSERT 316,317
list of 152
NOTE 233,234
SKIP 323
compiler options
current-date 44
quotation mark 37
402

sequence checking 50
truncation of binary items 118
compound conditions
description 162-165
evaluation rules 163
implied subjects and
relational-operators 164,165
logical operators 162
permissible symbol pairs 164
SEARCH statement 305
COMPUTATIONAL items (see binary data items)
COMPUTATIONAL usage
descriptions and format 138,136
internal representation 140
COMPUTATIONAL-1 items (see short precision
internal floating-point items)
COMPUTATIONAL-l and COMPUTATIONAL-2 usage
descriptions and format 138,136
internal representation 141
COMPUTATIONAL-2 items (see long precision
internal floating-point data items)
COMPUTATIONAL-3 items (see internal decimal
items)
COMPUTATIONAL-3 usage
description and format 139,136
internal representation 141
COMPUTATIONAL-4 items (see binary data
items)
COMPUTATIONAL-4 usage
description and format 139,136
internal representation 140
COMPUTE statement 182
computer-name
OBJECT-COMPUTER paragraph 65
SOURCE-COMPUTER paragraph 64
System/370 instructions 65
computer-name (DOS/VS) ii-iv
COM-REG special register 44
condition-name (see level number 88 items)
condition-name condition
description and format 157
and SEARCH statement 305
conditional sentence, definition 166
conditional statement
definition 166,150
IF statement 166-168
list of 151
ON statement 320,321
conditional variable
assigning values to 142-144
condition-name condition 157
example 144
qualification of 48,49
conditions
compound conditions 162-165
PERFORM statement
descriptions 191-195
formats 189
SEARCH statement 301-305
test conditions 155-162
Configuration Section
copying 313-315
description and format 64-67
OBJECT-COMPUTER paragraph 65
SOURCE-COMPUTER paragraph 64
SPECIAL-NAMES paragraph 65-67
and System/370 instruction
generation 65

Configuration section (DOS/vS)
description and format ii-iv
OBJECT-COMPUTER paragraph ii-iv
SOURCE-COMPUTER paragraph 11
System/370 instruction generation ii-iv
CONSOLE
ACCEPT statement 219,220
DISPLAY statement 220,221
SPECIAL-NAMES paragraph 66
constant
definition 41
figurative 43
literal 41
continuation area
comment lines 52,234
reference format 50
continuation line 51
continuation of
ACCEPT operands 219,220
comments 52,234
DISPLAY operands 220,221
lines 51
nonnumeric literals 52
NOTE statement 233,234
numeric literals 52
words 52
continued line 51
control breaks (see CONTROL clause)
control bytes
BLOCK CONTAINS clause 101
inter-record slack bytes 135,136
S-mode and V-mode records 103
CONTROL clause 257,258
control hierarchy 257,258
control of sort procedures 245-247
CONTROL report group
CONTROL clause 257,258
GENERATE statement 273,274
LINE clause 263-265
NEXT GROUP clause 265,266
PAGE LIMIT clause 258-260
report group description entry 261-263
summation 212,273
TYPE clause 267-269
controls in report writer (see CONTROL
clause)
conversion of data (see data conversion)
COpy statement 313-315
copying
entire program 316,311
part of a program 313-315
CORE-INDEX option of the APPLY clause 89
core storage for sort
SAME clause 240,241
SORT-CORE-SIZE special register 249
CORRESPONDING option
arithmetic statements
ADD 181
description 119
SUBTRACT 185,186
MOVE statement 198,119
counter updating 272,213
CR, in PICTURE clause
description 120,121
numeric edited items 124,128
sterling report items 327-329
creating files
direct 60,61

indexed 61,62
sample programs 336-338
standard sequential 60
(see also output files)
creating labels 110-115
credit symbol (see CR in PICTURE clause)
cross-footing 272
CSP function-name defined 66
CURRENCY-SIGN clause
description and format 66,61
international considerations 330
restriction 61
currency symbol in PICTURE clause
(see also Cl~RENCY SIGN clause)
dollar sign
description 120,121
numeric edited items 124-128
pound sign 327-329
CURRENT-DATE special register 44
current record pointer, VSAM (DOS/VS) ix
cylinder overflow 88
CYL-INDEX option, APPLY clause 89
CYL-OVERFLOW option, APPLY clause 88
COl through C12 function-names defined 66

D, in sterling PICTURE clause 325-329
·data, categories of (see PICTURE clause)
data conversion
DISPLAY statement 220.221
EXAMINE statement 201,202
first character of program-name 58
GIVING option 119
MOVE statement 199
TRANSFORM statement 203-205
data description clauses
BLANK WHEN ZERO 115
data-name 111
FILLER 111
JUSTIFIED 116
OCCURS 292-299
PICTURE 116-128
REDEFINES 112-115
RENAMES 144-146
SYNCHRONIZED 130,131
USAGE 136-141
VALUE 142-144
data description entry
(see also "data description clauses")
ASCII considerations 351
definition 108
general formats 108,109
indentation 97
maximum length 108
data description entry·w VSAM (DOS/VS) ix
data description terms 108
Data Division
ASCII considerations 357
description 91-146
organization 94
report writer considerations
File Section 254,255
Report Section 256-273
sort considerations 241,242
structure 94
table handling considerations 292-299
Data Division, VSAM (DOS/VS) ix
Index

403

data item
assigning a value to 142-144
definition 108
maximum length 108
overlapping
arithmetic statements 180
MOVE statement 199
TRANSFORM statement 203
data item alignment (see ~alignment of data
items")
data item description entry
description 108
Linkage Section 98,99
Working-Storage section 98
data management techniques 59-62
data manipulation statements
EXAMINE 201,202
MOVE 198-200
TRANSFORM 203-205
data-name
definition 41
qualification of 48,49
in reference format 51
data-name clause 111
data organization
direct 59-60
indexed 60
sequential 59
specification of 71-75
data organization, VSAM (DOS/VS) iv
DATA RECORDS clause
description and format 106,107
report writer considerations 255
sort considerations 241,242
DATA RECORDS clause, VSAM (DOS/vS)
ix
data reference methods 48,49
data sets for symbolic debugging 364,365
data transformation 203-205
DATE-COMPILED paragraph 58
DATE-WRITTEN paragraph 57
DB, in PICTURE clause
description 120,121
numeric edited items 124-128
sterling report items 327-329
debit symbol (see DB, in PICTURE clause)
DEBUG card 322
debugging, symbolic 363-377
debugging language
output 318
packet 322
statements
DEBUG card 322
EXHIBIT 318-320
ON 320,321
READY/RESET TRACE 318
decimal point (see period., used in a
PICTURE clause)
decimal point alignment
MOVE statement 199
period insertion character 119~124
rounding 179,180
size error 180
DECIMAL-POINT IS COMMA clause
description and format 66,67
international considerations 330
declaratives
error processing 175-178
EXIT statement in 177,178

,. "'I

~v~

label handling 170-175
report writer 276,277
section
description and format 169,150
USE sentence 169
defaults
ACCESS MODE clause 78
APPLY CYL/MASTER-INDEX clause 89
BLOCK CONTAINS clause 101
cylinder overflow area 88
name-field in system-name 71
page format in Report Writer 260
printer spacing 214
priority number 311
quotation mark character 37
record sizes in DISPLAY 220
recording mode 103,104
segment limit 311
sequence checking 50
truncation of binary items 118
USAGE clause 137
definitions of terms 385-397
DELETE card for copying 316-317
DELETE statement, VSAM (DOS/VS)
description and format xx, xxi
processing capabilities xiv
DEPENDING ON option
GO TO statement
description and format 187
maximum number of operands 187
OCCURS clause
description and formats 292-299
logical record size
considerations 102,103
slack bytes 133-135
SYNCHRONIZED clause 133-135
VALUE clause 142
depth of a report page 258-260
descending sequence
in sort 243,244
in table handling 295,296
descending sequence in merge
(DOS/vS) xxv, xxvi
DETAIL report group
description 261-263
GENERATE statement 273.274
LINE clause 263-265
NEXT GROUP clause 265,266
SUM counters 272,273
TYPE clause 267-269
detail reporting 273,274
device type specification 70
DFR OCR macro instruction (DOS-VS) xxvij
difference (in subtraction) 185.,186
direct access device (see mass storage
device)
direct data organization 59,60
direct files
accessing techniques 60,61
ACTUAL KEY clause 79-81
APPLY EXTENDED-SEARCH clause 87
ASSIGN clause 69-72
BLOCK CONTAINS clause 100,,101
error processing 175-178
initiating access 206-208
invalid key condition
READ statement 211.212
REWRITE statement 218,219

WRITE statement 213,217,218
random access 78,61
READ statement 211,212
recording mode 103,104
REWRITE statement 218,219
sequential access 78,60
user labels
description 105,106
processing 170,171
WRITE statement
description 217,218
format 213
direct indexing 298,290
DISPLAY statement 220,221
DISPLAY usage
alignment 131
alphabetic items 137
alphanumeric items 137
ASCII considerations 357
description 136,137
edited items 137
numeric items 137
SYNCHRONIZED clause 131
DISPLAY-ST usage 325-329
DIVIDE statement 183
division, arithmetic operation 183
division by zero 183,180
division header 51
division operator 153,154
division of a program, definition 46
DLINT OCR macro instruction
(DOS/VS) xxvJ...J...J...
dollar sign (see currency symbol, dollar
sign)
DOS/VS COBOL features (DOS/vS)
FIPS flagger XXV111-XXXlll
merge facility xxi-xxvii
miscellaneous
considerations xxxiv-xxxvi
OBJECT-COMPUTER paragraph ii-iv
VSAM file processing iv-xxi
WHEN-COMPILED special register i
3886 OCR processing xxvii,xxviii
DOS/vS miscellaneous considerations
(DOS/VS)
ACTUAL KEY clause for 3340 xxxv
APPLY CYL-OVERFLOW clause for 3340 xxxv
APPLY WRITE-VERIFY invalid for
3540 xxxv
ASSIGN clause for 3340, 3540 xxxiv
BLOCK CONTAINS clause for 3540 xxxv
CLOSE statement for 3540 xxxvi
ERROR declaratives GIVING option for
3540 xxxv
file processing summary xxxiv
OPEN statement for 3540 xxxv
sort input/output files xxxvi
WRITE statement for 3540 xxxvi
double spacing
printer page 214,215
source program listing 323
doubleword
floating-point items 138
SYNCHRONIZED clause 131
USING operands 229
dummy files 69
duplication of names 48,49

E, in
external floating-point
items 118,121-123
floating-point numeric literals 41
EBCDIC collating sequence (Extended Binary
Coded Decimal Interchange Code) 159,244
editing
insertion
fixed 126
floating 127
simple 125
special 125
replacement 128.
sign control symbols
description 119-121,126
in fixed insertion editing 126
in floating insertion editing 127
in sterling report items 327-329
symbols
in alphanumeric edited items 124
in arithmetic statements 179
description 119-121
in numeric edited items 124
in SUM counter description 272
zero suppression 128
editing character
description 119-121
insertion
fixed 126
floating 127
simple 125
special 125
zero suppression and replacement 128
EJECT statement 323
elementary item
(see also data description clauses)
description 95,96
renaming 144-146
slack bytes 132-135
SYNCHRONIZED clause 130,131
ellipsis ( ••• )
in formats 54
ELSE option
IF statement 166-168
nested IF statements 167,168
ON statement 320,321
END DECLARATIVES. 169,150
end of file
when reading 212
when sorting 248
end of page condition 213.215
end of volume positioning 222-224
ENTER statement 233
entry point 226-228
ENTRY statement 227.228
Environment Division
ASCII considerations 355,356
Configuration Section
OBJECT-COMPUTER paragraph 65
SOURCE-COMPUTER paragraph 64
SPECIAL-NAMES paragraph 65-67
Input-Output Section
FILE-CONTROL paragraph 68-83
1-0 CONTROL paragraph 84-89
international considerations 330
organization 63
segmentation considerations 311,65
sort considerations 238-241

Index

405

System/370 card devices 379-381
System/370 instructions 65
Environment Division, VSAM (DOS/VS) v-ix
equal sign (=)
in COMPUTE statement 182
in relation condition 158
equal size operands in a relation
condition 160
equivalents
reserved words and abbreviations 40
THROUGH and THRU 40
error bytes 176,178
error conditions, arithmetic operations
(see arithmetic statements, SIZE ERROR
option)
ERROR procedure, VSAM (DOS/VS)
(see EXCEPTION/ERROR procedure, VSAM)
error processing declaratives
and ACTUAL KEY 79
description and format 175-178
and Linkage section 177
with sort 245,246
table of capabilities 178
error processing declaratives (DOS/vS)
GIVING option for 3540 xxxv
VSAM file processing xii, xiii
evaluation rules
arithmetic expressions 153
compound conditions 163-165
IF statements 166-168
EXAMINE statement
description and formats 201,202
with sterling items 330
EXCEPTION/ERROR procedure, VSAM (DOS/VS)
CLOSE statement xxi
description and format xii,xiii
OPEN statement xv
READ statement xvii
WRITE statement xviii
execution, order of 150
EXHIBIT statement 318-320
exit point for procedures
error processing 176
EXIT statement 196 , 197
label handling 171
PERFORM statement 190
sort input/output procedures 245-249
EXIT PROGRAM statement
description and format 232,231
symbolic debugging 365
EXIT statement
description and format 196,197
PERFORM statement 190
PROGRAM option 232,231
with sort procedures 248,249,
explanatory comments
in every division 52,234
in Procedure Division 233,234
exponent
floating-point items 137,138
floating-point numeric literals 41
exponentiation operation 153,154
Extended Binary Coded Decimal Interchange
Code (EBCDIC)
collating sequence 159,244
nonnumeric literals 41

406

extended search
for direct files 87
when reading 212
EXTENDED-SEARCH option of the APPLY
clause 87
extended source program library
facility 316,317
external data 93
external decimal items
class test 156
collating sequence for sort 244
description 137
internal representation 140
MOVE statement 200
relation condition 161
USAGE clause
description 137,140
format 136
external floating-point items
collating sequence 244
description 137
internal representation 141
MOVE statement 200
relation condition 161
USAGE clause
description and format 137,136
internal representation 141
VALUE clause 143
external-name in ASSIGN clause 71

F-mode records
description 103,104
and OPEN REVERSED 207
recording mode 103,104
report print line 255
in sort 241
specification 104
FD (see file description entry)
figurative constants
description 43
EXAMINE statement 201,202
MOVE statement 200
relation condition 161
TRANSFORM statement 203-205
VALUE clause' 142
file
definition 93
disposition of
CLOSE statement 221-225
OPEN statement 206-208
FILE-CONTROL paragraph 68-83
file description entry 100-107
inter-record slack bytes 135,136
I-O-CONTROL paragraph 84-89
FILE-CONTROL paragraph
ACCESS MODE clause 78
ACTUAL KEY clause 79-81
ASSIGN clause
description and format 69-75
for sort 238~239
copying 313-315
FILE-LIMIT clause 77,78
format 68
NOMINAL KEY clause 82
PROCESSING MODE clause 78,79
RECORD KEY clause 83

RESERVE clause 77,238
SELECT clause
description and format 69
for sort 238,239
sort considerations 238,239
TRACK-AREA clause 83
FILE-CONTROL paragraph (DOS/VS)
merge facility XXll
VSAH files v-viii
3340 and 3540 devices xxiv,xxv
file description entry
BLOCK CONTAINS clause 100,101
description and format 100,97
DATA RECORDS clause
description and format 106,107
report writer 255
LABEL RECORDS clause 105,106
RECORD CONTAINS clause
description and format 102,103
report writer 255
RECORDING MODE clause 104,255
REPORT clause 254,255
report writer 254,255
sort 241,242
VALUE OF clause 106
file description entry, VSAM (DOS/VS) ix
file information area for OCR
(DOS/VS) XXVlll
FILE-LIMIT clause 77,78
file-name, definition 41
file processing technique
general description 59-62
input/output errors 175-178
sample programs 33,34,336-340
statements and clauses 352-354
summary 59-62,352-354
file processing technique (DOS/VS)
System/370 device summary xxxiv
VSAM summary xiv
File section
ASCII considerations 356,357
boundary alignment 131
content 97,100-107
copying 313-315
file description entry 97,100-107
format 97,100
naming data 111
record description entry 108,109,97
report writer considerations 254,255
sort considerations 241,242
file size for sort 249
FILE STATUS clause, VSAM (DOS/vS) V,Vlll
files sharing same storage area 85,86
FILLER
CORRESPONDING option 179
inter-record slack bytes 135,136
record description entry 111,108
FINAL control
CONTROL clause 257,258
TYPE clause 267-269
final phase of sort 248
FIPS flagger description
(DOS/VS) xxviii-xxxiii
fixed insertion editing 126
fixed length record format (see F mode
records)
fixed point numeric item 122
fixed point numeric literal 42

fixed portion of a segmented
program 309,311
floating insertion editing 127
floating-point data items (see external and
internal floating-point items)
floating-point numeric literal
description 42
MOVE statement 200
flowchart
nested IF statement 168
PERFORM statements
varying one identifier 193
varying three identifiers 195
varying two identifiers 194
SEARCH statement 304
footing report groups
CONTROL clause 257,258
GENERATE statement 274
NEXT GROUP clause 266
PAGE LIMIT clause 259,260
report group description 261
SUM clause 272,273
TYPE clause 267-269
form overflow (see end of page condition)
format
DISPLAY statement output 220,221
EXHIBIT statement output 318-320
logical records 95,96
reference 50-52
report page 252-254
format control of the source program
listing 323
format F records (see F-mode records)
format notation 53,54
format S records (see S-mode records)
format summary 341-350
format U records (see U-mode records)
format V records (see V-mode records)
fractions, internal floating-point
items 138,141
FROM identifier option, VSAM (DOS/VS)
description x,xi
REWRITE statement xi
WRITE statement xvii,xi
full FIPS flagging (DOS/VS) xxix-xxxi
full word
binary item 138
slack bytes 132
SYNCHRONIZED clause 131
function-name
CODE clause
description and format 256,257
in SPECIAL-NAMES 66,67
description 66,67,41
in SPECIAL-NAMES paragraph 66.67
in switch-status condition 162,66,67
System/370 card devices 379,380
in WRITE statement 214-217,66

GENERATE statement 273,274.,253
generic key
specification 208,209
GIVING option
arithmetic statements
ADD 181
description 179
Index

407

DIVIDE 183
MULTIPLY 184
SUBTRACT 185
error handling declarative 175-178
SELECT sentence format 238
SORT statement
description 247,243
GIVING option (DOS/VS)
merge statement xxvi
3540 error processing xxxv, xxxvi
glossary 385-397
GO TO MORE-LABELS 171,172
GO TO statement
ALTER statement 188
CALL statement 227
debug packet 322
description and formats 187,188
error processing procedures 177
IF statement 166
label handling procedures 171,172
PERFORM statement 190
segmentation 312
sort procedure 245,246
GO BACK statement
description and format 232,231
symbolic debugging 365
group
collating sequence for sort 244
contents 95,96
report 261-263
GROUP INDICATE clause 270~273
group item
description 95,96
MOVE statement 200,199
OCCURS clause 294
relation condition 161
renaming 144-146,112-115
report 261-263
slack bytes 132-136
USAGE clause 136
VALUE clause 143,144

halfword
binary item 138,140
slack bytes 132
SYNCHRONIZED clause 131
halting execution
STOP RUN 196
subprograms linkage 231,232
header labels
description 105
nonstandard 105,170
standard 105,170
user 105,170
heading report groups
CONTROL clause 257,258
GENERATE statement 274
NEXT GROUP clause 266
PAGE LIMIT clause 259,260
report group description 261
SUM clause 272,273
TYPE clause 267-269
hierarchy
arithmetic expressions 153
controls in report writer 268,257
qualification 48,49

408

relations 163
structure of a record 95,96
high-intermediate FIPS flagging
(DOS/VS)
xxxi, xxxii
HIGH-VALUE (HIGH-VALUES) figurative
constant
description 43
MOVE statement 200
permissible comparisons 161
RECORD KEY 83
TRANSFORM statement 203-205
hyphen
(see also minus symbol)
collating sequence 159,244
continuing lines 52
program-names 58
words 37

1-0 files
CLOSE options 222-225
error handling 175-178
label handling 170-171
OPEN statement 206-208
REWRITE statement 218,219
WRITE statement 213,217,218
I-O-CONTROL entry (DOS/VS)
merge facility xxii, xxiii
VSAM files viii,ix
3340 and 3540 devices xxxv
I-O-CONTROL paragraph
APPLY clause 87-89
copying 313-315
description and formats 84-89
MULTIPLE FILE TAPE clause 86,87
purpose 84
RERUN clause 84,85
SAME clause 85,86
sort considerations 239-241
IBM sterling representation 324
ID Division header 57,46
Identification Division
comment-entry in 57,58
DATE-COMPILED paragraph 58
header 57,46
PROGRAM-ID paragraph 57,58
structure of 57
identifier, definition 48
identifying records
da ta -name 111
indexing 290~291
qualification 48,49
reports 261
subscripting 289,290
IF statement
description and format 166-168
nested 167,168
IGN parameter of ASSGN job control
statement 69
imperative statements
arithmetic 179-186
data-manipulation 198-205
declarative 169-178,276,277
definition 150
input/output 206-225
procedure branching 187-197
report writer 273-276

sort 242-249
table handling 301-306
implied subjects and
relational-operators 164,165
IN qualifier connective
indexes 291
names 48
subscripts 290
incrementing
index-name values 306,299
LINE-COUNTER special register 278
PAGE-COUNTER special register 277
SUM counters 272,273
indentation of level numbers 97
independent segment 309-312
index data it-em
MOVE statement 198
relation condition 300,301,161
USAGE clause description 299,300
index-name
description 297,41
modifying values in 306,299
MOVE statement 198
OCCURS clause 293,296-299
PERFORM statement 189,191,192
relation condition 300,301,161
SEARCH statement 301-305
SET statement 306
subprogram linkage and 236,229
value in 297-299
INDEX option of the USAGE clause (see index
data item)
INDEXED BY option of the OCCURS clause (see
index-name)
indexed data organization 60
indexed files
access techniques 61,62
APPLY clause 88,89
ASSIGN clause 69-71
blocking factor 101
error processing 175-178
index in core 89
initiating processing 206-209
invalid key condition
READ 211,212
REWRITE 218,219
START 208,209
WRITE 213,217,218
LABEL RECORD clause 105
NOMINAL KEY clause 82
OPEN statement 206-208
overflow areas 88
READ statement 211,212
RECORD KEY clause 83
recording mode 104
restrictions on processing of

208,61

REWRITE statement 218,219
START statement 208,209
VSAM (see VSAM file processing)
WRITE statement 213,217~218
indexes used with qualifiers 290,291
indexing tables
description 290,291
direct 298,.290
INDEXED BY option 296-299
relative 299,291
initializing
index values 306,191

report writer special registers 275
sort special registers 249
values of data items 142
INITIATE statement 275,253
initiating
access to a mass storage file 208-210
file processing 206-208
report processing 275
input files
APPLY EXTENDED-SEARCH 87
effect of close options 222-225
error handling 175-178
inter-record slack bytes 135,136
intra-record slack bytes 132-135
label handling 170-172
OPEN statement 206-208
READ statement 211,212
record size 102
input format for source programs 50-52
input/output areas (buffers) 77
input/output error (see error processing
declaratives,. invalid key condition)
Input-Output Section
copying 313-315
description and format 68
File-Control paragraph 68-83
I-O-Control paragraph 84-89
sort considerations 238-241
Input-Output Section (DOS/VS)
merge facility xxii, xxiii
sort feature xxxvi
VSAM files v-ix
3340,3540 considerations xxxiv.xxxv
input/output statements
ACCEPT 219,220
CLOSE 221-225
DISPLAY 220,221
OPEN 206-208
READ 211,212
REWRITE 218,219
SEEK 210
START 208,209
WRITE 212-218
input/output statements, VSAM (DOS/VS)
CLOSE xxi
DELETE xx, xxi
OPEN xiii-xv
READ xvi,xvl.l.
REWRITE xix,xx
START xv
WRITE xVl.l.-xix
input phase of merge (DOS/VS) xxv, xxvi
input phase of sort 245-248
input phase of sort (DOS/VS) xxxvi
INSERT card for copying 316,317
insertion
asterisks 128,120
commas 125,119
currency symbol 126,120
periods 125,119
sign control symbols 126,120
spaces
single insertion 125
symbols 118,119
zero suppression 128
zeros 125 .. 119
insertion character, and item size 118-120

Index

409

insertion editing
fixed 126
floating 127
simple 125
special 125
INSTALLATION paragraph 57
integer, description 42
integer literals (see fixed-point numeric
literals)
inter-record slack bytes 135,136
intermediate results
arithmetic statements 333,334
compound conditions 163,164
internal data 98
internal decimal items
allowable characters 139
class test 156
collating sequence 243,244
description 139
internal representation 141
MOVE statement 200
relation condition 161
SYNCHRONIZED clause 131
USAGE clause
description and format 139~136
internal representation 141
internal floating-point items
collating sequence 244
description 138
internal representation 141
MOVE statement 200
relation condition 161
USAGE clause
description and format 138,136
internal representation 141
internal representation
alphabetic and alphanumeric items 137
external decimal items 137,140
numeric items 140,141
sterling items 324
international currency
considerations 330,65-67
INTO/FROM identifier option, VSAM (DOS/VS)
description xi
READ statement xi ,.xvi
REWRITE statement xi
WRITE statement xi,xviii
intra-record slack bytes 132-135
INVALID KEY condition
READ 211,212
REWRITE 218,219
SEEK 210
START 208,209
WRITE 213,217,218
INVALID KEY condition, VSAM (DOS/VS)
DELETE statement xx.xi
description xi
READ statement xv~~,xi
REWRITE statement xx,xi
START statement xv,xi
WRITE statement xviii,xix,x
INVALID KEY option (see invalid key
condition)
justification
and JUSTIFIED clause 116
and MOVE statement 199
JUSTIFIED clause 116
"1
f\
... ..LV

KEY clauses
ACTUAL 79-81
NOMINAL 82
RECORD 83
RECORD, VSAM (DOS/VS) vii,viii
KEY option
MERGE statement CDOS/VS} xxv, xxvi
OCCURS clause 295,296
SEARCH ALL statement 302,305
SORT statement 243,244
START statement 208,209
key words
description 40
format notation 53
keys
for MERGE statement (DOS/VS) xxv, xxvi
for SORT statement 243,244
for START statement 208,209
for START statement (DOS/VS) xv
for table SEARCH
KEY option 295,296
SEARCH ALL statement 305,302

label handling
ASCII considerations 356
CLOSE options 222-225
declarative 170-175
LABEL RECORDS clause 105,106
multivolume files 223
OPEN statement 206-208
sample program 172-175
for sort 241,242
USE sentence 170,171
writing 217
LABEL RECORDS clause
ASCII considerations 356
description and format 105,106
label procedures 170.171
LABEL RECORDS clause (DOS/VS)
VSAM ix
3540 xxxv
leading zeros, suppression 127,128
left justification 116
length
binary items 138
BLOCK CONTAINS clause 100,101
data-name in APPLY CORE-INDEX 89
external decimal items 137
external floating-point items 122,123
internal decimal items 139
internal floating-point items 138
RECORD CONTAINS clause 102,103
and standard data format 102
level indicator
file description entry 97,100
reference format 51
report writer feature 254,256
sort feature 241
summary of 95
level number
data description entry 111,108-110
indentation of 97
reference format 51
special 108-110
summary of 96,97
use 95-97

level number 01 items
boundary alignment 131,229
CALL statement 229
copying 313-315
description 96
File Section
data description 108,109
REDEFINES restriction 112
word boundary 131
Linkage Section
data description 108,109
description 98,99
subprogram linkage 229
word boundary 131,132
reference format 51
Report Section 261-263,265-269
SYNCHRONIZED clause 130.131
Working-Storage Section 108,109,131
level number 02-49 items
data description clauses 108,109
description 95,96
indentation 97
reference format 51
Report Section 261-263
slack bytes 132-135
SYNCHRONIZED clause 130
Working-Storage section 108,109,98
level number 66 items
description 96,109
format 108
indentation 97
RENAMES clause 144-146
restrictions 109
rules for use 109
level number 77 items
called subprograms 229
copying 313-315
description 96
Linkage section
description 99
subprogram linkage 229
word boundary 131
reference format 51
use 96,108,109
VALUE clause 142,143
Working-Storage section 98,108,109
level number 88 items
condition-name condition 157
description and format 109,110,91
indentation 97
rules for use 109,110
VALUE clause 142-144
library facility (see source program
library facility)
library-name 313-315,41
LINE clause 263-265
line-control cards 364,365
LINE-COUNTER special register
description 218
GENERATE statement 214
INITIATE statement 215
lines in a report 258-260,263-266
lines, spacing of
program output 213-211
report 263-266
source program 323~52
Linkage Section
boundary alignment 130,131,229

content 98,99
copying 313-315
data item description entry 108,109
error declarative 111
format 99
intra-record slack bytes 132-135
record description entry 108,109
structure 94
use of FILLER 111
USING option of the CALL statement 229
VALUE clause 142
Linkage Section and OCR processing
(DOS/vS) xxviii
liT~age statements for subprograms (see
subprogram linkage statements)
list of compiler features
DOS/VS COBOL 11
Version 3 COBOL 11-13
lister facility (DOS/VS) 11
literal
CODE clause 256,257
description 41,42
as a function-name 66,61
MOVE statement 200
nonnumeric 42
numeric 42
permissible comparisons 161
VALUE clause 142-144
location of slack bytes 132-136
logical connectives in compound
conditions 162-165~40
logical operators 162,40
logical record
description 93
redefining
description 112-115
File Section restriction 112
renaming 144-146
size of 102
slack bytes in 132-136
long-precision internal floating point
items (see internal floating-point items)
low FIPS flagging (DOS/VS) xxxii. xxxiii
low-intermediate FIPS flagging
(DOS/VS) xxxii
LOW-VALUE (LOW-VALUES) figurative constant
in ACTUAL KEY clause 80
description 43
MOVE statement 200
track identifi~r 80
TRANSFORM 203-205
lowercase letters in ACCEPT (DOS/VS) xxxvi
lower-case words in formats 53

magnetic tape (see tape)
magnitude of floating-point items 137
main program, description 226,,221
major control break 251,258
mantissa
description 131,138
internal representation 141
PICTURE clause 123
mass storage devices
DOS/VS information
(DOS/VS) iv, xxxiv-xxxvi
Index

411

error information 176,178
list of 70,72
mass storage files
(see also VSAM file processing (DOS/VS»
CLOSE statement 221-225
OPEN statement 206-208
READ statement 211,212
REWRITE statement 218,219
SEEK statement 210
START statement 208,209
WRITE statement 213,217,218
maximum length
arithmetic operands 181-184,186
binary items 138
data description entries 108
external decimal items 137,122
floating-point items 122,123,137
internal decimal items 138,122
items in EXHIBIT statement 318-320
keys in
sort 244
table handling 295
numeric edited items 124
PICTURE character string 117
record
CONSOLE 220
data 108
SYSLST 220
SYSPCH/SYSPUNCH 220
tables 293
maximum length, keys in merge (DOS/VS) xxv
maximum number
index-names 296
keys
sort 244
table handling 295
procedure-names in GO TO statement 187
maximum number, keys in merge (DOS/VS)
xxv
maximum size (see maximum length)
maximum value
ACTUAL KEY track identifier 80
binary item and PICTURE clause 118,138
floating-point items 137,42
NSTD-REELS special register 45
ON statement integer 321
RERUN clause integer 85
RESERVE clause integer 77
subscript 289
MEMORY SIZE clause 65
merge feature (DOS/VS)
FILE-CONTROL entry
ASSIGN clause xxii
SELECT clause xxii
I-O-CONTROL entry xx~~,xx~~~
input/output files valid xxii
MERGE statement
ASCENDING/DESCENDING KEY
option xxv, xxvi
file-names in xxv, xxvi
format xxv
GIVING option xxvi
OUTPUT PROCEDURE option xxvi,xxv~~
segmentation restrictions xxvii
USING option xxvi
SAME clause xxii, xxiii
SO entry xxiv
methods of data reference 48,49

412

MFCU (multifunction card unit) support
(DOS/vS) xxxiv,xxxvi,ll
minimum value
floating-point items 137,42
subscript 289
minor control break 268~257,258
minus symbol
(see also hyphen)
arithmetic expressions 153,154,39
collating sequence 159,244
external floating-point literals 42
indexing 299,290,291
PICTURE clause
description 120,121
external floating-point
items 137,123
numeric edited items 124-128
sterling items 325-329
SIGN clause 129,130
as unary operator 153,154
miscellaneous considerations
(DOS/VS) xxxiv-xxxvi
mnemonic-name
ACCEPT statement 219,220
assignment of 66,67
CODE clause 256,257
DISPLAY statement 220
SPECIAL-NAMES paragraph 66,67
WRITE statement 213-216
mode F records (see F-mode records)
mode U records (see U-mode records)
mode V records (see V-mode records)
modification
library text
DELETB and INSERT cards 316,317
sort records
after sorting 246,241
before sorting 245
MOVE statement
CORRESPONDING option 198,199
description and formats 198-200
permissible moves 200
sort special registers 249
sterling items 330
multifunction card unit (MFCU) support
(DOS/VS) xxxiv,xxxvi wll
MULTIPLE FILE TAPE clause 86,87
multiple results
ADD statement 181
SUBTRACT statement 185
multiplication 184,153,154
multiplication operator 153,154,39
MULTIPLY statement 184
multivolume processing
ASSIGN clause 69,10
CLOSE statement 221-225
NSTD-REELS special register 69,70,45
reading 212
writing 217
name
data item 111
description of 41
field in system-name 71
indexing of 290,291,296-299
procedure 41
qualification 48,49
record 111,41
subscripting of 289,290

NEGATIVE operand in a sign condition 162
negative value
DISPLAY statement 221
external floating point items 123
numeric edited items 124-128
PERFOR~ statement
191
SIGN clause 129,130
sign condition 162
nested
IF statements 167,168
OCCURS clauses 293-295
PERFORM statements 190
REDEFINES clauses 113
NEXT GROUP clause
description and format 265,266
effect of PRINT-SWITCH 277
NOMINAL KEY clause
description and format 82
indexed files 61,62
READ statement 211,212
REWRITE statement 218,219
START statement 208,209,82
WRITE statement 217,218,212
noncontiguous data items
(see level number 77 items)
nonnumeric literals
continuation of 52
description 42
EXAMINE statement 201,202
MOVE statement 200
relation condition 161
TRANSFORM statement 20~-205
VALUE clause 142-144
nonnumeric operands
MOVE statement 199,200
relation condition 159-161
nonstandard labels
declarative 170-175
GO TO MORE-LABELS 171,172
LABEL RECORDS clause 105,106
multiple reel files 69,70,45
NSTD-REELS special register 45,69,70
reversed reading 86,81,201
sample program 173-115
system procedures 110,111
NOT condition construction
abbreviated conditions 164,165
compound conditions 162-165
test conditions 155
NOT logical operator
description 162-165
implied subjects and relational
operands 164,165
NOTE statement 233,234
NSTD-REELS special register 45,69,70
null report group 261
numeric character
description 119-121
PICTURE clause 119-128
numeric class test 156
numeric data item
BLANK WHEN ZERO clause 115
class test 156
EXAMINE statement 201,202
fixed-point
binary 138-140
external decimal 131,140
internal decimal 139,141

floating-point
external
description 131,122,123
internal representation 141
internal 138,141
internal representation 140,141
MOVE statement 199,200
PICTURE clause 122,123
relation condition 161,159
VALUE clause 142-144
numeric data item (DOS/VS)
FILE STATUS clause, VSAM viii
RECORD y~y clause, vs~_~ vii. vii
numeric edited items
BLANK WHEN ZERO clause 115
description 124-128
MOVE statement 199,200
relation condition 159-161
USAGE clause 137
numeric item, description 122,123
numeric literal
continuation 52
description 42
MOVE statement 200
relation condition 161
VALUE clause 142-144
numeric operands
ADD statement 181,182
COMPUTE statement 182
DISPLAY statement 221
DIVIDE statement 183
EXAMINE statement 201~202
MOVE statement 199,200
MULTIPLY statement 184
relation conditions 159,161
SUBTRACT statement 185,186

OBJECT-COMPUTER paragraph
computer-name 65
copying 313-315
description and format 65
SEGMENT-LIMIT clause 311,65
System/310 instruction generation 65
OBJECT-COMPUTER paragraph (DOS/VS) ii-iv
object of a condition 158
object program definition 51
OCCURS clause
description and formats 292-299
direct indexing 298
redefining restriction 112
relative indexing 299
renaming restriction 145
slack bytes 133-135
value restriction 142
OCR processing (DOS/VS) xxvii,xxviii
OF qualifier connective
with indexes and subscripts 289-291
with name 48,49
OFF/ON STATUS clause 66,67
OMR (optical mark read) processing 72,16
ON statement 320,321
Version 3 improvement 320,321
ON/OFF STATUS clause 66,67
OPEN statement
declaratives 170-115
description and format 206-208
Index

413

OPEN statement, VSAM (DOS/VS)
description and format xiii-xv
PASSWORD clause xiv,viii
processing capabilities xiv
status key xiv,x
OPEN statement for 3540 (DOS/VS) xxxvi
operands, overlapping
arithmetic statements 180
MOVE statement 199
TRANSFORM statement 203
operation sign (see sign, SIGN clause)
operator communication 196,219-221
optical character reader
(DOS/VS) xxvii,xxviii
optical mark read processing 72,76
optimized object code, Version 3 12
optional words in formats 53
OR logical operator in compound
conditions 162-165
order of evaluation for compound
conditions 163,164
order of execution 150
organization
COBOL program 46~47
data 59-62,93
Data Division 94
Data Division entries 95-97
Environment Division 63
field of system-name 71-75
Identification Division 57
Procedure Division 149,150
ORGANIZATION clause, VSAM (DOS/vS>
description and format vii,v
processing capabilities xiv
output files
CLOSE options 222-225
error handling 175-178
inter-record slack bytes 135,136
intra-record slack bytes 132-135
label handling 170-175
OPEN statement 206-208
sample programs 336-338
WRITE statement 212-218
output files, VSAM (DOS/VS)
OPEN statement Xl11-XV
processing capabilities xiv
WRITE statement xvii-xix
output phase of merge (DOS/vS) xxv-xxvii
output phase of sort 246-248
output source listing format
compiler 50-52
control of 323
overflow records 88
overlapping data groupings 144-146
overlapping operands
arithmetic statements 180
MOVE statement 199
TRANSFORM statement 203
overlayable fixed segment 309-311
overlaying procedures 309-312

P, in PICTURE clause (see assumed decimal
point)
packed decimal format (see internal decimal
items)

padding in a physical record
BLOCK CONTAINS clause 100,101
slack bytes 132-136
page change in a report
GENERATE statement 274
LINE clause 263-265
NEXT GROUP clause 265,266
PAGE LIMIT clause 258-260
PAGE clause (see PAGE LIMIT clause)
page condition 258-260
PAGE-COUNTER special register
description 277
GENERATE statement 274
INITIATE statement 275
PAGE FOOTING report group
description 268
LINE clause 263-265
NEXT GROUP clause 265,266
PAGE LIMIT clause 258-260
TERMINATE statement 275,276
TYPE clause 267-269
page format in Report Writer 258-260
PAGE HEADING report group
definition 267
GENERATE statement 273,274
LINE clause 263-265
NEXT GROUP clause 265,266
PAGE LIMIT clause 258-260
TYPE clause 267-269
PAGE LIMIT clause 258-260
pairing
ELSE in nestep IF statements 167,168
parentheses in arithmetic
expressions 153,154
parentheses in subscripts and
indexes 289-291
symbols in arithmetic expressions 154
symbols in compound conditions 164
paragraph
DATE-COMPILED 58
definition 149
FILE-CONTROL 68-83
I-O-CONTROL 84-89
OBJECT-COMPUTER 65
Procedure Division 149,51
PROGRAM-ID 57,58
SOURCE-COMPUTER 64
SPECIAL-NAMES 65-67
paragraph-name
qualification 48,49
reference format 51
rules for forming 149,41
parameters for OCR processing
(DOS/VS) xxviii
parentheses
arithmetic expressions 153,154
conditions 163,164,155
PICTURE clause 118
punctuation rules 38
subscripting and indexing 289-291
parity checking 88
PASSWORD clause, VSAM (DOS/VS)
description and formats viii,v
OPEN statement xiv
pence
internal representations 324
nonreport items 325,326

report items 327-329
PERFORM statement
CALL statement 227
debug packets 322
declarative section 171,176,277
description and formats 189-195
flowcharts 193-195
segmentation 312
sort procedures 245,246
period
and comma exchanged 66,67,330
data description entry 108,109
division header 51
END DECLARATIVES 169,150
fixed-point numeric literals 42
floating-point numeric literals 42
paragraph-name 149,51
PICTURE clause
description 119.121
external floating-point items 123
indicated by P 119
indicated by V 119
numeric edited items 124-128
sterling items 325-329
section-header 149,51
section-name 149,51
sentence 149
permanent segment 309-311
permissible
comparisons 161
moves 200
symbol pairs
arithmetic expressions 154
compound conditions 164
physical file, definition 93
physical record
definition 93
size specification 100,101
PICTURE clause
allowable symbols 118-120
ASCII considerations 357,361
categories of data
alphabetic 120
alphanumeric 120
alphanumeric edieed 124
numeric 122,123
numeric edited 124-128
table of 117
character string 117,118
classes of data 117
editing
fixed insertion 126
floating insertion 127
simple insertion 125
special insertion 125
zero suppression and replacement 128
format 117
precedence of symbols in 121
repetition of symbols 118
plus symbol
arithmetic expressions 153,154
collating sequence 159,244
indexing 290,291,299
PICTURE clause
description 120,121
external floating-point
items 122,123
fixed insertion editing 126

floating insertion editing 127
numeric edited items 124-128
precedence in 121
sterling items 325-329
SIGN clause ~29,130
unary operator 153,154
pocket select characters
combined function processing 379,383
definition 66
WRITE statement 214-216
positioning a file
CLOSE statement 222-224
MULTIPLE FILE TAPE clause 86,87
OPEN statement 206-208
POSITIVE operand in sign condition 162
positive value
external floating-point items 122,123
PERFORM statement 191
sign condition 162
unsigned operands 162,199
pound-report-string 327
pound-separator-string 327
pound sign
report item 327,329
representation 329
print line size for report 255
PRINT-SWITCH
description 277
INITIATE statement 275
NEXT GROUP report groups 266
printer support, Version 3 13
printer support, DOS/VS 11
priority numbers
ALTER statement 312
called programs 312
description 310,311
information for use 310
PERFORM statement 312
section header 310,311
seqment limit 311
procedure branching statements
ALTER statement 188
EXIT statement
description and format 196,197
subprogram linkage 231,232
GO TO statement 187,188
PERFORM statement 189-195
STOP statement 196,231
procedure, definition 149
Procedure Division
content 149-152
copying 313-315
definition 46
organization 149,150
Report Writer cons~derations
declarative 276,277
GENERATE statement 273,274
INITATE statement 275
overall 252-254
TERMINATE statement 275,276
Sort considerations
EXIT statement 248,249
RELEASE statement 247,248
RETURN statement 248
SORT statement 242-247
statement list 151,152

Index

415

statements (see compiler-directin~
statements, conditional statements,
imperative statements)
sterling considerations 330
structure 150
table handling considerations
relation conditions 300,301
SEARCH statement 301-305
SET statement 306
USING option on the division
header 228-231,149,150
Procedure Division (DOS/VS)
merge facility XXV-XXVll
VSAM file processing
common processing facilities ix-xi
CLOSE statement xxi
DELETE statement xx, xxi
EXCEPTION/ERROR declarative xii, xiii
file processing capabilities xiv
OPEN statement xiii-xv
READ statement xvi, xvii
REWRITE statement xix,xx
START statement xv
WRITE statement xvii-xix
procedure-name, definition 41
procedures, Declarative 169-178,276,277
processing capabilities summary, VSAM
(DOS/VS) xiv
PROCESSING MODE clause 78,79
program-control card 364
PROGRAM-ID paragraph 57,58
program-name
description 58
subprogram linkage 226
program termination 196,231,232
punctuation character
in formats 53
in a source program 38
quadruple spacing of source program
listing 323
qualification
condition-names 144,48,49
description 48,49
index-names 290,291
names 48,49
subscripts 289,290
qualifier connective, definition 40
qualifier, definition 48
quotation mark option
default 37
nonnumeric literals 42
program-name 58
QUOTE (QUOTES) figurative constant
description 43
in EXAMINE 201
in MOVE 200
in relation condition 161
in TRANSFORM 203
quotient 183

random access
ACCESS MODE clause 78
CLOSE statement 224,225
definition 60
direct files 61
I,.,

c.

"t.l.U

error processing 175-178
indexed files 61,62
READ statement 211,212
REWRITE statement 218,219
SEEK statement 210
WRITE statement 213,217,218
random access, VSAM (DOS/VS) vii
random file processing
effect of CLOSE options 224,225
function of a read 211,212
function of a REWRITE 218,219
function of a SEEK 210
function of a WRITE 212,217,218
summary charts 353,354
range of a PERFORM statement 190-195
range of values
condition-name 143,144
priority numbers 310,311
sequence numbers on DELETE card 316,317
RCE (read column eliminate)
processing 72,73,76
RD (see report description entry)
READ statement
description and format 211,212
error processing 178
READ statement, VSAM (DOS/VS)
description and formats xvi, xvii
processing capabilities xiv
reading backwards 207
reading nonstandard labels
ASSIGN clause 70,71
MULTIPLE FILE TAPE clause 86
OPEN statement 207
READY/RESET TRACE statement 318
receiving data item
justification 116
MOVE statement 199,200
record
description 108,109
level number 95-97
naming 111
slack bytes
between records 135,136
within records 132-135
RECORD CONTAINS clause
description and format 102,103
Report Writer 255
Sort 241,242
RECORD CONTAINS clause, VSAM (DOS/VS) ix
record description entry
contents 108,109
definition 96
File Section 97
format 108
Linkage section 99
maximum length 108
Report Writer 255
Sort records 241,242
Working-Storage Section 98
(see also data description clauses)
RECORD KEY clause 83
RECORD KEY clause., VSAM (DOS/VS)
description and format vii.viii,v
START statement xv
record length for sort records 241,242
record size default
ACCEPT statement 219
DISPLAY statement 220
report writer 255

recording mode
ASCII considerations 357
default 103,104
specification 104
types 103,104
RECORDING MODE clause
ASCII considerations 357
description and format 102
RECORDING MODE clause invalid, VSAM
(DOS/VS)
ix
REDEFINES clause
APPLY CORE-INDEX option 89
description and format 112-115
position when used 109,112
SYNCHRONIZED clause 131
VALUE clause 143
reference format 50-52
reformatted (lister) source listing
(DOS/VS) 11
registers (see special registers)
regrouping data items
REDEFINES clause 112-115
RENAHES clause 144-146
relation character
definition 39
in relation conditions 158
relation conditions
ASCII considerations 358-360
characters used 158,39
condition-name as abbreviation 157
description and format 158-161
impliea subject and relational
operators 164,165
operands allowed 161
table handling 300,301
relational-operators
compound conditions 162-165
definition 39
implied 164,165
relation condition 158
relative indexing 290.291,299
relative LINE clause 263-265
RELEASE statement in sort 247,248
relocation factor, Version 3 13
remainder, definition 183
REMARKS paragraph 57
RENAMES clause
data description entry 108,109
description and format 144-146
level number summary 96
renaming
data items (see REDEFINES clause,
RENAMES clause)
logical records 112,97
repetition of symbols in PICTu~E 118
replacement editing 128
replacing zero with a space
BLANK WHEN ZERO clause 115
editing rules 124-128
PICTURE clause symbol 119
REPORT clause 254,255,100
REPORT clause invalid, VSAM (DOS/VS)
ix
report, description 252-254
report description entry
CODE clause 256,257
CONTROL clause 257,258
COPY statement 313-315
definition 256

GENERATE statement 273,274
PAGE LIMIT clause 258-260
report file, definition 254
REPORT FOOTING report group
description 267-269
LINE clause 263-265
NEXT GROUP clause 265",266
PAGE LIMIT clause 258-260
TERMINATE statement 275,276
TYPE clause 267-269
report group description entry
COLUMN clause 269
COpy statement 313-315
description and formats 261-263
GROUP INDICATE clause 270
LINE clause 263-265
NEXT GROUP clause 265,266
RESET clause 270,271
SOURCE clause 271
SUM clause 271-273
TYPE clause 267-269
USAGE clause 269
VALUE clause 273.271
report groups
definition 261
page format 259
sequence of printing 268,269
types 267-269
USE sentence 276,277
REPO~J:' HEADING report group
descrl.ptIori 26"7-269
GENERATE statement 274
LINE clause 264
NEXT GROUP clause 266
PAGE LIMIT clause 259
TYPE clause 267,268
report page format effect on
LINE-COUNTER special register 278
PAGE-COUNTER special register 277
PAGE LIMIT clause 258-260
Report Section
content 256-273
COpy statement 313-315
formats
report description entry 256
report group description
entry 261,262
structure 94
VALUE clause
description and format 273,271
overall description 142
Report Writer
Data Division considerations
File Section 254,255
overall description 252-254
Report Section 256-273
Procedure Division considerations
declarative 276,277
GENERATE statement 273,274
INITIATE statement 275
overall description 253,254
TERMINATE statement 275,276
USE statement 276,277
sample program
coding 279-283
output 284-288
special registers 277.278
Index

417

report-name
definition 41
qualifier for SUM counter 261
specification 256,273,274
RERUN clause
ASCII considerations 356,361
processing programs 84,85
sort feature 240,361
RERUN clause, VSN~ (DOS/VS) Vlll,lX
required words in formats 53
RESERVE clause
description and format 77
System/370 card devices 381
RESERVE clause, VSAM (DOS/VS) v,vi
reserved words
definition 40
in formats
53
list of 344-346
RESET clause, Report Writer 270,271
RESET TRACE statement 318
restarting a program 84,85,240
retrieving an indexed file
access methods 61,62
READ statement 211,212
restriction 208
START statement 208,209
return code
multivolume files 69,70
sort 249
return code, VSAM status key (DOS/VS)
x
return from merge (DOS/VS)
GIVING option xxv, xxvi
output procedure xxv-xxvii
return from sort
GIVING option 247
output procedure 246,247
RE'I'URN statement in merge (DOS/VS) xxvi
RETURN statement in sort 248
reversed reading of a file 207
rewinding a tape file
CLOSE statement 222-224
OPEN statement 206,207
REWRITE statement
description and format 218,219
error processing 178
REWRITE statement, VSAM (DOS/VS)
description and format xix,xx
processing capabilities xiv
rewriting mass storage files 218,219 w 60-62
right justification 116
rolling counters forward 272
ROUNDED option in arithmetic statements
ADD 181
COMPUTE 182
description 179,180
DIVIDE 183
MULTIPLY 184
SUBTRACT 185
rounding 179,180

S, in PICTURE clause
class test 156
description 119,121
numeric items 122,123
precedence 121
SIGN clause 129-130
418

sterling nonreport items 326
S-mode records
BLOCK CONTAINS clause 101
description 103,104
RECORDING MODE clause 104
SAME clause
description and format 85 w 86
sort considerations 240,241
SAME clause (DOS/vS)
merge facility xxii,xxiii
VSAM files viii,ix
sample programs
creation of a direct file 336 u 337
creation of an indexed file 338
report writer 279-288
retrieval of a direct file 33,34
retrieval of an indexed file 339,340
sort 250,251
table handling 307,308
scaling, effect on rounding 180
scaling position character (p) 119,121
scientific decimal item (see external
floating-point items)
SEARCH statement
description and formats 301-305
flowchart 304
section
classification in segmentation 310,311
definition 149
format 150,310
section header 149,51
section-name 150,310
SECURITY paragraph 57
SEEK statement 210
segment classification 310,311
SEGMENT-LIMIT clause 311
segmentation
ALTER statement 312
called programs 312
classifying segments 310,311
control of 310
fixed portion 309,311
GO TO statement 312
independent segments 309,311
overlayable fixed segments 309,311
PERFORM statement 312
permanent segments 309,311
priority numbers 310,311
program organization 309
restrictions on program flow 312
segment limit 311
segmentation merge restrictions
(DOS/VS) xxvii
SELECT clause
COPY statement 313-315
description and format 69
GIVING option of SORT statement 238,239
sort work units 239
SELECT clause (DOS/VS)
merge facility xxii
VSAM files v,vi
semicolon
data description entry 109
separating statements 149
source program 38
SPECIAL-NAMES paragraph 66
sentence
conditional 166

t

description 149
termination 149
SEPARATE CHARACTER option of SIGN
clause 129.130
separator
statements 149
sterling items 327-329
words 40
sequence
entries in Data Division 100,109
entries in Environment Division 68,84
entries in formats 46
execution of Procedure Division 150
execution of segmented programs 310
report groups 261
sorting 243,244
table entries 295,296
sequence checking compilation default 50
sequence-number-field for copying 316,317
sequence number in a source program 50
sequential access
ACCESS MODE clause 78
ACTUAL KEY clause 79
APPLY WRITE-ONLY clause 87
,ASSIGN clause 69-75
description 60
direct files 60
indexed files 61
NOMINAL KEY clause 82
recording mode 103-104
RECORDING MODE clause 104
RESER\-1E clause
7'''
sequential files 60
size of records 103,104
sequential data organization 59
sequential files (see standard sequential
files)
sequential multivolume files
effect of CLOSE options 222-224
reading 212
sequential processing 60,61
sequential single-volume files. effect of
CLOSE options 222-224
sequential VSAM files (see VSAM file
processing)
serial search of a table 302-304
series connective, definition 40
SET statement
description and formats 306
with index data items 299.,300
with indexes 296-299.290
setting 'values for index-names 306
shading in text, explained (see Preface)
sharing storage between files 85.,86
shilling representation
BSI and IBM conventions 324
internal 325,326
PICTURE clause 325,327
report items 327-329
short-precision internal floating-point
items (see internal floating-point items)
sign
class condition 156
internal representation 140,141
literals 42
MOVE statement 199
PICTURE clause 119,121
relation condition 159

SIGN clause 129,130
sign condition 162
sterling items 326-329
subscripts 289
unary operator 153,154
SIGN clause
ASCII considerations 357,361
class condition 156
description and format 129,130
Version 3 feature 13
sign condition 162
simple insertion editing 125
single digit level number 96
single spacing
printer page 214
source program listing 323
SIZE ERROR option in arithmetic statements
ADD 181,182
COMPUTE 182
description 180
DIVIDE 1,83
MULTIPLY 184
SUBTRACT 185
SKIP statements 323
slack bytes
description 132-136
elementary computational items 132,133
group items containing an OCCURS
clause 133-135
inter-occurrence 133-135
inter-record 135.136
intra-occurrence 133
intra-record 132-135
physical record size 101
small letters in ACCEPT (DOS/VS) xxxvi
sort
ascending and descending
sequence 243,244
ASCII considerations 360,361
checkpoints 240
collating sequence 244
control of procedures 247
Data Division considerations 241,242
Environment Division considerations
File-Control paragraph 238,239
I-O-Control paragraph 239-241
file description entry 241,242
final phase 246.247
input phase 245,246
keys 243,244
modification of records 245-241
optimizing performance 249
Procedure Division considerations
EXIT statement 248,249
RELEASE statement 241,248
RETURN statement 248
SORT statement 242-241
sample program 250,251
special registers 249
work units 239
sort enhancements (DOS/VS) xxxvi
sort-file
COPY statement 313-315
description entry 241.242
SELECT clause 239
sort special registers 249
SORT statement
description and format 242-247
Index

419

GIVING option 247
INPUT PROCEDURE option 245
OUTPUT PROCEDURE option 246,247
RELEASE statement 247,248
RETURN statement 248
USING option 246
SORT statement enhancement (DOS/VS) xxxvi
SORT-OPTION clause (DOS/VS) xxxvi
SORTWK1, SORTWK2 in sort 239
SOURCE clause
description and format 271
report groups 269
SOURCE-COMPUTER paragraph 64
source program
definition 57
reference format 50-52
structure 46,47
source program library facility
COPY statement 313-315
extended
BASIS 316
DELETE and INSERT 316,317
space
alphabetic items 120
BLANK WHEN ZERO clause 115
collating sequence 159,244
in editing 124-128
external floating-point items 122,123
replacement character 118,119~121
simple insertion editing 125
word separator 40
space insertion 125-128,115
SPACE (SPACES) figurative constant
definition 43
EXAMINE statement 201
MOVE statement 200
permissible comparisons 161
TRANSFORM statement 203-205
spacing program output 213-217
spacing source program listing 323,52
special characters
CURRENCY-SIGN clause 67
in formats 53
special insertion editing 125
special level numbers 96,97,108-110
special-names, definition 41
(see also mnemonic-name)
SPECIAL-NAMES paragraph
COPY statement 313-315
description and format 65-67
special register WHEN-COMPILED (DOS/VS) i
special registers
report writer
LINE-COUNTER 278
PAGE-COUNTER 277
PRINT-SWITCH 277
sort
SORT-CORE-SIZE 249
SORT-FILE-SIZE 249
SORT-MODE-SIZE 249
SORT-RETURN 249
system
COM-REG 44
CURRENT-DATE 44
NSTD-REELS 45,70
TALLY (see TALLY special register)
TIME-OF-DAY 44
stacked items in formats 53
420

standard data format
alphabetic items 120
alphanumeric items 120,124
description 102
logical records 102
numeric items 122,124
physical records 101
standard labels 105.170~171
STANDARD option of the LABEL RECORDS
clause 105
standard sequential file
APPLY WRITE-ONLY clause 87
ASSIGN clause 69-75
BLOCK CONTAINS clause 100,101
definition 59
effect of CLOSE options 222-224
error declarative capabilities 178
labels 105,106
reading 211,212
recording mode 103,104
RESERVE clause 77
writing 212-217
standard system procedures
error routines 175-178
label handling 170,171
START statement
description and format 208,209
error processing ~78
NOMINAL KEY 82,61 -'
START statement, VSAM (DOS/VS)
description and format xv
processing capabilities xiv
statement categories
compiler-directing, list 152
conditional~ list
151
description 150
imperative, list 151,152
statement number option., Version 3 13
status key., VSAM (DOS/VS)
CLOSE statement xxi
DELETE statement xxi
description v~~~,x
EXCEPTION/ERROR declarative xii
OPEN statement xiv
READ statement xvi
REWRITE statement xix
START statement xv
table of possible values x
WRITE statement xviii
sterling currency
international considerations 330
nonreport items
description andlformat 325,326
MOVE statement 200
relation condition 161
sign representation 326
Procedure Division considerations 330
report items
description and format 327-329
MOVE statement 200
relation condition 161
representations 324
STOP RUN statement 196,231,232
STOP statement
calling and called programs 231,232
format and description 196
storage available for sort 249

I
structure of
COBOL language 37-45
COBOL program 46,47
Data Division 94
Environment Division 63
Identification Division 57
Procedure Division 150
subdivisions of data records
data description entry 108,109
description 95,96
subject of a condition
explicit 158,164,165
implied 164,165
of a data description entry 111
of an OCCURS clause 293
subprogram, description 226
subprogram linkage statements
CALL 226,227
ENTRY 227,228
EXIT PROGRAM 232
GOBACK 232
STOP RUN 196
termination consierations 231
USING option 228-231
subroutine for OCR processing
(DOS/VS) xxv].].].
subscripts
condition-name 144
description and formats 289,290
qualification 290
qualifier 289 f 290
restrictions on use 291
substitution
asterisk for zero 128,120
comma for period 66,67,330
dollar sign 66,67,330
space for zero
BLANK WHEN ZERO clause 115
in editing 127,128
PICTURE symbol 119,121
subtotaling in a report 272,273
SUBTRACT statement
CORRESPONDING option 179
description and formats 185,186
GIVING option 179
overlapping operands 180
ROUNDED option 179,180
SIZE ERROR option 180
subtraction operator 153,154,39
SUM clause 272,273
SUM counter
definition 272
GENERATE statement 274
INITI~TE statement
275
report-name only
qualifier for 261
RESET clause 270,271
resetting to zero
GENERATE statement 274
INITIATE statement 275
RESET clause 270,271
SUM clause 272,273
summary reporting 273,274
summation in a report 270-275
suppress spacing 214,215
suppression of
library entry listing 314

report group printing 277
sequence checking 50
spacing in WRITE statement 214,215
zeros in PICTURE clause 118-121,127,128
suppression and replacement editing 128
suppression symbols 118-121
switch-status condition
description and format 162
function-names 162,66,67
symbol pairs
arithmetic expressions 154
compound conditions 164
PICTURE clause 121
subscripting and indexing 289-291
symbolic debugging, Version 3 13
symbolic portion of ACTUAL KEY 80
symbols
arithmetic expressions 153,154,39
floating-point literals 42
PICTURE clause 118-121
relation conditions 158,39
sterling currency formats 325
SYNCHRONIZED clause
description and format 130,131
index data items 300
OCCURS clause 133-135
slack bytes 132-136
SYSIPT 66,219,220
SYSLST 66,220,221
SYSPCH and SYSPUNCH 66,220,221
system closing conventions 222-225
system logical input device 66,219,220
system logical output device 66,220,221
system-name
ASSIGN clause 70-75
RERUN clause 84,85
sort feature 238-240
system-name, VSAM (DOS/VS) vi,xxxiv
system procedures (see standard system
procedures)
system special registers (see special
registers)
Systern/370 device support (DOS/VS) 11
System/370 support, Version 3 65,11-13
SYS001, SYS002 in Sort 239
SOl through S05 function-names
combined function processing 379
SPECIAL-NAMES paragraph 66
WRITE statement 214,216
Table Handling
ascending/descending sequence 295,296
Data Division considerations
OCCURS clause 292-299
USAGE clause 299;300
indexing 290,291,296-299
Procedure Division considerations
relation conditions 300,301
SEARCH statement 301-305
SET statement 306
sample program 307,308
subscripting 289-291
TALLY special register
ACCEPT statement 219
description 44
DISPLAY statement 221
EXAMINE statement 201,202
SOURCE clause 271
Index

421

~
J
!

1

l

iI

subscripting 289
SUM clasue 271,273
tape device, error information 176,178
tape file, label handling
CLOSE statement 222-224
LABEL RECORDS clause 105,106
OPEN statement 207,208
READ statement 212
USE statement 170,171
TERMINATE statement 275,276
termination of
execution 196
main programs 231,196
report processing 275,276
sort processing 248,249
subprograms 231,232
test conditions
class 156
compound 162-165
condition-name 157
description 155
relation 158-161
sign 162
switch-status 162
THEN
used in IF statement 166
used in sentences 38,149
THRU reserved word
and PERFORM statement 189,190
and THROUGH, equivalence of 40
and VALUE clause 142-144
TIME-OF-DAY special register 44
TRACE statement 318
track address
algorithm example 336
component of ACTUAL KEY 80,81
direct file 59-61
TRP~CK-AREA clause
83
trailer labels 170,171,105
transfer of control
ALTER statement 188
CALL statement 226,221
CALL statement for OCR (DOS/VS) XXVll1
calling and called programs 226-232
DECLARATIVES 169
end of series of procedures 196,191
EXIT statement
description and format 196,197
sort procedures 248,249
subprogram linkage 231,232
GO TO statement 187,188
GO TO MORE LABELS 171,112
GO BACK statement 231,232
merge feature (DOS/VS) xxVi,XXVll
operating system 231,232,196
operator 220,196
PERFO~l statement
189-195
RELEASE statement 247,248
RETURN statement 248
segments, among 310
sort feature 247-249
TRANSFORM statement
ASCII considerations 358-360
description and format 203-205
transmission errors 116
triple spacing
printer page 213-216
source progra.m listing 323
1.f22

,

truncation
alphabetic and alphanumeric
items 199,116
arithmetic operations 180
of buffers 87
floating insertion editing 127
MOVE statement 199,116
numeric items 180,199
TYPE clause 267-269

U-mode records
description 103,104
physical record size 100,101
specification 104
UHL (user header label) 105
unary + and - 153,154
undefined record format (see U-mode
records)
unique names
indexing 290,291
qualification 48,49
subscripting 289,290
unit, definition
in formats 54
in storage 222
unit record volume
CLOSE options 222-224
description 222
error information 118
list 10,12
unsigned numeric operands
considered positive 159,162
MOVE statement 199
relation condition 159
sign condition 162
updating a file
REWRITE statement 218.219
sample programs 33,34.339,340
WRITE statement 213,211,218
UPSI-O through 1 (User Program Status
Indicator bits) 67
USAGE clause
alteration by redefining 114
ASCII considerations 351,361
default 136
description and formats 136-141
index data items 299,300
internal representations 140~141
sterling items 325-329
use of coding form 50-52
USE statement
declarative description and format
error processing 115-118
label processing 170-175
report writer 216,211
user-created libraries 313-315
user error procedures 115-118
user header label CUHL) 105
user labels
description 105
GO TO MORE-LABELS 111,112
procedures for handling 110-112
standard systems procedure
CLOSE statement 222-225
label processing 110~111

169

READ statement 212
WRITE statement 217
user program status indicator bits 67
user trailer label (UTL)
105
USING option in calling and called programs
boundary alignment of identifiers 229
in a CALL statement 226-229
in a called program 227-229
in a calling program 226-229
in ENTRY statement 227-229
index-names invalid 229 6 226
on Procedure Division
header 228,229,150
U;:).Ll'l\.:i option in rnerge (DOS/VS)
XXVi
USING option in sort 246
USING option in sort (DOS/VS) xxxvi
utility device
class field in system-name 70
list 70,72
UTL (user trailer label)
105

V, in PICTURE clause
description 119,121
external floating-point items 123
fixed point numeric items 122
numeric edited item 124
with P 119
precedence 121
sterling nonreport items 325,326
V-mode records
APPLY WRITE-ONLY clause 87
description 103,104
inter-record slack bytes 135,136
intra-record slack bytes 132-135
in sort 241
specification 104
specification of physical record
size 100,101
VALUE clause
condition-names 142-144,109,110
description and formats 142-144,109,110
example 144
report writer data items 271,273
sterling items 326,329
VALUE OF clause 106
variable-length record format (see V-mode
records)
variable-length records
recording mode 103,104
size of print line in a report 255
in sort 241
variable length table 293-295,297,298
verb profiles and statistics (DOS/vS)
11
vertical positioning of a printed
line 213-217
volume positioning
CLOSE statement 222-224
OPEN statement 207
volume switch
CLOSE options 222-224
label processing 170
READ statement 212
WRITE statement 217
VSAM file processing (DOS/VS)
Data Division considerations ix
entry-sequenced data sets iv

FILE-CONTROL paragraph v-viii
I-O-CONTROL paragraph viii-ix
indexed files iv, v, xiv
key-sequenced data sets iv
overall description iv
Procedure Division
considerations ix-xxi
processing capabilities summary iv,xiv
sequential files iv, v, xiv
description iv,v,xiv
input to merge xxii
input to sort xxxvi
valid mass storage devices iv
WHEN-COMPILED special register (DOS/VS)
i
word
characters used in 37
continuation of 52
definition 39,40
separators 40
types
name 41
reserved word 40
special-name 41
word boundary 138,131,132
Working-Storage Section
boundary alignment 131
condition-name entries 142
content 108-110,98
COPY statement 313-315
data item description entry 108-110
formats 98,108,109
level-numbers in 98,108
naming data 111
record description entry 98,108,109
renaming entries in 144-146
structure 94
used in error processing 177
use of FILLER 111
values of items 142
Version 3 support 13
Working-Storage Section and OCR processing
(DOS/vS)
xxv].].].
WRITE-ONLY option of the APPLY clause 87
WRITE statement
combined function processing 382-384
description and formats 212-218
error processing 176,178
multivolume sequential files 217
system-name organization field 218
WRITE statement (DOS/VS)
VSAM files
description and format xvii-xix
processing capabilities xiv
3540 device xxxvi
WRITE-VERIFY option of the APPLY clause
description and format 88
3540 device (DOS/VS) xxxv
writing user labels 170-175,217

X, in PICTURE clause
alphanumeric edited items
alphanumeric items 120
description 119,121
precedence 121

124

Index

423

Z, in PICTURE clause
description 119,121
numeric edited items 128,124
precedence 121
sterling r~port items 327-329
zero suppression editing 128
ZERO (ZEROES, ZEROS) figurative constant
description 43
EXAMINE statement 201
MOVE statement 200
relation condition 161
replacing numeric literal 43
TRANSFORM statement 203-205
zero divisor 183,180
zero insertion 119,121,124,125
zero operand
DIVIDE statement 183
internal floating-point items 180
relation condition 159,161
sign condition 162
zero, simple insertion editing 125
zero suppression and replacement
editing 128
zone bits, external decimal items 137
zoned decimal format 137,140

0, in PICTURE clause
alphanumeric edited items 124
description 119,121
floating insertion editing 127
numeric edited items 124
precedence 121
simple insertion editing 125

424

01-49 level numbers 96,109
6, in sterling PICTURE clause 325
66 level number
definition 96
description 144-146
general description 108,109
7, in sterling PICTURE clause 325,326
77 level number 96,108,109
8, in sterling PICTURE clause 325,326,:
88 level number
definition 97
description 143,144
general description 109
9, in PICTURE clause
alphanumeric edited items 124
description 119,121
numeric edited items 124-128
numeric items 122,123
precedence 121
sterling items 325-329
2319, 3211, 3330, 3410, 3420, 3505, 3525
support, Version 3 13
2560, 3504, 3881 support, Version 3 12
3203, 3340, 3540, 5203 (DOS/VS)
processing support 11
programming considerations xxxiv-xxx
3886 OCR (DOS/vS)
processing support 11
programming considerations xxvii,xxv
5425 MFCU (DOS/VS)
processing support 11
programming considerations xxxiv, xxx'

OJ

s:
o
a
en

"

c

»

3(I)

..,

0'
Ol

::J

Z

Ol

.-+

0'
::J

!!.

en
.-+
Ol

::J

C.
Ol

a.
(')

aOJ
ar-

"

CD

z

o
en
w

0')

o

r()

~

"..,5'
.-+
(I)

C.

5'

c
en
~

G)
(')
I\J
(X)

enw

(0
~

en

llJ]5llir

®

International Business Machines Corporation
Data Processing Division
1133 Westchester Avenue, White Plains, New York 10604
(U.S.A. only)

IBM World Trade Corporation
821 United !'-Jations Plaza, !\Je\rA.t York, l'Je"A, York 10017
(I nternational)

IBM DOS Full American
National Standard COBOL
GC28-6394-6
Your comments about this publication wiil help us to improve it for you.
Comment in the space below, giving specific page and paragraph references
whenever possible. All comments become the .property of IBM.
Please do not use this form to ask technical questions about IBM systems and
programs or to request copies of publications. Rather, direct such questions or
requests to your local IBM representative.
If you would like a reply, please provide your name, job ritie, and business
address (including ZIP code).

Fold on two lines, staple, and mail. No postage necessary if mailed in the C.S.A. (Elsewhere,
any IBM representative will be happy to forward your comments.) Thank you for your
cooperation.

Reader's
Comment
Form

GC28-6394-6

Fold and Staple

First Class Permit
Number 6090
San Jose, California

Business Reply Mail
No postage necessary if mailed in the U.S.A.

(

§

c
e

-4

C'

C

c

Postage will be paid by:

I BM Corporation
P. O. Box 50020
Programming Publishing
San Jose, California 95150

Fold and Staple

International Business Machines Corporation
Data Processing Division
1133 Westchester Avenue, White Plains, New York 10604
(U.S.A. only)
IBM World Trade Co!'poration
821 United Nations Plaza, New York, New York 10017
! International)

C
r

This Newsletter No.

Date
Base Publication No.
File No.

Previous Newsletters

GN26-0887
December 3, 1976

GC28-6394-4, -5, -6
S360-24
GN26-0801 (-4,-5)
GN28-1047 (-4)
GN28-1062 (-4)

IBM DOS Full American National Standard COBOL
© IBM Corp. 1968, 1969. 1970,1971, 1972. 1973
This technical newsletter, a part of Version 2 of IBM DOS Full American National Standard COBOL
for Release 26 of DOS. of Release 3 of Version 3 of the IBM DOS Full American National Standard
COBOL Compiler and Library, and of Release 2 of the IBM DOS!VS COBOL Compiler and Library,
provides replacement pages of the subject publication. These replacement pages remain in effect for
subsequent releases unless specifically altered.
Pages to be added and! or replaced are listed below:
Cover. edition notice
Summary of Amendments (#10 added)
xxxvi.i

37,38
41,42
49,50
67,68
87-90
143, 144
211-214
217,218
223,224
239-242
273,274
293,294
317,318
Please place the Summary of Amendments page following the cover page.
Each technical change is marked by a vertical line to the left of the change.
Note: Please me this cover letter at the back of the publication to provide a record of change.

IBM Corporation, P.O. Box 50020, Programming Publishing, San Jose, California 95150
Printed in U.S.A.



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37
Create Date                     : 2012:05:24 13:41:54-08:00
Modify Date                     : 2012:05:24 15:23:41-07:00
Metadata Date                   : 2012:05:24 15:23:41-07:00
Producer                        : Adobe Acrobat 9.51 Paper Capture Plug-in
Format                          : application/pdf
Document ID                     : uuid:e2c0be50-b76f-47ce-a78a-9b4bc2f95fb3
Instance ID                     : uuid:815ba587-c0dd-4cfc-b789-a8de12055bce
Page Layout                     : SinglePage
Page Mode                       : UseNone
Page Count                      : 488
EXIF Metadata provided by EXIF.tools

Navigation menu