Baixe FDR3059-101A - COBOL Jan80 e outras Manuais, Projetos, Pesquisas em PDF para Informática, somente na Docsity! Prime Computer, Inc.
Reference Guide FDR3056-101A
COBOL
The COBOL Reference Guide
1
2
CONTENTS
PARTI — OVERVIEW
OVERVIEW OF PRIME'S COBOL
This Document 1-1
Related Document 1-2
Language Spesifications 1-2
Prime Extensions to the Level 2 Standard 1-4
COBOL Under PRIMOS 1-4
Program Environments 1-5
System Resources Supporting COBOL 1-6
PART II — LANGUAGE-SPECIFIC SYSTEM INFORMATION
COMPILING THE PROGRAM
Introduction 2-1
Using the Compiler 2-1
Compiler Functions 2-4
Compiler Generated Files 2-7
LOADING AND EXECUTING PROGRAMS
Loading Programs 3-1
Executing Loaded Programs 3-2
PART HI — COBOL LANGUAGE REFERENCE
FUNDAMENTAL CONCEPTS OF COBOL
Divisions of a COBOL Program: A Summary 4-1
Language Considerations 4-4
Language Specifications 4-7
Arithmetic Expressions 4-18
Conditional Expressions 4-20
IDENTIFICATION DIVISION
Identification Division 5-1
ENVIRONMENT DIVISION
Environment Division 6-1
7 DATA DIVISION
Data Division 7-1
File Section 7-2
File Description 7-2
Uncompressed 7-3
Label Records 7-4
Block Contains 7-4
Record Contains 7-5
Value of File-ID 7-6
Owner Is 7-6
Data Records 7-6
Code-Set 7-7
Record Description 7-7
Level-Number 7-10
Data-Name:Filler 7-12
Redefines 7-12
Renames 7-13
Occurs 7-14
Picture 7-15
Usage 7-22
Sign 7-23
Synchronized 7-24
Justified 7-25
Blank When Zero 7-25
Value 7-27
Working-Storage Section 7-28
Linkage Section 7-30
8 — pRocEDURE DIVISION
Procedure Division 8-1
Procedure Slalements 8-4
ACCEPT 8-4
ADD 8-6
ALTER 8-7
CALL B-8
CLOSE B-8
COMPUTE 8-9
Copy a-9
DELETE 8-11
DISPLAY 8-12
DIVIDE 8-12
ENTER 8-14
EXHIBIT 8-14
EXIT 8-15
EXTE PROCRAM 8-15
GOTO 8-15
IF 816
INSPECT 8-19
MOVE q-22
MULTIPLY 8-23
OPEN 8-23
PERFORM 8-24
READ 8-32
ACKNOWLEDGMENT
“The following acknowledgment is a reprint from the American National Standard Program-
ming Language COBOL, ANSI X3.23-1974:
“Any otganization interested in reproducing the COBOL standard and specificalions in wbole
or in part, using ideas from this document as the basis for an inslruction manual or for any
other purpose, is free to do so. However, all such organizations are requested to reproduce the
following acknowledgment paragraphs in their entirety as part of the preface to any such
publication (any organization using a short passage from this document, such as in a book
review, is requested to mention'COBOL in acknowledgment of the source, but need not quote
the acknowledgment):
COBOL is an industry language andis not the property of any company or group of companies,
or of any organization or group of organizations.
No warranty. expressed or implied, is made by any contributor or by the CODASYL Program-
ming Language 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 therewilh.
“The authors and copyright holders of the copyrighted material used herein
FLOW-MATIC (trademark of Sperry Rand Corporation), Programming for the
UNIVACS [ and II, Data Automation Systems copyrighted 1958, 1959, by
Sperry Rand Corporation; IBM Commercial Translator Form No. F 28-8013,
copyrighted 1959 by IBM; FACT, DSI 2745260-2760, copyrighted by
Minneapolis-Honey well
have specifically authorized the use of this material in whole or in part, in the COBOL specifi-
cations. Such authorization exlends to the reproduction and use of COBOL specifications in
programming manuals or similar publications.”
Overview of
Primes COBOL
THIS DOCUMENT
Purpose and audience
The COROL Reference Guide is a Final Documentation Release at software revision level 17
(Rev. 17). This document and a companion document. The Prime User's Guide, replace the
COBOL Programmer's Guide PDR3056 Rev. B.
This document fully describes Prime COBOL, and provides the necessary information for
compiling, loading, executing and debugging COBOL programs on a Prime system. Itis
designed to be used as a reference guide for an experienced COBOL programmer. Users
unfamiliar with the language should read one of the many commercially available instruc-
tion books; examples are:
Feingold, Carl, Fundamentals of Siructured COBOL programming. WM. C. Brown
Company Publishers
Stern, N. and Stern, R.. COBOL, Programming, John Wiley and Son, Inc
Organization and usage
“his document has three major parts:
Part one Overview. Introduces Prime's COBOL, including Prime extensions
to the language, supporting utilities, systems and software (Section
1).
Part two Language-Specific System Information. Provides complete in-
formation on lhe use of the COBOL compiler (Section 2), and
describes the process of loading and executing COBOL programs
(Section 3)
Part three Language Reference. Provides syntactical and general COBOL
specifications. patterned after the ANSI standard. The three main
sub-divisions are:
Fundamental Concepts of COBOL (Section 4)
Nucleus (Sections 5-8)
Functional Processing Modules [Sectians 9-13)
Fundamental Concepts of COBOL defines the Nucleus and Func-
tional Processing Modules. The Nucleus presents the structure and
governing rules of COBOL's four divisions: Identification. En-
vironment, Data and Procedure. The Functional Processing Mod-
ules include Inter-program Communication, able Handling, Sort,
Indexed 1/0, Relative 1/Q, Sequential [/O, and Library.
Effective usage of the Language Reference sections requires
knowledge of its organization:
* Fundamental Concepts begins with a generalized COBOL
program summary. This is expanded in the sample listing
file, SAMPLE. Fundamental COBOL concepts, including
4 January 1980 1-1 FDR 3056
1 OVERVIEW OF PRIME'S COBOL
standard format notation, punctuation rules, etc. are here
set forth.
* The Nucleus expands upon the previous presentation of
Fundamental Concepts. Tt provides detailed information
related to the Identification, Environment, Data, and Pro-
cedure Divisions.
PROCEDURE DIVISION [Section 8) presents COBOL
verbs alphabetically. A quick verb index is in Appendix C
Each division section closes with an example of source
cading for that given division. These examples form a
functional program, REr2, which illustrates the interrela-
tionship of component parts
* Functional Processing Modules are self-contained. often
restating concepts, data deseriptions, and COBOL
statement formats elsewhere described. The reader wili
find here all related data in a single location for maximum
utility and efficiency. For example, the READ verb is
presented in the Procedure Division. It is restated in the
Indexed [1/0 Functional Processing Module, together with
related data pertinent to Indexed 1/0) processing
In addition lo the body of text, the Table of Contents is a guide ta content and order; the
index provides the most direct access to specifios. Appendices present a capsule form of
repeatedly used data as follows:
* The file organization
* Two sets of typical CREATK dialog for INDEXED and SAM files, along
with examples
Important reference tables: COBOL Verb Index, COBOL Reserved Words.
ASCII Character Set, File Status Key Definitions, Permissible 1/0
Statements, Permissible Moves, and Numeric Conversion Tables
A list of COBOL punctuation, arithmetic and edit symbols
* A list of compile-time and run-time error messages and their meanings
* An introduction to expanded listing for COBOL programs
* The LABEI, command for magnetic tapes
* A list of system files required by COBOL
RELATED DOCUMENT
The Prime User's Guide describes all supporting PRIMOS utilities for programming in
Prime COBOL or any other Prime language. The COBOL Reference Guide and The Prime
User's Guide are complementary documents: both are essential to the COBOL programmer.
LANGUAGE SPECIFICATIONS
Prime COBOL is based upon American National Standard Programming Language COBOL.
X3.23-1974. Elements of the COBOL language are allocated to the following 12 different
functional processing 'modules”: Nucleus. Table Iandling, Sequential [/O, Relative I/O,
Indexed I/O, Sort-Merge, Report Writer, Segmentation, Library, Debug. Inter-Program
Communication, and Communication.
Each module of the COBOL Standard has two non-null “levels”: level 2 contains the full set
of capabilities and features; level 1 contains a subset of level 2
In order for a given system to be called COBOL, it must provide at least level 1 of the
* Nucleus, Table Handling and Sequential 1/0 modules.
FDR 205 1-2 1 January 1980
OVERVIEW OF PRIME'S COBOL
management; it supports up to 63 simultaneous users. The system is based on demand paging
from disk with 2048 bytes per page. A page-sharing feature reduces overhead time. For
example, several COBOL users may share one copy of the Editor to enter, modify, or debug
their programs, rather than individually having their own copy.
Prime's segmentation scheme uses a virtual address consisting of a segment number (one of
4096), a page number. and a word number. The virtual address is translated into a physical
address by a series of segment tables and page maps. Paging requirements for the
application program are thus met immediately and automatically.
COBOL under PRIMOS has advanced segmentation capability, expanded compilation
options, sharable code, and DBMS capahility
Compastibility
Because a common operating system architecture is used throughout the Prime processor
line, COBOL programs created on one Prime computer can be used on any larger or smaller
Prime computer without modification. Compatibility holds true at both the source level and
the memory image level.
PROGRAM ENVIRONMENTS
Under PRIMOS, COBOL. programs may execute in one of three environments:
* Interactive
* Phantom user
* Batch job processing
Interactive
Program execution is initiated directly by the user. Programs run in real time and are
“connected” to the terminal. Program output is printed at the terminal, as well as user- or
system-generated error messages. 'lhis environment is the one most often used. Major uses
are:
* Program development
* Programs requiring short execution time
* Dala entry programs such as order entry, payroll, etc.
* interactive programs such as the Editor, etc.
Phantom user
“The phantom environment allows programs to be executed while “disconnected” from a
terminal, This frees the terminal for other uses. Phantom users accept input from a
command file instead of a terminal: output directed to a terminal is either ignored or
directed to a file.
Major uses of phantoms are:
* Programs requiring long executian time (such as sorts)
* Certain system utilities (such as line printer spooler)
« Freeing terminals far interactive uses
Batch job processing
Since the number of phantom users on a system is limited. phantoms are nôt always
available. The Batch environment allows users to submit non-interactive command files as
Batch jobs at any time. The Batch monitor (itself a phantom) quenes these jobs and runs
them, one to six at a time, as phantoms become free.
1 January 1980 1-5 FDR 3056
1 OVERVIEW OF PRIME'S COBOL
SYSTEM RESOURCES SUPPORTING COBOL
Prime COBOL shares equally with all Prime programming languages a broad range of
system and file management resources.
Such resources as system libraries, the text editor, or the SEG utility expand the scope and
efficiency of Prime's interactive environment.
Compatible file management systems enhance the mixing capabilities of the system while
providing standardized file management functions. Files are created and maintained
separately from the applications program,
Libraries
The COBOL programmer may find system library functions and subroutines of use in some
applications. A list of VCOBLR library subroutines and functions is presented in Appendix
H. A complete Ireatment of all library and system subroutines is in The Subroutinc
Reference Guide.
Compiler
Prime's COBOL compiler operates on COBOL source code to generate object code. It is also
possible to generate a program listing only. Since syntax checking can be achieved in a
shorter period of time, this feature can produce a quick and uscful reference to the source
program. The user has the additional compiler options to control 1/O specifications. The
compiler is described in detail in Section 2.
SEG utility
SEG is the V-identity program loading and execution utility. It combines separalely
compiled program modules, subroutines, and libraries into an executable program. Program
modules can be up ta 64K words long. All memory management. symbol tables, linkages, etc.
are handled by SEG's loader. Various types of loadmaps may be obtained. The SEG utility
has many functions; they are described as follows:
Normal usage (Section 3)
Advanced usage (LOAD and SEG Reference Guide]
Editor
Prime's text editor is a line-oriented editor enabling lhe programmer to enter and modify
source code and text files. Information for these purposes is in The Prime User's Guide; à
complete description of the Editor is in The New User's Cuide to EDITOR and.RUNOFF.
Database Management System (DBMS)
Prime's DBMS is a CODASYL-compliant system for management of large amounts of data
DBMS can be accessed from either COBOL or FORTRAN programs. tis compatible with
MIDAS and FORMS.
As a system resource available ta COBOL, Prime's DBMS provides generalized database
management capabilities for describing, creating, manipulating, and maintaining structured
Uatahases in a diverse range of applications.
Itis particularly uscful for:
* Interactive business data processing applications with complex rela-
tionships among data.
* On-line transaction processing
* Standardization of data meaning and usage
* A high degree of protected, concurrent usage
FIDR 3056 1-6 1 January 1980
OVERVIEW OF PRIME'S COBOL 1 =
* Minimized data redundancy
* Integrity, backup and automatic recovery
Complete information on using DBMS in the COBOL environment is in DBMS Adminis-
trator's Guide, DBMS SCHEMA Reference Guide, and DBMS COBOL Reference Guide.
Multiple Index Data Access System (MIDAS)
MIDAS is à management software system of utilities and subroutines for creating and
maintaining keyed-index/direct-access files.
MIDAS provides the COBOL programmer with a transparent multi-level file structure. All
housekeeping functions on the index and data sub-files are performed by MIDAS sub-
routines called from COBOL programs.
Prime programming files created by programs written in one language may be accessed and
manipulated by programs written in other languages, insuring compatability
MIDAS Access Manager is reentrant. All active programs on Prime models 350 and above
share a single copy of the manager, minimizing redundancy.
* Therc can be up to 5 alternate record keys for a COBOI, MIDAS file
* Duplicate keys let MIDAS retrieve multiple records for a single key value
+ LOCK prevents concurrent usage conflicts
* KEYS can be constructed from concatenated information
* A single program can make segmented and random accesses to a single file
Basic MIDAS template construction information is presented in Appendix B. The complete
documentation is The MIDAS Reference Guide.
Forms Management Systems (FORMS)
FORMS is a system for creation, maintenance, and use of screen forms for interactive file
maintenance. These screen forms are an extremely useful tool for the applications
programmer writing data entry programs, where data fields are to be displayed in one or
more formats.
FORMS keeps application programs. the forms and devices they use separated until run
time. Thus, changes can be effected in one area without necessarily affecting the other two.
FORMS is compatible with DBMS and MIDAS; it is available to up to 63 concurrent users.
Itfacilitates making accurate data available at widely dispersed locations for inquiry and/or
update by transactions which can represent all elements of a business.
Details are in The FORMS Programmer's Guide.
Language interfaces
Since all Prime high-level languages are alike at the object-code level, and since all use the
same calling conventions, object modules produced by the COBOL compiler can call and be
called by modules produced by the F77, FTN, or PLIG compilers. provided that certain
restrictions are observed:
* AIL T/O routines must be written in the same language.
* There must be no conflict of data types for variables being passed as
arguments.
* Modules in 64V or 321 may call each other if they are otherwise com-
patible.
COBOL programs can also call PMA (Prime Macro Assembler) routines, and vice versa. For
information, see Section 9 of this manual and The Assembly Language Programmer's Guide.
1 January 1980 1-7 FDR 3056
Compiling the program
INTRODUCTION
There is one COBOL compiler for all Prime computers and PRIMOS levels.
Source programs must meet the requirements of Prime's COBOL as specified in this manual.
The COBOL compiler generates object code in the segmented-addressing (84V] mode
suitable for processing by Prime's segmented-addressing loader (SEG) utility on Prime
models 350 and up.
USING THE COMPILER
The COBOL compiler is invoked by the COBOL command to PRIMOS:
COBOL pathname [-parameter-1 -parameter-2 ... -parameter-n]
where pathname is the pathname of the COBOL source program file
parameter-1 etc. are the mnemonics for the options controlling com-
piler functions such as I/O device specification,
listings, and others.
For example:
COBCL MYPROG —L PRELST
The mnemoanics are explained in COMPILER FUNCTIONS in this section. All mnemonic
parameters must be preceded by a hyphen (-). The name of the source program file must be
specified as the above expression following the command COBOL.
Compilation messages
The Prime COBOL compiler flags milestones during compilation: Phases [ through VI. Phase
markers are output to the user's terminal in the following manner:
OK, COBOL pathname
Phase I Environment Division
Phase II Data Division
Phase III Procedure Division
Phase IV Intermediate code generation
Phase V File Control Block generation
Phase VI Final code generation
No Errors, No Warnings, Prlme V-Mode COBOL, Rev 17.1 <program>
1f errors occur during compilation, an appropriate message will be output to the console, the
listing file, or both. For example:
On the terminal:
OK, COBOL SAMPLE. SORT
Phase I
Phase II
Phase III
Phase IV
1 January 1960 2-1 FDR 3056
2 COMPILING THE PROGRAM
Phase V
Phase VI
1 Error, No Warnings, Prime V-Mode COBOL, Rev 17.1 <SORTIT>
In the listing file:
0009 AREA-A VIOLATION; RESUMES AT NEXT PARAGRAPH/SECTION/DIVISION/VERB,
1 Error, No Warnings, Prime V-Mode COBOL, Rev 17,1 <SORTIT>
Note
Jf there are compiler errors, the object file is unusable.
End of compilation messages: After the compiler has completed a pass at the specified input
file, generated code and listing output as specified by the mnemonic parameters, it prints a
message at the user's terminal [see examples above). The message format is:
where
xxxx Errors, yyyy Warnings, Prime V-Mode COBOL, Rev 17.1 <program>
XXXX is the number of errors encountered during com-
pilation.
vyyy is the number of warnings.
program is the name of the program (ID) compiled.
An error is a mistake in a statement which makes execution of the program impossible.
A warning occurs when a statement is encountered which, although legal, may cause
unexpected and/or undesirable results.
Note that the compiler does not support a SYSTEM READ/WRITE LOCK OF 5. Consequent-
ly, this will cause miscellaneous compiler aborts.
After compilation, control returns to PRIMOS.
Compiler error messages: The general format of the error message is:
n message.[]
where
n Is the line reference number.
message Is the standard COBOL compiler error message. A
complete list is given in the Error Reference Sec-
tion, Appendix E.
[1 Is a variable describing the problem.
For example:
g082 UNRESOLVED PROCEDURE-NAME; STATEMENT DELETED, [SORT-DATA ]
?Unsuccessful Compilation; Terminal Error Q Line 82.
FDR 9056 2-2 1 January 1980
COMPILING THE PROGRAM 2
(See Table 2-4.) This parameter must not be used if
the source filename immediately follows the
COBOL command; otherwise, it must be included
in the parameter list.
To override default, specifies binary (object) out-
The binary file will be created with the pathname
specified (example: -B OUTPUT > TEST, where
the binary file is created on the UFD OUTPUT
under the filename TEST).
No binary file will be created; only a syntax check
The binary file is created with the default name B
filename, where filename is the name of the
source program file in the UFD in which the source
program file resides. The binary file, however, is
created in the UFD to which the user is attached
when invoking the compiler.
Tf the BINARY parameter is not included in lhe
command line, it is equivalent to -B YES. (See
To override default, specifies listing file/device.
The listing file will be created with the pathname
specified (example: -L ELM > LTEST).
No listing file will be created. At later stages in
program development or when minor mod-
ifications are made to programs. it may not be
considered necessary to get a source program lisl-
The listing file is created with the default name L—
filename. where filename is the name of the source
program file in the UFD in which the source
program file resides. The listing file, however, is
created in the UFD to which the user is attached
when invoking the compiler.
The listing file is printed on the user's terminal.
The listing file is spooled directly to the line
If the LISTING parameter is not included in the
command line, it is equivalent to -I. YES.
-BINARY
put file/device.
-B pathname
-BNO
will occur.
- -BYES
Table 2-1.)
“LISTING
-L pathname
-LNO
ing.
* -LYES
-LTTY
-L SPOOL
printer.
-SOURCE
Addressing mode
. -s4V
Same as -INPUT. See INPUT.
Generates segmented-addressed code which must
be loaded with the SEG loader. It provides a user
area up to 32 megabytes (256 segments of 128K
bytes each). It may be run on any Prime mode! 350
or above under PRIMOS
Enable expanded listings/cross references
-Expanded listing: The expanded listing is a combination of a regular listing (source code
with line number appended) and machine-generated code.
1 Jonuary 1980 2-5
FDR 3056
2 COMPILING THE PROGRAM
Table 2-1, Compiler File Specifications
COMPILER
MNEMONICS INPUT LISTING BINARY
pathname Looks for file Opéns file named Opensfile named
named pathname pathname:as pathname as
as source file listing file binary- (object)
file.
YES Uses default file- Uses default-file-
name for listing namefor binary:
file L-PROGRM. file B-PROGRM.
NO No listing file. No binary.file”
TTY Peint listing on
user terminal,
SPOOL Spool listing
directly to line
printer: e
Option Souree filename Same-as YES “ Same-as YES
not must-be first E :
invoked option after
COBOL command.
* -NOEXPLIST Suppresses generation of the expanded listing.
This is the normal default.
-“EXPLIST Generates an expanded listing at the end of the
listing file. User defined names are NOT used,
machine-generated labels are placed in the listing.
An expanded listing example for SAMPLE appears in Appendix F. To fully utilize the listing.
a knowledge of PMA is necessary. The reader: is referred to The Assembly Language
Programmer's Guide.
Cross-reference listing: The Cross Reference has two compile-time options, -NOXREF or
-XREF,
* -NOXREF Suppresses generation of any cross-reference list-
ing. This is the normal default,
-XREF Generates a cross-reference listing at the end of the
listing file. A line number with a suffix 'D' in-
dicates a paragraph or section name in the Pro-
cedure Division.
For example:
OK, COBOL SAMPLE.SORT -XREF -L TTY
(8973) PROCEDURE DIVISION.
(9974) START-PARA.
(8115) GET-TOTALS SECTION.
(9116) GET-TOTAL.
FDR 3056 2-6 1 Jonvary 1980
COMPILING THE PROGRAM 2 E
(9117) DISPLAY "ENTER MONTH XX ($1-12) OR ENTER 99 TO QUIT'.
(0118) ACCEPT MONTH-ACCEPT.
(8119) IF MONTH-ACCEPT = 99
(8128) Go TO DONE-PARA.
(9121) IF NOT VALIDMONTA
(0122) GO TO GET-TOTAL.
(0148) DONE-PARA.
(9149) STOP RUN.
ADD-TOTALS 8129 91390
DONE-PARA 9120 Ul4BD
GET-TOTAL G116D 6122 135
GET-TOTALS 2093 G115D
START-PARA 9074D
SUM-DEPT ggal 9130 9132 140
TABLE-AREA 8962
TABLE-VALUE gas 2057
VALIDMONTH 0043 121
PROGRAM STATISTICS
An actual listing for SAMPLE.SORT is shown in Section t1
COMPILER GENERATED FILES
File types
Three fypes of files may be involved during compilation. They are: source file. listing file,
object file. Of these, the listing and object files are compiler-generated, Corresponding
PRIMOS file units are given below.
File Type PRIMOS file unit
Source 1
Listing 2
Object 3
1 january 1980 27 FDR 3056
Loading and
executing programs
LOADING AND EXECUTING PROGRAMS
The PRIMOS SEG utility loads and executes all COBOL programs. This section describes
normal loading and execution, and specifies some techniques required for COBOL pro-
grams. The loading concept is described in more detail in the Prime User's Guide. For
extended loading features, as well as a complete description of all SEG commands,
including those for advanced system-level programming, refer to the LOAD and SEC
Reference Guide.
LOADING PROGRAMS
Normal Loading
Mast loads can be accomplished by the following basic procedure:
2. Invoke the SEG loader with the SEG command. (A '% sign will be the
prompt symbol.)
2. Enter the SEG-level LOAD command to start the load subprocessor and
to set up the runfile (LO ffilename). (A '$ sign will appear as the next
prompt symbol.)
3. Use the load subprocessor's LOAD command to load the object files in
the following order:
* The object file of the main program (LO B-filename)
* The object files of any separately compiled subroutines
(preferably in order to frequency of use)
4, Use the load subprocessor's LIBRARY command to load subroutines
called from libraries in the following order:
* Shared COBOL library [LI VCOBLB)
* Non-shared COBOL library, if user written subroutines are
loaded (LI NVCOBLB)
* Other Prime libraries, if required (LI filename)
* Standard FORTRAN library (LI)
Atthis point, you should receive a LOAD COMPLETE message. If the message is absent, do
a MAP 3 to identify lhe unsatisfied references and load them. In the unlikely event some
other SEG error message appears, refer to the LOAD and SEG Reference Guide for the
probable cause and correction.
5. SAVE the runfile.
&. The QUI! command exits from the utility.
As an example of loading. assume that the user has compiled a main program, MAIN, and
a subroutine in a separate source file, SUBR. Both have been compiled using the default
object filenames. They could be loaded as follows:
1 January 1980 FDR 3056
e
É
OK, SEG brings SEG into memory
[SEG rev 17.1]
É LO MAIN invokes the loader and establish a runfile
$ LO B MAIN loads the main program
$ LO B SUBR loads any separately compiled subroutine
$ LI VCOBLB loads the shared COBOL library
3 LI NVCOBLB loads the non-shared COBOL library
$ LI loads the FORTRAN library
LOAD COMPLETE Loader indicates all references are satisfied
5 SA user saves runfile
sQ returns to PRIMOS level
OK,
EXECUTING LOADED PROGRAMS
Execution of Runfiles
For programs loaded and saved by SEG, execution is performed at the PRIMOS leve] using
the SEG command:
SEG sfilename
where gfilename is lhe filename (or pathname) of a SEG runfile. SEG loads the runfile into
segmented memory and hegins execution of the program after a dialog with C$IN [see
below)
A shortcut to saving and executing a loaded program is available. Immediaely after
receiving the LOAD COMPLETE message, enter the load subprocessor's EXECUTE com-
mand. This command will then save the loaded program and start executing the program
after a dialog with the C$IN utility program (see below). EXECUTE will also work if a SAVE
has been given explicitly.
Upon completion of program execution, control returns to PRIMOS command level
C$IN utility program
Immediately following the execute command of SEG or EXECUTE, a series of questions will
be asked concerning run-time file assignments. These questians are prompted by the utility
program CSIN,
The utility programs will ask on the terminal:
ENTER FILE ASSIGNMENTS:
>
The proper response to the request above is to give the name of the file (as stated in the
VALUE OF FILE-D clause of the File Description), followed by the pathname of the actual
file to be associated with the ID. The pathname can he a filename if the file resides in the
current UFD. For example, suppose that in a COBOL program the following statements
existed:
FDR 3056 3-2 4 Jonuery 1980
HO
COBOL
LANGUAGE
REFERENCE
4 FUNDAMENTAL CONCEPTS OF COBOL
Procedure Division
The Procedure Division contains instructions (COBOL statements) required to solve a data
processing problem.
This division contains two types of sections: declarative sections and procedural sections.
Declarative sections: are optional. When used, they must be grouped at the beginning of the
Procedure Division. Declarative sections permit the execution of instructions which are not
performed in the regular sequence of coding. Such out-of-sequence procedures are usually
initiated by a condition which the program does not test directly
Procedural sections: foliow declaratives in a logical sequence. Each procedural section
comprises one or more paragraphs. Each paragraph consists of one or more COBOL
sentences. Sentences, in turn, are comprised of one or more COBOL statements.
Execution of the instructions in the Procedure Division begins with the first statementin the
division, excluding declaratives. Statements are executed in the order in which they are
presented for compilation, unless the rules indicate otherwise
The Procedure Division ends at that point in the source program after which no furlher
procedures appear. This coincides with the physical end in the program.
“The following skeletal coding defines the program format and order:
AD DIVISION.
PROGRAM-ID. program-name.
[AUTHOR. [comment-entry] ... ]
FINSTALLATION. [comment-entry] ... ]
[DATE-WRITTEN. [comment-entry] ... ]
[DATE-COMPILED. [comment-entry]... ]
(SECURITY. [comment-entry] ... ]
[REMARKS. [comment-entry] ...]
ENVIRONMENT DIVISION.
[CONFIGURATION SECTION.
[SOURCE COMPUTER. entry.]
TOBJECT COMPUTER. entry.)
ISPECIAL-NAMES. entry.1]
HINPUT-OUTPUT SECTION.
* FILE CONTROL. (entry)...
IEO-GCÔNTROL. entry]
DATA DIVISION.
[FILE SECTION.
Hle-description-entry.
[record-description-entry].... ] ..
fsort-file-description-entry.
(record-description-entey):..: 1... ]
[WORKING-STORAGE SECTION.
[77-lovel-description-entry)....
Irecord-description-entry] ... ]
- ILINKAGE SECTION.
[77Nevel-description-entry]....
: [recórd-description-entry] ....]
PROCEDURE DIVISION [USING tdentifier-t.... 1,
IDECLARATIVES.
- (sectlon-name SECTION. use-sentence.
Tharagraph-name. [sentence).... ]... ) ...
END DECLARATIVES.
fsectlon-name SECTION.
fparagraph-name. [sentence]... ] ... )'...
FDR 3055 4-2 1 January 1980
FUNDAMENTAL CONCEPTS OF COBOL 4
The following listing file for sample program SAMPLE, illustrates the program format and
order. SAMPLE creates and reads a relative file sequentially.
Rev 17.2 CCBOL
(g9a1)
(0082)
(9003)
(0004)
(a095)
(8006)
(ga07)
(9008)
(B009)
(g919)
(ga1L)
(9012)
(0013)
(9914)
(0915)
(9016)
(9017)
(9018)
(8019)
(0929)
(0621)
(9922)
(8923)
(0824)
(2025)
(9825)
(9027)
(0928)
(9029)
(9839)
(9031)
(8832)
(9033)
(0934)
(2035)
(8036)
(8037)
(9938)
(0039)
(3048)
(9941)
(9942)
(9943)
(0944)
(9945)
(9046)
(9047)
(ge48)
(6949)
(9059)
1 Jorvary 1980
Source File: SAMPLE 11/85/79 13:55
ID DIVISION.
PROGRAM-ID. SAMPLE,
INSTALLATION. PRIME COMPUTER TECHNICAL PUBLICATIONS DIVISION.
DATE-WRITTEN. OT 26, 1979.
SECURITY. NONE.
REMARKS. THIS PROGRAM CREATES AND READS A RELATIVE FILE
SEQUENTIALLY.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. PRIME-750.
CBJECT-COMPUTER. PRIME-750.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT PRINT-FILE ASSIGN TO PRINTER.
SELECT CARD-FILE ASSIGN TO PEMS.
SELECT DIRECTCRY-FILE ASSIGN TO PEMS,
ORGANIZATION IS RELATIVE,
RELATIVE KEY IS RELATIVEKEY,
ACCESS MODE IS SEQUENTIAL,
FILE STATUS IS FILE-STATUS.
DATA DIVISION.
FILE SECTION.
FD PRINT-FILE, LABEL RECORDS ARE CMITTED,
DATA RECORD IS PRINT-LINE,
RECORD CONTAINS 132 CHARACTERS.
91 PRINT-LINE PIC X(132).
FD CARD-FILE, LABEL RECORDS ARE STANDARD,
VALUE OF FILE-ID IS 'INDATA".
91 CARD-IMAGE PIC X(88).
FD DIRECTORY-FILE, LABEL RECORDS ARE STANDARD,
VALUE OF FILE-ID IS 'D-FILE'.
91 DIRECTORY-RECORD.
85 CARRIAGE-CONTROL PIC X.
gs NAME.
18 LAST-NAME PIC X(15).
10 FIRSTNAME PIC X(15).
95 FILLER PIC X(U.
95 ADDRESS PIC X(25).
95 FILLER PIC X().
95 CcIPY PIC X(4).
95 FILLER PIC X().
95 PHONENO PIC 9(7).
95 FILLER PIC x(8).
WORKING-STORAGE SECTION.
91 RELATIVE-KEY PIC XX.
77 FILE-STATUS PIC XX VALUE SPACES.
61 HEADER.
os H1 PIC X(5), VALUE IS ! NAME!.
95 FILLER PIC X(27), VALUE IS SPACE.
65 H2 PIC X(6), VALUE IS "STREET".
4-3 PDR 3056
4 FUNDAMENTAL CONCEPTS OF COBOL
(2051) 95 FILLER PIC X(19), VALUE IS SPACE.
(9052) 05 H3 PIC X(4), VALUE IS 'CITY'.
(2053) 95 FILLER PIC X(4), VALUE IS SPACE,
(0054) 95 H4 PIC X(5), VALUE IS 'PHONE!.
(9055) PROCEDURE DIVISION.
(0056) BEGIN SECTION.
(9857) CREATE-FILE.
(9258) OPEN INPUT CARD-FILE.
(8059) OPEN OUTPUT PRINT-PILE, DIRECTORY-FILE,
(8860) WRITE PRINT-LINE FRCM HEADER AFTER ADVANCING PAGE.
(0861) READ-NEXT.
(8062) READ CARD-FILE AT END GO TO LIST-DIRECTORY.
(2063) MOVE CARD-IMAGE TO PRINT-LINE.
(8064) MOVE CARD-IMAGE TO DIRECTORY-RECORD.
(2265) WRITE PRINT-LINE.
(B066) WRITE DIRECTORY-RECCRD INVALID KEY DISPLAY "INVALID KEY'.
(2867) GO TO READ-NEXT.
(0068) LIST-DIRECTORY.
(0069) CLOSE CARD-FILE, DIRECTORY -FILE.
(9970) DISPLAY “END TEST TO CREATE PILE'.
(8071) OPEN INPUT DIRECTORY-FILE.
(0972) LAST-SECTION SECTION.
(0973) LIST.
(0074) WRITE PRINT-LINE FROM HEADER AFTER ADVANCING PAGE.
(0875) READ-NEXT-DIRECTORY-RECORD.
(9076) READ DIRECTORY-FILE NEXT RECORD AT END GO TO CLOSE-ALL.
(8877) MOVE DIRECTORY-RECORD TO PRINT-LINE.
(8978) WRITE PRINT-LINE.
(2079) GO TO READ-NEXT-DIRECTORY-RECORD.
(g986) CLOSE-ALL,
(0881) CLOSE DIRECTORY-FILE, PRINT-FILE.
(0982) DISPLAY "END TEST SEQUENTIAL READ AFTER A START'.
(0083) STOP RUN.
No Errors, No Warnings, Prime V-Mode COBOL, Rev 17.2 <SAMPLE>
LANGUAGE CONSIDERATIONS
Format notation
Throughout the Reference portion of this document, basic formats are prescribed for
various clauses or statements. These generalized descriptions guide the programmer in
writing his (or her) own statements. They are presented in a uniform system of notation:
* All words printed entirely in capital letters are Reserved Words, These are
words which have preassigned meanings. In all formats, words in capital
letters represent an actual occurrence of those words.
* All underlined Reserved Words are required unless the portion of the
format containing them is itself optional. Such underlined Reserved Words
are Key Words. If any Key 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
FDR 3056 4-4 2 January 1980
Prime character set
The standard character set utilitized by Prime is the ANSI, ASCH, 7-bit character set. The
entire set of characters, with octal, hexadecimal, and punched card equivalents, is
presented in Appendix C.
Collating sequence
Each character in the Prime character set has a unique octal value which establishes the
collating sequence for the character set. This sequence conforms to the American Standards
Code for Information Interchange (ASCII). The characters in Appendix C, the ASCII
Character Set, are arranged in ascending order from top to bottom
LANGUAGE SPECIFICATIONS
COBOL character set
Yhe standard COBOL language character set utilizes 52 characters as follows: The numbers
O through 9, the 26 uppercase letters of the English alphabet, the space (blank), and 14
special characters. (A fifteenth special character. the apostrophe, is used by Prime COBOL
as an alternate for the quotation mark). The complete COBOL character set is illustrated in
Figure 4-2.
The individual characters of the COBOL language are the basic units used to form the major
elements of COBOL, i.e. character-string, separators. words, statements, sentences, para-
graphs, and sections.
Character strings
A character-string is a character or a segence of contiguous characters which forms a
COBOL word, a literal, a PICTURE character-string, or a comment-entry. À character-string
is delimited by separators.
Picture character-strings
A PICTURE character-string (picture-string) consists of certain combinations of characters
in the COBOL character set used as symbols. See DATA DIVISION, PICTURE, for a
description of the PICTURE character-string and the rules governing its use. À punciuation
character which is part of the specification of a PICTURE character-string is not considered
as a punctuation character, but as a symbol in that PICTURE character-string.
Word formation
A COBOL word is a character-slring of not more than 30 characters chosen from the
following set of 37 characters:
O through 9 (digits)
A through Z (letters)
- hyphen
A word must not begin ar end with a hyphen. A word is ended by a space, or by proper
punctuation. A word may contain more than one embedded hyphen: consecutive embedded
hyphens are also permitted.
All words are either Reserved Words or programmer-defined words.
tf a programmer-defined word is not unique, there must be an unique method of referencing
it by using name qualifiers, e.g., TAX-RATE IN STATE-TABLE. Primarily. a programmer-
defined word identifies a data item or field, and is called a data-name. Other cases of
programmer-defined words are file-names, condition-names, and mnemonic-names
1 january 180 47 FOR 3056
4 FUNDAMENTAL CONCEPTS OF COBOL
crass
alpha À
numeric
aumerio
alphabetic
special
characters
CHARACTER MEANING
01.48 cigir
figurative LOW-VALUE(S) value nat)
constants/ZERO,ZEROS,ZERÕES - value tagra)
AB..Zz letter
space biank
poeta PAC válue tblank?
constam
+ plussiga
- imúnius sign
1 asterisk
= equatsign
$ currerioy siga
. comia
semicolón
period
quotation mark
' apostraphe (quotation mark
substitution)
ç teft parenthesis
, right parenthesis
> “ grestec-than
< fess-than
4 “irêuilo (slash
Value (quotation)
figurativo f QUOTEIs)
constant" LHIGHVALEta vôlue tdelotay
Note
When the. figurative constant LOW-VALUES is use with
In ali other instances, it
binary data, ht is initorpreted as numeri
is interpreted as alphanúmerio.
Figure 4-2 COBOL Character Set
* Tiguestive constant
SPECIALUSAGE
COBOL word formation
figurativa Constant
figurativé constant :
COBOL word tormiatioa
punctumtior
figurativo constant
sign symbót'arithmehio editing :
sign symbat/arithmeiia/eosing — -
syrabol/ editing! COBOL iwôrd formitici
coding eyimbot!:siithmadiobaiino
aritbmeticirelanion testa editing -
editing
punctuation fediting.
panetustion CA
purciuatior
punctuation
punctuation
pinctuetion
purictuatioa
relation tests “7.
relation tests: siga
«arithmetic editing icódinertyrebo!
figurativo constant
EDR 3056
48
t January 1980
FUNDAMENTAL CONCEPTS OF €
aa
With the exception of paragraph-name and section-name. all programmer-defined words
must contain at least one alphabetical character.
Reserved words
A Reserved Ward is one of a specified list of words which may be used in COBOL source
programs. but which may not appear as programmers-defined words. They may only be
used as specified in the general formats. The types of Reserved Words are:
* Key words
* Optional words
* Connectives
* Figurative constants
* Special-character words
Key words: A key word is one whose presence is required when the stalement in which the
word appears is used in à source program. Within cach statement, such words are uppercase
and underlined.
Optional words: Within each format, uppercase words which are not underlined are called
optional words; they may appear at the user's option. The presence or absence of an
optional word does not alter the meaning of the COBOL program in which it appears. butis
required as written when used.
Connectives: The three types of connectives are:
1. Qualifier-connectives used to associate a data-name, condition-name,
text-name, or paragraph-name with its qualifier: OF. IN
2. Series connectives which may be used to link two or more consecutive
operands: , [comma) or : [semicolon)
3. Logical connectives used in the formation of conditions: AND, OR
Figurative constants: Figurative constants are Reserved Words used to name and reference
specific constant values. A figurative constant represents as many instances of the as-
sotiated character as required in the context of the statement.
“The singular and plural forms are equivalent and may be used interchangeably
A liguralive constant may be used wherever literal appears in a format description:
except that, whenever the literal is restricted to numeric characters, the only figurative
constant permitted is ZERO (ZEROS, ZEROES). A figurative constant must not be bounded
by quotation marks
Values, and the Reserved Words used lo reference them are:
ZERO
ZEROS — The ASCII character represented hy Octal 260
ZEROES
LOW-VALUE — The character whose Octal representation is 200
LOW-VALUES :
HIGH-VALUE : The character whose Octal representation is 377
HIGH-VALUES
QUOTE
QUOTES :
SPACE ;
SPACES
All literal
The blank character represented by Octal 240
— The quotation mark, whose Oclal representation is 242
The literal is a single character, used in MOVE
statements; the receiving field is filled with the given
. character
Special character words: The arithmetic uperators and relation characters are Reserved
Words. They comprise the following:
1 January 1980 49 FDR 3056
4 FUNDAMENTAL CONCEPTS OF COBOL
Mnemonic-names: A mnemonic-name is assigned in the Enviornment Division under
SPECIAL-NAMES for reference in ACCEPT or DISPLAY statements. A mnemonic-name is
composed according to the rules for Word Formation.
Procedure names: Procedure-names in the form of paragraph-names and section-names are
words which identify paragraphs and sections, respectively, in the Procedure Division
They may be up to 30 characters long, and may be all alphabetic, all numeric, or some
combination of the two.
Literals
A literal is a programmer-defined constant value. It is not identified by a data-name in a
program, but is completely defined by its own identity. A literal is either non-numeric or
numerie,
Non-numeric literals: A non-numeric literal must be bounded by matching quotation marks
or apostrophes and may consist of any combination of characters in the ASCII set, except
apostrophe or quotation marks, respectively. All spaces enclosed by the quotation marks are
included as part of the literal. A non-numeric literal must not exceed 120 characters in
length
The following are examples of non-numeric literals:
“"ILLEGAL CONTROL CARD”
*'CHARACTER-STRINS*
"1234
“gol!
“3. 14149
6
“DO'S & DON"TS"
'PLEASE DON''T SQUEEZE THE CHARMIN!
Each character of a non-numeric literal (following the introductory delimiter) may be any
character other than the delimiter. That is, if the literal is bounded by apostrophes, then
quotation (') marks may be within the literal and vice versa. Length of a non-numeric literal
excludes the detimiters; length minimum is one.
À succession of two delimiters [”) within a literal is interpreted as a single representation
of the delimiter within the literal. The last example above illustrates this point.
Only non-numeric literals may be “continued” from one line to the next. When a non-
numeric literal is of a length such that it cannot be contained on one line of a coding sheet.
the following conventians apply to the next line of coding (continuation line):
* A hyphen is placed in position 7 of the continuation line.
* A delimiter is placed in B Arca preceding the continuation of the literal.
In the absence of continuation characters and delimeters. the non-numeric literal is
required to continue for five lines. On any continuation line, A Area should be blank
Numeric literals: A numeric literal must contain at least one and not more than 18 digits. A
numeric literal may consist of the characters (digits) O through 9 (optionally preceded by a
sign) and/or the decimal point. It may contain only one sign character and only one decimal
point. The sign, if present, must appear as the leftmost character of the numeric literal. If a
numeric literal is unsigned, it is assumed to be positive.
A decimal point may appear anywhere within the numeric literal, except as the rightmost
character. If a numeric literal does not contain a decimal point, it is considered to be an
integer.
FDR 3056 4-12 1 January 1980
FUNDAMENTAL CONCEPTS OF COBOL 4 E
H a literal conforms to the rules for the formation of numeric Hiterals, but is enclosed in
quotation marks, it is a nonnumeric literal and it is treated as such by the compiler.
The following are examples of numeric literais:
72 + BIl 3,14159 — 6 —-.333 0.5
By use of the Environment specfication DECIMAL-POINT IS COMMA, the functions of the
period and comma characters are interchanged, putting the “European” notation into effect.
In this case. the value of "pi" would be 3,1416 when written as a numeric literal
Qualification of names
The user must be able to identify, uniquely, every name which defines an element in à
COBOJ. source program. The name may be made unique in its spelling or hyphenation; or.
procedural reference may be accomplished by use of qualifier names.
In the following example, the data-name, YEAR, will require qualification for procedural
reference:
Bl EMPLOYZE RECORD
B5 NAME
95 ADDRESS
85 HIRE-DATE
18 YEAR
19 MONTH
12 DAY
85 TERMINATION-DATE
18 YEAR
18 MONTH
lg DAY
YEAR OF HIRE-DATE is a qualified reference which would differentiate between year
ficlds in HIRE-DATE and TERMINATION-DATE.
Qualifiers are preceded by the word OF or IN. Successive data-name or condilion-name
qualifiers must designate lesser level-numbered groups which contain all preceding names
in the compasite reference. That is, HIRE-DATE must be a group item (or file-name)
containing an item called YEAR. Paragraph-names may be qualified by their containing
section-name. Therefore. two identical paragraph-names cannot appear in the same section
The rules for qualification are:
« Each qualifier must be of a successively more inclusive level within the
same hierarchy as the name it qualifies.
+ The same name must not appear at two levels in a hierarchy.
+ If a data-name or a condition-name is assigned to more than one item in a
source program, the data-name or condition-name must be qualified each
time it is referred to in the Procedure, Environment, and Data Divisions
(except in the REDEFINES clause where qualification must not be used).
* A data-name cannot be subscripted when it is being used as a qualifier.
* A name can be qualified even though it does not need qualification. If
more than one combination of qualifiers can make a name unique. any
combination can be used. The complete set of qualifiers for a data name
must not be the same as any partial set of qualifiers for another data-name.
* A qualified name may only be written in the Procedure Division.
1 January 1980 4-13 FDR 3056
4 FUNDAMENTAL CONCEPTS OF COBOL
* The maximum number of qualifiers is one for a paragraph-name, five for
a data-name or condition-name. File-names, mnemonic-names, and sec-
tion-names must be unique,
Classes of data
The five categories of data-items (alphabetic, numeric, numeric edited. alphanumeric, and
alphanumeric edited), as specified in the PICTURE clause, are grouped into three classes:
alphabetic, numeric, and alphanumeric. For alphabetic and numeric data items, classes and
categories are the same. The alphanumeric class includes the categories of alphanumeric
edited, numeric edited and alphanumeric (without editing). Every elementary item except
for an index data item belongs to one of the classes and, further, to one of the categories. The
class of a group item is treated at object time as alphanumeric regardless of the class of
elementary items subordinate to that group item. The following chart depicts the rela-
tionship of the class and categories of data items.
Level of data Class Category
í Alphabetic Alphabetic
Numerie Numeric
Elementary Numeric Edited
Alphanumeric Alphanumeric Edited
Alphanumeric
Alphabetic
ó Numeric
Nonelementary Alphanumeric Numeric Edited
(Group) | Alphanumeric Edited
Alphanumeric
Data levels
The two major levels of data are group and elementary:
Group item: A group item is defined as one having further subdivisions, so that it contains
one or more elementary items. In addition, a group item may contain other groups. An item
is a group item if, and only if. its level number is less than the level number of the
immediately succeeding item. If an item is not a group item, then it is an elementary item.
The maximum size of a group is 32,767 characters.
Elementary item: An elementary item is a data item containing no subordinate items. An
elementary item must contain a PICTURE clause, except when usage is described as
COMPUTATIONAL (binary), or INDEX.
Categories of data
The classes of data are: alphabetic, numeric, alphanumeric. Within these, the categories of
data are: alphabetic, numeric, numeric edited, alphanumeric edited and alphanumeric.
Alphabetic item: An alphabetic item consists of any combination of the 26 characters of the
English alphabet and the space character.
Numerie item: A maximum number of 18 digits is permiited; the exact number of digit
positions is defined by the specification of 9's in the picture-string. For example, PICTURE
999 defines a 3-digit item whose maximum decimal value is nine hundred and ninety-nine.
FDR 3055 4-14 1 January 1980
FUNDAMENTAL CONCEPTS OF COBOL 4
of the table are pointed to by subscripts whose values are 2, 3,.... The highest permissible
subscript value, in any particular case, is the maximum number of occurrences of the item
as specified in the OCCURS clause.
The subscript which identifies the table element is delimited by the balanced pair of
separators, left parenthesis and right parenthesis, following the table element data-name.
When more than one subscipt is required, they are written in the order of successively less
inclusive dimensions of the data-organization.
The format is:
data-name
(subscript-1 E, subscript-2 [, subscript-3]])
conditlon-name
Indexing
References can be made to individual elements within a table of like elements by specifying
indexing for that reference. An index is asigned to that level of the table by using the
INDEXED BY phrase in the definition of a table. A name given in the INDEXED BY phrase
is known as an index-name and is used to refer to the assigned index. The value of an index
corresponds to the occurrence number of an element in the associated table. An index-name
must be initialized before it is used as a table reference. An index-name can be given an
initial value by either a SET, a SEARCH AJL, or a Format three Perform statment.
Prime COBOL supports two types of indexing: direct and relative. Direct indexing is
specified by using an index-name in the form of a subscript. Relative indexing is specified
when the index-name is followed by a space, followed by one of the operators + or —,
followed by another space, followed by an usigned integer numeric literal all delimited by
the balanced pair of separators left parenthesis and right parenthesis following the table
element data-name. The occurrence number resulting from relative indexing is determined
by incrementing or decrementing by the value of the literal, the occurrence number
represented by the value of the index. When more than one index-name is required, they
are written in the order of successively less inclusive dimensions of the data organization.
When a statement, which refers to an indexed table element.is executed, the value in the
associated index must neither be less than zero, nor greater than the highest occurrence
number of an element in the table. This restriction also applies to the values resultant from
relative indexing.
The general format for indexing is:
data-name ( index-name-1 [ | +bliterai-2]
condition-name t | Heral-1
indox-name-2 [ | + [Mteral-4)
literal-3
index-name-3 [ ! + ! Hterai-6]
E »
ttoral-5
1 Jonuary 1980 417 FDR 3056
4 FUNDAMENTAL CONCEPTS OF COBOL
Restrictions on qualification, subscripting and indexing.
* A data-name must not itself be subscripted nor indexed when that data-
name is being used as an index. subscript or qualifier
« Indexing is not permitted where subscripting is not permitted
* An index may be modified only by the SET. SEARCH, and PERFORM
statements. Data items described by the USAGE IS INDEX elause permit
storage of the values associated with index-names, Súch data items are
called index data items.
ARITHMETIC EXPRESSIONS
Definition
An arithmetic expression must be an idenlifier or a numeric elementary item, a numeric
literal, such identifiers and literals separated by arithmetic operators, two arithmetic
expressions separated by an arithmetic operator, or an arithmetic expression enclosed in
parentheses. Any arithmetic expression may be preceded by a unary operator. The
permissible combinations of variables, numeric literals, arithemetic operators and paren-
theses are given in Table 4-1
| Table;4-1. Symbol combinations in Arithmetic Expressidns
FIRST SECOND SYMBOL. :-
SYMBOL Variable */—+ Unary + OR — í J
Variable x P x X Pp
EH / e — P XxX Pp Pp X
Unary + or — P x X Pp x
4 Pp x Pp P x
) x Pp x x.oP
In the table above, P — permissible, X = invalid, Variable indicates an identifier or literal,
Tdentifiers and literals appearing in an arithmetic expression must represent either numeric
elementary items or numeric literals on which arithmetic may be performed.
Arithmetic operators
The specific characters below represent the binary and unary arithmetic operators. They
must be preceded and followed by at least one space.
Binary arithmetic Meaning
+ Addition
— Subtraction
+ Multiplication
/ Division
Unary arithmetic Meaning
+ The effect of multiplication by numeric literal +1
— The effect of multiplication by numeric literal —1.
Parenthesis Meaning
(1 Lised to enclosc expressions to control the se-
quence in which conditions are evaluated
Follow these general rules on arithmetic expressions:
Parentheses may be used in arithmetic expressions to specify the order in which elements
are to be evaluated. Expressions within parentheses are evaluated first: and within nested
parentheses, evaluation proceeds from the least inclusive set to the most inclusive set When
FDR 3056 4-18 1 January 1980
FUNDAMENTAL CONCEPTS OF COBOL 4 mM
parentheses are not used, or parenthesized expressions are at the same level of inclusive-
ness, the following hierarchical order of execution is implied:
1st - Unary plus and minus
and - Multiplication and Division
3rd - Addition and Subtraction
When the sequence of execution is not specfied by parentheses, the order of execution of
consecutive operations of the same hierarchical level is from left to right. Example:
A+B/(C-D*E)
This expression is evaluated in the following ordered sequence:
1, Compute the product D times E, considered as intermediate resul! R1
2. Compute intermediate result R2Z as the difference G — Ri.
3. Divide B by R2, providng intermediate result R3
4. The final result is computed by addition of A to R3.
Without parentheses, the expression
A+B/C-D*E
is evaluated as:
R3-D*E
final result — R2 — R3
When parentheses are employed. the following punctuation rules should be used:
2. A Jefl parenthesis is preceded by one or mare spaces.
2, A right parenthesis is followed by one or more spaces.
The expressions 'A - B - C' is evaluated as (A — B) — C', Unary operators are permite,
Example:
COMPUTE A = + C + 4.6 COMPUTE X=-Y
Operators, variables, and parenthesis may he combined in arithmetic expressions as
summarized in Table 4-1,
An arilhmetic expression may begin only with the symbol ( + —or a variable: itmay end only
with a ) or a variable. There must he one-to-one correspondence between left and right
parentheses of an arithmetic expression such that each left parenthesis is to the left of its
corresponding right parenthesis.
Arithmetic statements
“he arithmetic statements are the ADD, COMPUTE, DIVIDE, MULTIPLY, and SUBTRACT
statements. These have several common features.
1. [he data descriptions of the operands need not be the same; any
necessary conversion and decimal point alignment is supplied through-
out the calculation.
2. Yhe maximum size of each operand is 18 decimal digits. The composite of
operands, which is a hypothetical data item resulting from the super-
imposition of specified operands in a statement aligned on their decimal
points, must not contain more than 18 decimal digits.
1 January 1980 4-19 FDR 3056
4 FUNDAMENTAL CONCEPTS OF COBOL
“The rules for comparing a conditional variable with a condition-name value are the same as
those specified for relation conditions
“Vhe result of the test is true if one of the values corresponding to the condition-name equals
the value of its associaled conditional variable. Condition-names are allowed in lhe File
Section and Linkage Section where VALUE clauses are not.
Sign condition: The sign condition determines whether or not the algebraic value of an
arithmetic expression is less than, greater than, or equal to zero. The general format for a
sign condition is as follows:
POSITIVE |
data-name IS [NOT] 4 NEGATIVE
ZERO
Complex conditions
A complex condition is a concatenation of simple conditions, combined conditions and/or
complex conditions with logical connectors (logical operators 'AND' and 'OR' or negating
these conditions with logical negation (the logical operator 'NOT").The truth of a complex
condition is that truth value which results from the interaction of all the stated logical
operators on the individual truth values of simple conditions, or the intermediate truth
values of conditions logically connected or logically negated. Five levels of parentheses are
permitted in complex conditions.
The logical operators are:
Logical operator Meaning
AND Logical conjunction; the truth value is 'true' if both
of the conjoined conditions are true; 'false' if onc
or bath of the conjoined conditions is false.
OR Logical inclusive OR; the truth value is 'true' if one
or both of the included conditions is true; false" if
bath included conditions are false.
NOT Logical negation is the reversal of the truth value:
i.e. the truth value is 'true' if the condition is false,
and false" if condition is true.
Logical operators must be preceded and followed by a space.
Negated simple conditions: The general format of a negated simple condition is:
NOT simple-condition
Thus, the simple condition is negated through the use of the logical operator NOT.
The truth value of a negated simple condition is the opposite of the truth value for a simple
condition: i.e.. true if the simple condition is false and false if the simple condition is true.
Inclusion in parenthesis of a negated simple condition does not affect the truth value.
Combined and negated combined conditions: Combined conditions are simple conditions
connected by one af the logical operators AND or OR. A combined condition has the format:
AND
condition- [NOT] condition-2
OR
FDR 3056 4-22 1 January 1980
FUNDAMENTAL CONCEPTS OF COBOL 4 =
where condition is:
A simple condition
A negated simple condition
A combined condition
A negated combined condtion, i.e., the logical operator NOT followed by a
combined condition enclased in parentheses
« Combinations of the above
Table 4-2 below sets forth the permissible combinations of conditions, logical operators and
parentheses,
Table 4-2. Permissible combinations of conditions, logical operations and parentheses
Conditional Using a left to right sequence of elements
ELEMENT Expression When not first, When not lust.
Location the element can be the element can be
immediately preceded immediately followed
First Lost only by only by
Simple-condition Yes Yes OR, NOT. AND, ( OR, AND. |
OR and AND No No Simple-candition. ) Simple-condition.
NOT, |
NOT Yes No OR, AND, ( Simple-condition. |
í Yes No OR, NOT. AND, ( Simple-condition.
NOT. (
) No Yes Simple-condition, ) OR. AND. |
Multiple conditions: Multiple conditions reler to complex conditions grouped in paren-
theses: as previously stated, parentheses are permitled lo five levels.
When more lhan five levels ol parentheses are required, explicit grouping, condition-names,
nested IF statements, or some combination of the above should be substituted.
For example, in the statement
IFa=bAND(c-dORe=tf
explicit grouping may be achieved by coding
IFa=bANDc-dORa=bANDe-f
Abbreviated combined relation conditions
Abbreviated combined relation conditions refer to conditions with implicd subjects. That is.
the omission of the subject of the relation, or the omission of both the subject and the
relational operator of the relation condition.
The format for a abbreviated combined relation condition is:
AND
retation-condition ENOT] [relatlonal-operator] object ...
OR
Wilhin a sequence as described above, eilher form of abbreviation may be used: the
omissian of subject. ar the omission of subject and relational aperator
“Fhe effect of such abbrevialions is that of inserting the previously stated subject in place of
the omitted subject, or lhe previous stated relational operator.
1 January 1980 4-23 FDR 3056
4 FUNDAMENTAL CONCEPTS OF COBOL
All insertions terminate once a complete simple condition is encountered within a complex
condition.
In all instances, the results must comply with the rules outlined in Table 4-2 above.
Negated relation condilions arise from lhe use of the word NOT in an abbreviated combined
relation condition. They are evaluated as follows:
* NOT participates as part of the relational operalor il the word immediately
following NOT is GREATER, >. LESS, <. EQUAL, or eq;
* Not is interpreted as a logical operator if the above condition does not
apply. with the result thal the implied insertion of subject or relational
operator results in a negated relation condition,
Below are examples of abbreviated combined relation condilions
Abbreviated Combined
and Negated Combined
Relation Conditions Expanded Equivalent
a=boRrcoRd a=boa=coORa=d
a > bANDNOT<cORd ((a > b) AND (a NOT < c)) or (a NOT < d)
NOT a=borc (NOT (a = b)) OR (a
c)
a NOT EQUAL Db OR c (a NOT EQUAL b) OR (a NOT EQUAL c)
NOT (a GREATER b OR < c) NOT ((a GREATER b) OR (a < c))
NOT (a NOT > b AND c NOT ((( a NOT > b) AND (a NO? > c))
AND NOT d) AND (NOT (a NOT > d)))
Note
The reader is cautioned about the ambiguities which arise
from such coding
Condition evaluation rules
Parentheses can be used to specify the arder in which individual conditions of complex
conditions can be evaluated when it is necessary to depart from the implied evaluation
precedence. Conditions within parentheses are evaluated first. and, within nested paren-
theses, evaluation proceeds from lhe least inclusive condition to the most inclusive
condition. When parentheses are not used, or when parenthesized conditions are at the
same level of inclusiveness, the following hierarchical order of logical evaluation is implied
until the final truth value is determined.
1, Truth values for simple conditions are evaluated in the following order:
Relation (following the expansion of any abbreviated relation condition:
Class
Condition-name
Sign
2. Truth values for negated simple conditions are established
3. Trulh values for combined conditions are established:
AND logical operators. followed hy
OR logical operators
4, Truth values for negated combined conditions are established
FDR 3055 4-24 1 January 1980
IDENTIFICATION DIVISION
pe Function
“he Identification Division must be included in every COBOL source program as the first
entry. is division identifies the source program and the resultant outpul listings
Additional user information, such as the date the program was written or the program
author, may he included under the appropriate paragraph(s) in the general format shown
below.
Format
ID DIVISION. (or IDENTIFICATION DIVISION.)
PROGRAM-ID. program-name. (no special characters In name)
(AUTHOR. comments.)
EINSTALLATION. comments.)
[DATE-WRITTEN. comments]
[DATE-COMPILED. comments.]
[BECURITY. comments.)
REMARKS. comments.)
> Syntax rules
1. The Identification Division must begin with ID DIVISION or IDENTI-
FICATION DIVISION followed by a period and a space.
2. The PROGRAM.-ID paragraph is required and must follow immediately
after the division header.
3. Program-name follows the general rules for Word Formation. Tt may
be any alphanumeric string. However, the first character must be
alphabetic. Special! characters, including the hyphen, are prohibited.
(Only the first six characters of program-name are retained by lhe
compiler.)
4. All remaining paragraphs are optional. When included, these must be
presented in order shown above.
. The comments entry can be any combination of characters. Use of the
hyphen in the continuation indicator area is not permitted; however, the
comments entry can appcar on one or more lines.
a
1 Jonuory 1980 5-1 FDR 3056
5 IDENTIFICATION DIVISION
pb General rule
Fixed paragraph names identify the type of information contained in the paragraph.
De Example
ID DIVISION.
PROGRAM-ID. REF2,
AUTHOR. PRIME COMPUTER,
INSTALLATION. CORPORATE TECHNICAL PUBLICATIONS DIVISION.
DATE-WRITTEN. SEPTEMBER 1, 1979.
DATE-COMPILED. SEPIEMBER 1, 1979.
SECURITY. NONE.
REMARKS. THIS AREA IS USED TO DESCRIBE THE PROGRAM.
FDR 3056 5-2 1 January 1980
6 ENVIRONMENT DIVISION
[1-0-CONTROL.
SAME AREA FOR file-name-1[ , file-name-2), ]
b Syntax rules
1, The Environment Division must begin with the header, ENVIRONMENT
DIVISION, followed by a period and a space
2. Mandatory sequence vf required and optional paragraphs is shown in
the above format,
Note
In the rare instance when hardware-dependent configura-
tions and consideratins do not apply, the entire ENVIRON-
MENT DIVISION may be omitted. However, the header,
ENVIRONMENT DIVISION, must be presented all the time.
pe General rule
Each section within the Environment Division begins with its section-name, followed by the
word SECTION, and each paragraph within each section begins with its paragraph-name.
[CONFIGURATION SECTION.
This sectian is optional. Itis required only if one or more of the following three paragraphs
is used
1. [SOURCE-COMPUTER. computer-name ]
Computer-name serves only as a comment entry. It is used to identify the
computer for which the COBOL program is written.
2. [OBJECT-COMPUTER. computer-name .]
Computer-name serves only as a comment entry. Itis used to identify the
computer on which the COBOL program will be executed.
3 [SPECIAL-NAMES.
This paragraph is optional. It is required only if one or more of the
following four statements is used
* [CONSOLE IS mnemonic-name]
Mnemonic-name is a programmer-defined word which will
be associated with CONSOLE throughout the program.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES. CONSOLE IS TTY.
FDR 3056 6-2 1 January 1980
ENVIRONMENT DIVISION 6
PROCEDURE DIVISION.
DISPLAY YEAR OP HIRE-DATE UPON TTY.
The coding above would cause the field, YEAR OT HIRE-
DATE, to be output on the CONSOLE.
Note
CONSOLE IS is an optional statement. IH omitted, the com-
puter will automatically associate CONSOLE (terminal) with
ACCEPT and DISPLAY.
* [CURRENCY SIGN IS literat)
Literal represents the currency sign to be used in the
PICTURE clause, It is a single character, non-numeric
literal which will be used to replace the dollar sign as the
currency sign. The designated character may not be a quote
mark, or any of the characters defined for PICTURE repre-
sentations.
« [DECIMAL-POINT IS COMMA]
The “European” convention of separating integer and frac-
tion positions of numbers by the comma character, rather
than the decimal point or period, is specified by use
of the DECIMAL-POINT IS COMMA clause.
Note
The Reserved Word, IS, is required in entries for currency
sign definition and decimal-paint conventian specification.
+ [ASCU IS NATIVE) ]
The entry, ASCILIS NATIVE, specífies that the data repre-
sentation adheres to the American Standard Code for
information Interchange as shown in Appendix C. This
convention is assumed even if the entry is not present.
[ENPUT-OUTPUT SECTION.
The INPUT-QUTPU'I SECTION is used when there are external data files. It allows
specification of peripheral devices and information needed to transmit and handle data
between the devices and the program. "he section has two paragraphs: FILE-CONTROL and
FO-CONTROL
FILE-CONTROL,
This entry names each file and specifies its device medium, allowing specified hardware
assignments. It can also specify other file-related information, such as number of input-
output areas allocated, file organization, and method of file access. The format chosen is
1 January 1880 6-3 FDR 3056
6 ENVIROMENT DIVISION
dependent upon file organization. Each file requires one SELECT statement and the
appropriate sequence of optional clauses.
Format one
SELECT flle-name
ASSIGN TO device
AREA
E; RESERVE Integer-1
AREAS
[; ORGANIZATION IS SEQUENTIAL)
[; ACCESS MODE IS SEQUENTIAL]
E FILE STATUS IS data-name-1].
Format two
SELECT file-name
ASSIGN TO device
AREA
E RESERVE integer-1 1
AREAS
; ORGANIZATION IS RELATIVE
SEQUENTIAL [, RELATIVE KEY IS data-name-1]
[; ACCESS MODE IS mn 3
» RELATIVE KEY IS data-name-1
DYNAMIC
E FILE STATUS IS data-name-2).
Format three
SELECT file-name
ASSIGN TO device
AREA
[; RESERVE Integer-1
AREAS
1 ORGANIZATION IS INDEXED
FDR 3056 6-4 1 January 1980
=
ENVIRONMENT DIVISION 6
The SAME AREA clause allows the programmer to share the same I/O buffer areas for files
which arc not open concurrently. No file may be listed in more than une SAME AREA
clause.
Db Example
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. PRIME-758.
OBJECT=-COMPUTER. PRIME-756.
SPECIAL-NAMES. CONSOLE IS TTY ,
ASCII IS NATIVE.
INPUT-CUTPUT SECTION.
FILE-CONTROL
SELECT PRINT-FILE ASSIGN TO PRINTER.
SELECT CARD-FILE ASSIGN TO PFMS.
SELECT DIRECTORY-FILE ASSIGN TO PFMS,
ORGANIZATION IS INDEXED,
ACCESS MODE IS DYNAMIC,
RECORD KEY IS PHONE-NUMBER,
ALTERNATE RECORD KEY LAST-NAME,
ALTERNATE RECORD KEY STATE,
ALTERNATE RECORD KEY BIRTH-DATE,
ALTERNATE RECORD KEY FIRST-NAME,
FILE STATUS IS FILE-STATUS,
7 January 1980 6-7 FDR 3056
Data division
DATA DIVISION
D Function
The Data Division of the COBOL souree program defines the nature and characteristics of
the data to be processed by the program. Data to be processed falls into three calegories:
1, Data is contained in files and entets or leaves lhe internal memory of the
computer from a specified area or areas.
2. Data is developed internally and placed into intermediate or working
storage.
3, Canstants which are defined by the user.
The Data Division consists of three optional sections. If used, they must appear in the
following order:
1. FILE SECTION. Files and records in files are described.
2, WORKING-STORAGE SECTION. Memory space is allocated for the
storage of intermediate processing results.
3. LINKAGE SECTION. Data available to a called program is described.
Format
DATA DIVISION.
[FILE SECTION.
[fle-description-entry.
[record-descriptlon-entry] ..
[sori-file-descriptlon-entry.
frecord-deseription-entry)... 3... ]
[WORKING-STORAGE SECTION.
Ilevel-77-data-description-entry] ...
[data-item-description-entry] ... ]
LINKAGE SECTION.
[level-77-data-descrlption-entry] ...
Edata-item-descriptlon-entry)] ... 1
Syntax rules
1. The Data Division must begin with the header DATA DIVISION, fol-
lowed by a periad and a space.
1 January 1980 74 FDR 3056
7 DATA DIVISION
> General rules
1. The UNCOMPRESSED clause is optional. When used, it enables a READ
based on record length (PRWFIL). rather than compression control
characters (RDASC).
2. The UNCOMPRESSED option must be used when reading sequential
YO files containing packed or binary data.
Note
The UNCOMPRESSED reserved word is non-ANSL and is
peculiar to Prime
Never use the slandard utilities such as EDITOR an a file
which is to be accessed UNCOMPRESSED for a COBOL
program
LABEL RECORDS
> Function
The LABEL RECORDS clause specifies whether labels are present for the file
Format
| necono is |) ( STANDARD
LABEL ,
| neconos ARE | | OMITTED
ç
> Syntax rule
This clausc is required in every file description entry.
> General rules
1. OMITTED specifies that no explicit labels exist for the file or device to
which the file is assigned.
STANDARD specifies that a label exists for the file and that the label
conforms to system specifications. The STANDARD option must be
specified for all files assigned to DISK (PFMS) or tape. See Table 7-1
below.
Note
Standard labels are automatically provided for disk files. See
Appendix G. LAREL COMMAND, for information on stan-
dard labels for magtape.
Table 7-1. Label Options
Device Standard Omilted
Terminal
Reader
Printer
Punch
MT9 (Tape)
PEMS (Disk)
XXNS
Na
BLOCK CONTAINS
> Function
The BLOCK CONTAINS clause specifies the size of a physical record.
FDR 3056 7-4 1 January 1980
DATA DIVISION 7
Format
RECORDS
[BLOCK CONTAINS IIntegert-1 TO ] Integer-2
o CHARACTERS
> Syntax rules
1. The BLOCK CONTAINS clause is optional.
2. The clause can only be used in connection with tape files.
b- General rules
1. The clause may be omitted if the physical record contains one, and only
one, complete logical record
2. Qmission of this clause assumes records are unblocked.
3. When the RECORDS option is used, the compiler assumes that the block
size provides for integer-2 records of maximum size and then provides
additional space for any required control words.
4. When the word CHARACTERS is specified, the physical record size is
specified in terms of the number of character positions required to store
the physical record, regardless of the types of characters used to
represent the items within the physical record.
. When neither the CHARACTERS nor the RECORDS option is specified.
the CHARACTERS aption is assumed.
5. When both integer-1 and integer-2 are used, inleger-1 is for documenta-
tion purpose only.
a
RECORD CONTAINS
> Function
The RECORD CONTAINS clause specifies the size of data records.
Format
RECORD CONTAINS [Integer-3 TO] Integer-4 CHARACTERS
> General rules
1, Since the size of each data record is defined fully by the set of data
description entries constituting the record (level 03) declaration, this
clause is always optional,
. Integer-4 may not be used by itself unless all the data records in the file
have the same size. In this case, integer-4 represents the exact number of
characters in the data record. If integer-3 and integer-4 are both shown.
they refer to the minimum number of characters in the smallest size data
record, and the maximum number of characters in the largest size data
record. respectively
3. The maximum size of a single data record is 32,767 characters.
ts
7 Januory 1480 7-5 FDR 3056
7 DATA DIVISION
VALUE OF FILE - ID
> Function
The VALUE OF FILE-ID clause particularizes the description of an item in the label records
associated with a file, thus allowing for the linkage of internal and external program names,
Format
(VALUE OF FILE-D is literai-1]
> Syntax rule
This clause is mandatory if labels are standard.
> General rules
1. Literal-1 assuciates the internal FD file-name with an external file-name
It is a non-numeric value which may not exceed eight characters.
2. If there are no file assignments at run-time (explained in Section 3).
literal-1 will become the default value for the internal file-name.
OWNER IS
> Function
The OWNER IS clause specifies the LIser File Directory (UFD) in a Prime system, in which
VALUE OF FILE-ID value is contained.
Format
[OWNER is literal-2]
> Syntax rule
The OWNER JS clausc may be used only with disk files
> General rules
1, Literal-2 is a non-numeric value which may not exceed six characters
2. The clause is overridden by explicit definition at run-lime
3. If the clause is used. it must follow the above rules. If omitted, a default
of the current UFD may apply.
DATA RECORDS
> Function
The DATA RECORDS clause serves only as documentation for lhe names af data records
and their associated file.
a
1
a
FDK 3055 2 Januory 1980
DATA DIVISION 7
Format three
VALUE IS THROUGH
88 conditlon-name; literal-1 [ tlteral-2]
VALUES ARE THRU
THROUGH
[ literal-3 [ Hteral-4]3....
THRU
Format four
VALUE IS
88 condition-name; literal-1 [, literal-2]....
VALUES ARE
> Syntax rules
t
ta
a
a
The level-number in Format one may contain a value of 01 through 49, or
77
In Formal one, clauses can be written in any order with two exceptions:
“The data-name-1 or FILLER clause must immediately follow the level-
number: and the REDEFINES clause. when used. must immediately
follow the data-name-1 clause.
. In Format one, PICTURE clause must he specified for every elementary
item except when USAGE is described as binary (COMPUTATIONAL!
A group item cannot contain a PICTURE clause.
The OCCURS clause cannot be specified in a data description entry
which has a 01. 66, 77, or an 88 level-number.
. Format two permits alternative possible averlapping groups of elemen-
tary items
. Formats three and four are used only for condition-names which must
have a level-number 88. Formats three and four may not be combined for
a single level 86 entry.
| The words THRU and THROUGH are equivalent and interchangeable
Reserved Words.
> General rule
A record description entry can appear in the File, Working-Storage. or Linkage Section of
the Data Division. All records in each file referenced by a file description entry (FD] must
be described by record description entries.
1 Januory 1980 7-9
FDR 3056
7 DATA DIVISION
> Function
The level-number shows the position of a data-item within the hierarchy of duta in a logical
record. It also identifies entries for condition-names, and data ilems in the Working-Storage
and Linkage Sections.
Format
tevel-number
> Syntax rules
1, A level-number is required as the first element in each data description
entry (see REGORD DESCRIPTION).
2. Wata description entries subordinate to an FD entry must have level-
numbers 01 through 49. 66, or 88.
3. Data description entries in lhe Working-Storage and Linkage Sections
must have level-numbers 01 through 49, 66, 77 or 88.
> General rules
1. Level-numbers are used to subdivide a record so that each item in the
record may be relerred to. A record can be divided, and each subdivision
further divided, until a basic level is reached which cannot be further
divided. An item at this basic level is called an elementary item. A record
can itself be an elementary item.
2. À group consists of one or more consecutive elementary items: groups
can. in turn, be combined into other groups of two or more gronp items.
A group consists of a specified group item and all following group and
elementary items with level-numbers greater than that of the specificd
group item, and continuing until the next item with a level-number less
than or equal to that of the specified group item is reached
3. Level-numbers range from 01, the most inclusive level, to 49. the least
inclusive level, Any level-number except 49 can denote a group.
4. The level number 01 identifies the first entry in each Data Description. À
reference to level-number 01 data-name in the Procedure Division is
a reference to lhe entire record.
Multiple level 01 entries subordinate to one FD level indicator represent
implicit redefinitions of the same area
a
o
. Special level-numbers have been assigned to certain entries where there
is no real concept of hierarchy.
7. Level-number 77 is assigned to identify noncantiguous working storage or
linkage data items. They may be used only as described in Format one of
the data description entry.
Level-number 77 data items are elomentary items which cannot be
subdivided.
8. Level-number 88 is assigned to entries which define condition-names
associated with a conditional variable. They can be used only with
Formats three and four of the data description entry.
FDR 3056 7-10 1 Jonuary 1980
DATA DIVISION 7
Level 88 entries can contain individual values, series of individual
values, or a range of values. Such entries cannot combine ranges and
individual values.
Example:
9) Test-area PIC X.
88 Test-Value-l Value '1!,
88 Test-Value-2 value '1L!, !2!,
88 Test-Value-3 Value 1" thru '8'.
88 Test-Value-4 Value !1' thru !4!, !6!, 19º,
in lhe example above, lhe last 88 level definition is invalid.
A level 88 entry must be preceded by one of the following: Another level
88 entry, where there are several consecutive condition-names per-
taining to an elementary item. or. an clementary item.
Every condition-name pertains to an elementary item in such a way lhal
the condition-name be qualified by the name of the elementary item and
the elementary item's qualifiers. A condition-name is used in lhe
Procedure Division in place of a relational condition.
A condition-name may pertain to an clementary item (a condilional
variable) requiring subscripts. In this case, the condition-name. when
written in the Procedure Division, must be subscripted according to the
same requirements as lhe associated elementary item
The type of literal in a condition-name entry must he consistent with the
data type of the conditional variable. In the following example. PAY-
ROLL-PERIOD is the conditional variable. The picture associated with it
limits the value of the 88 condition-name to one digit.
92 PAYROLL-PERIOD PIC IS 9.
88 WEEKLY VALUE IS 1.
88 SEMI-MONTHLY VALUE IS 2.
88 MONTHLY VALUE IS 3.
Using the above description, one may write the procedural condition-
name test
IF MONTHLY GO TO DO-MONTHLY.,
An equivalent statement is:
IF PAYROLL-PERIOD = 3 GO TO DOMONTHLY.
For an edited elementary item, values in a condition-name entry must be
expressed in the form of non-numeric literals
Level number 68 is assigned to identify RENAMES entries. They can be
used only with Format two of the data description entry
1 January 1980 7-1 FDR 3056
7 DATA DIVISION
Format
THROUGH
66 data-name-1 RENAMES data-name-2 data-name-3
THRU
Note
Level-number 66 and data-name-1 are not part of the
RENAMES clause, but are included to show the context
> Syntax rules
1, Any number of RENAMES entries may be written for a logical record
They must all immediately follow the last entry of that record
2. Data-name-1 cannot be used as a qualifier but can be qualified to the 01
or FD entries. Neither data-name-2 nor data-name-3 may have an
OCCURS clause nor be subordinate to an entry that has an OCCURS
clause in its data description entry.
3. Data-name-2 and data-name-3 must be the names of elemenlary items or
groups of elementary items in the same record and cannot have the same
data-name
A level 66 entry cannot rename another level 66 entry or a 77. 88 0r 01
level entry.
. The beginning of the area described by data-name-3 must be to the right
of the area described by data-name-2.
> Exampie
91 MASTER.
95 EMP-REC.
18 EMPNO PIC 9(4).
18 EMP-NME.
15 LASTT PIC X(14).
15 FIRSTT PIC X(II.
18 DEPT-CODE PIC 99.
19 TEL-EXT PIC 9 (4).
95 WORKED-PER-WEEK PIC 9(4).
46 NAME-TAG RENAMES EMP-NAME THRU DEPT-CODE.
OCCURS
> Functions
“the OCCURS clause permits the definition of related sets of repeated data, such as tables,
arrays, lists, supplying required information for the application of subscripts or indexes.
FOR 3056 7-14 1 januory 1980
DATA DIVISION 7
Format
OCCURS integer-1 TIMES
( ASCENDING I
KEY IS data-name-1 [, data-name-2]...]
| DESCENDING ,
[INDEXED BY index-name-41 [, Index-name-2]... ]
> Syntax rules
1. Integer-1 must be greater than one and less than 32,767
2, Yhe OCCURS clause must not he used in a data description entry having
a 01, 66, 77. or an 88 level-number.
3. lf the data-name applies to a group item. then all data-names belonging
to the group must be subscripled or indexed whenever they are used.
> General rules
1, When the OCCURS clause is used, the data-name which is the delining
name of the entry must be subscripted whenever it appears in the
Procedure Division. If the INDEXED BY phrase is specified, then the
data-name must also be indexed. However, if the data-name is referred
to in a SEARCH Statement, it must not be subscripted or indexed
2. The OCCURS clause specification causes a fixed length table to be
generated. Its length is equal to the value ol integer-1 times the size of
cach element. The size of the table illustrated below is 10 x 10 (100):
01 FIRST-TABLE.
95 ELEMENT PIC X(LB) OCCURS 18 TIMES.
See Seclion 10, TABLE HANDLING, for further detailed
discussion of the OCCURS clause
PICTURE
> Function
The PICTURE clause describes the general characteristics and editing requirements of an
clementary item.
Format
( pretuRE
[ | | IS picture-string] (or character-string)
PIC
1 January 1980
=“
0
a
FDR 3056
7 DATA DIVISION
Syntax rules
1. A PICTURE clause can be specified only at the elementary item level.
2. A picture-string consists of certain allowable combinations of characters
in the COBOL character set used as symbols. The allowable combina-
tions determine the category of the elementary item.
3. The maximum number of character positions allowed in a picture-string
is 30. For example, PIC X(35) and PIC X(3) consist of 5 and 4 PICTURE
characters, respectively.
4. The PICTURE clause must be specified for every elementary item excepl
binary items,
5. PIC is a valid abbreviation for PICTURE.
6. The asterisk when used as the zero suppression symbol and the clause
BLANK WHEN ZERO may not appear in the same entry.
> General rules
1, Data: Five categories of data can described wilh a PICTURE clause:
Alphabetic, numeric, alphanumeric, alphanumeric edited, and numeric
edited.
+ Alphabetic: Picture-string can only contain the characters
A and B; and. item contents must be any combination of the
letters of the English alphabet and the COBOL space
character.
Numeric: Picture-string can only contain the symbols 9, P,
S, and V. The number of digit positions which may be
represented by picture-string is from 1 to 18; and item
contents must be a combination of the digits O through 9.
These may be signed, or not. TF signed, the ilem may be
positive or negative.
Alphanumeric: Picture-string is a combination of data de-
seription characters X, A, or 9, and the item is treated as if
the string contained al! X's. Alphanumeric picture-strings
may not employ all 9's or all A's; and, item contents may be
any character from the computer's ASCI] character set.
Alphanumeric edited: Picture-string is restricted to cerlain
combinations and the following symbols: A, X. 9. B, 0. /:
and. item contents are any character from the computer's
ASCII character set
Numeric Edited: The picture-string is a certain combina-
tion of the editing symbols: Z. CRDB,$8+7B0=-/9V
P; and, the picutre-string must contain at least one of the
editing symbols in conjunction with numeric symbols: and,
item contents must be one of the digits.
2, Size: The size of an elementary item (the number of character positions
occupied by the item in standard data format) is determined by the
number of alowable symbols which represent character positions.
An integer, enclosed in parentheses, following the symbols À. X 9P X*
B/0+-or the currency symbol, indicates the number of consecutive
occurrences of that symbol. The following symbols can appear only once
in a given PICTURE: S V. CR DB.
3. Decimal-Point Clause: When DECIMAL-POINT IS COMMA is specified,
the explanations for period and comma are understood to apply to
comma and periods, respectively.
FDR 305 7-16 4 January 1980