GNUCobol 4 Grammar
GNUCobol 4 Grammar
0-early-dev
Grammar
FOR R3716
Edward Hart
[email protected]
• IBM Commercial Translator, Form No. F28-8013, copyrighted 1959 by IBM, and
They have specially authorised the use of this material, in whole or in part, in the
COBOL specifications. Such authorisation extends to the reproduction and use of COBOL
specifications in programming manuals or similar publications.
1
The CODASYL COBOL committee was dissolved in 1992. Its work was continued by ANSI X3J4 and then
INCITS PL22.4, which was itself dissolved in 2015.
2
Sperry Rand’s computer business is now part of Unisys.
ii
Contents
Foreword xiv
Changelog xvi
1. GnuCOBOL 4.0-early-dev . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
2. GnuCOBOL 3.1-dev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii
3. GnuCOBOL 2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxxi
1. Key 3
2. Language fundamentals 5
2.1. Lexical elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.1. COBOL words . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.2. User-defined words . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.3. Reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.4. Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2. References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3. Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.1. Arithmetic expressions . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.2. Concatenation expressions . . . . . . . . . . . . . . . . . . . . 13
2.3.3. Conditional expressions . . . . . . . . . . . . . . . . . . . . . . 13
2.4. Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.4.1. Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.4.2. Locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4.3. Screens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4.4. User-defined functions . . . . . . . . . . . . . . . . . . . . . . . 15
3. Compiler directives 17
3.1. CALL-CONVENTION directive . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2. *CONTROL statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.3. COPY statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.4. D directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.5. DEFINE directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.6. DISPLAY directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.7. EJECT statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.8. IF directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.9. LEAP-SECOND directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.10. LISTING directive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
iv
Contents
4. Compilation group 53
5. Identification division 56
5.1. PROGRAM-ID paragraph . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.2. FUNCTION-ID paragraph . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.3. OPTIONS paragraph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
6. Environment division 61
6.1. Configuration section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
6.1.1. SOURCE-COMPUTER paragraph . . . . . . . . . . . . . . . . . . 62
6.1.2. OBJECT-COMPUTER paragraph . . . . . . . . . . . . . . . . . . 63
6.1.3. SPECIAL-NAMES paragraph . . . . . . . . . . . . . . . . . . . . 64
6.1.4. REPOSITORY paragraph . . . . . . . . . . . . . . . . . . . . . . 66
6.2. Input-output section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
6.2.1. FILE-CONTROL paragraph . . . . . . . . . . . . . . . . . . . . . 67
6.2.2. I-O-CONTROL paragraph . . . . . . . . . . . . . . . . . . . . . . 72
v
Contents
7. Data division 74
7.1. File section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
7.1.1. File description entry . . . . . . . . . . . . . . . . . . . . . . . . 75
7.2. Working-storage section . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7.3. Communication section . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
7.3.1. Communication description entry . . . . . . . . . . . . . . . . . 77
7.4. Local-storage section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
7.5. Linkage section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
7.6. Report section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.6.1. Report description . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.7. Screen section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
7.7.1. Screen description . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.8. Record description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
7.9. Constant definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
7.10. Data division clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
7.10.1. ANY LENGTH clause . . . . . . . . . . . . . . . . . . . . . . . . 93
7.10.2. AUTO clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
7.10.3. BACKGROUND-COLOR clause . . . . . . . . . . . . . . . . . . . 95
7.10.4. BACKGROUND-HIGH clause . . . . . . . . . . . . . . . . . . . . 96
7.10.5. BACKGROUND-LOW clause . . . . . . . . . . . . . . . . . . . . 97
7.10.6. BACKGROUND-STANDARD clause . . . . . . . . . . . . . . . . 98
7.10.7. BELL clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
7.10.8. BLANK clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.10.9. BLANK WHEN ZERO clause . . . . . . . . . . . . . . . . . . . . 101
7.10.10. BLINK clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
7.10.11. BLOCK clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
7.10.12. COLOR clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
7.10.13. COLUMN clause . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
7.10.14. CCOL clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
7.10.15. CLINE clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
7.10.16. CSIZE clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
7.10.17. DATA RECORDS clause . . . . . . . . . . . . . . . . . . . . . . . 109
7.10.18. DESTINATION clause . . . . . . . . . . . . . . . . . . . . . . . . 110
7.10.19. DESTINATION COUNT clause . . . . . . . . . . . . . . . . . . . 111
7.10.20. DESTINATION TABLE OCCURS clause . . . . . . . . . . . . . . 112
7.10.21. END KEY clause . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
7.10.22. Entry name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
7.10.23. ERASE clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
7.10.24. ERROR KEY clause . . . . . . . . . . . . . . . . . . . . . . . . . 116
7.10.25. EXTERNAL clause . . . . . . . . . . . . . . . . . . . . . . . . . . 117
7.10.26. EXTERNAL-FORM clause . . . . . . . . . . . . . . . . . . . . . . 118
7.10.27. FOREGROUND-COLOR clause . . . . . . . . . . . . . . . . . . . 119
7.10.28. FROM clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
7.10.29. FULL clause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
vi
Contents
vii
Contents
viii
Contents
ix
Contents
x
Contents
xi
Contents
Appendices 389
xii
Foreword
This document describes the syntax of COBOL as supported by GnuCOBOL. It is hoped it
will complement Gary Cutler and Vincent Coen’s GnuCOBOL Programmer’s Guide which
(currently) does not document recent features added to GnuCOBOL. This document is
also formatted in LATEX, so that everything looks a bit prettier.
The syntax diagrams were transcribed from GnuCOBOL’s parsers. It thus replicates
some unusual syntax rules and misses some syntax rules implemented outside the
parser. For example, the obsolete identification division comment paragraphs are al-
lowed in any order and the syntax of a file-control entry does not distinguish between
SEQUENTIAL, INDEXED and RELATIVE organisations.
This is a draft and so has many flaws. If people find this document useful, I will try to
fix these shortcomings.
xiv
Changelog
1. GnuCOBOL 4.0-early-dev
General
• configure: fixed unwanted flags not being removed completely (bug #627).
• EXTFH: added support for the external file handler (EXTFH) interface, letting users
provide a custom file handler.
• EXTFH: the old OpenCOBOL EXTFH interface (built into GnuCOBOL with the --with-
seqra-extfh and --with-index-extfh build options) has been marked as obsolete.
Configuration options
xvi
Changelog
– create_table (whether the ODBC/OCI file handler should create a DDL file from
an XFD file if no DDL exists).
– mf_ls_instab (whether to replace tabs by spaces which fill up to the next tab
stop (tab stops set 8 spaces apart)).
– keycheck (check whether INDEXED file keys match the SELECT specification
exactly).
Compiler directives
Identification division
Environment division
Data division
• SYNCHRONIZED clause: LEFT phrase is now marked as unimplemented (see bug #512).
Procedure division
• File I-O: allow file-handler to be configured for individual files or organizations us-
ing environment variables (or dictionary files).
xvii
Changelog
• File I-O: added initial support for ODBC and OCI as file-handlers.
• File I-O: changed file status for detecting bad data in line sequential files from 34
to 71.
• File I-O: fixed issues with LINE SEQUENTIAL and OPEN I-O on platforms that re-
quire output to be flushed between read and write of a file.
• INSPECT statement: fixed multiple TALLYING phrases being rejected (see bug #47)
• Procedure division header: fixed error when a variable-length parameter was not
referenced (bug #648).
• SET statement: added support for FH--FCD and FH--KEYDEF (feature request #349).
• Tracing: fixed line numbers when tracing inside RECURSIVE programs (bug #611).
2. GnuCOBOL 3.1-dev
NB: Some changes have been made to 3.1-dev which have not yet been merged up to
4.0-early-dev. They have been marked with an asterisk (*).
General
xviii
Changelog
• cobc command-line options: added -fdump to dump data of all modules on abend
of program.
• cobc command-line options: added -O0 for disabling optimisations (feature re-
quest #255).
• cobc command-line options: added -fec and -fno-ec to enable and disable excep-
tion checks.
xix
Changelog
• COBOL-85 NIST testsuite: tests can now be downloaded from Sourceforge when
the NIST website is unavailable (bug #563).
• Copyfiles: fixed segfault when GnuCOBOL tried and failed to open a copyfile (bug #458).
• Error messages: runtime error messages now use translated versions (depending
on a user’s language).
• Error messages: added checks for version control conflict markers in source code.
• Expressions: fixed bug #431, where decimal constants were not initialised in INI-
TIAL programs.
• Listings: fixed some cases of cross-reference listings containing wrong line num-
bers.
• Listings: fixed segfault in listing programs with large REPLACE arguments (bug #515).
• Listings: fixed stack overflow in listing programs long literals (bug #569).
xx
Changelog
• National literals: added Fujitsu NC national character literals (feature request #352).
• National literals: fixed NX type literals being treated as alphanumeric (bug #658).
• Nested programs: fixed bug #435, where identifiers in the containing program
where not propagated to the contained program, causing a segfault.
• Nested programs: fixed bug #587, where a memory error occurred when a pro-
gram was nested inside a program with the same name.
• Recursion: fixed bug #222, where the return value was lost when returning from a
recursive call.
• Reserved words: allow users to make default reserved words aliases for other
words.
• Screen section testsuite: added a manual testsuite for screen section functional-
ity (patch #26).
• Solaris support: fixed errors and warnings when compiling in Solaris 10.
• Tracing: added new options for controlling tracing (see feature request #242).
xxi
Changelog
Configuration options
• assign-clause compiler configuration option: added options external (equivalent
to ibm) and dynamic (equivalent to mf).
• IBM dialect: reserved words updated to Enterprise COBOL V6.2.
• incorrect-conf-sec-order option: changed to “ok” from “error” in mf and default
dialects.
• MF dialect: added ARGUMENT-NUMBER and ARGUMENT-VALUE as reserved words.
• New compiler configurations: realia for CA Realia II.
• New compiler configuration options: assign-disk-from, assign-ext-dyn, assign-using-
variable, assign-variable, binary-comp-1, call-convention-mnemonic, call-convention-
linkage, continue-after, display-special-fig-consts, free-redefines-position (feature
request #211), hp-octal-literals, implicit-assign-dynamic-var, goto-entry, line-col-zero-
default, national-character-literals move-figurative-space-to-numeric, move-non-numeric-
lit-to-numeric-is-zero, missing-statement, numeric-pointer, perform-without-varying-
by, record-delimiter, record-delim-with-fixed-recs, records-mismatch-record-clause,
report-column-plus, screen-section-rules, sequential-delimiters, symbolic-constant,
type-to-clause*, usage-type*, xml-generate-extra-phrases, zero-length-literals.
• New runtime configuration options:
– col_just_lrc (for enabling/disabling the LEFT/RIGHT/CENTER phrases of the
report COLUMN clause),
– printer and display_print_pipe (for specifying what command should be exe-
cuted before DISPLAY UPON PRINTER; similar to Micro Focus’ COBPRINTER
option);
– display_print_file (name of file which DISPLAY UPON PRINTER will append
its output to), display_punch_file (name of file to created upon first DISPLAY
UPON SYSPUNCH),
– mouse_flags (to let mouse clicks move the cursor in ACCEPT),
– mouse_interval (maximum time between mouse press and mouse release
events for them to recognised as a click),
– trace_format,
– dump_file and
– dump_width.
• Registers: disabling a register also removes the reserved word with the same
name, if it exists (feature request #278).
• Registers: added COL and LIN.
• Runtime configuration options: use the system’s file path separator instead of
always using : (so the path separator is now ; on Windows). (See bug #610.)
xxii
Changelog
Compiler directives
• COPY statement: added support for copybook and library names containing pe-
riods as text-names. For example, “COPY copybook.cpy.” is now accepted. See
feature request #344.
• New Micro Focus directives: ADDRSV, ADDSYN, MAKESYN, OVERRIDE and RE-
MOVE (feature request #210); ASSIGN, BOUND*, CALLFH, COMP1 and SSRANGE*.
Identification division
Environment division
• ALTERNATE RECORD KEY clause: implemented split keys (SOURCE IS; feature
request #23) and sparse keys (SUPPRESS WHEN; feature request #281).
• ASSIGN clause: re-enabled use of linkage section or BASED items (bug #421).
• CLASS phrase: fixed bug #566, where class-names were not inherited by nested
subprograms.
xxiii
Changelog
• CURRENCY phrase: changed to emit error when CURRENCY SIGN other than “$”
is entered.
• CURSOR phrase: fixed bug #579, where the CURSOR data item was not used for
the initially positioning the cursor in an ACCEPT statement.
• FILE STATUS clause: added detection of VSAM secondary status identifier (fea-
ture request #51).
• RECORD clause: fixed behaviour in the IBM dialect when the maximum record
length does not match the length in the RECORD clause.
• RECORD KEY clause: implemented sparse keys (SOURCE IS; feature request #23).
xxiv
Changelog
Data division
• 88-level items: improved error messages when used in the wrong places.
• ANY LENGTH clause: fixed bug #487, where literals moved to ANY LENGTH items
were incorrectly truncated.
• ANY LENGTH clause: fixed bug #511, where comparisons treated ANY LENGTH
items as having just one character.
• ANY LENGTH clause: fixed segfault when referencing linkage-section ANY LENGTH
items in the first compiled program.
• COLUMN clause: “COL +1” and similar clauses are no longer allowed; there must
now be a space between the sign and the number.
• errno: can now access the C global variable errno by declaring a variable as EX-
TERNAL AS "errno" (feature request #49).
• LINE clause: “LINE +1” and similar clauses are no longer allowed; there must now
be a space between the sign and the number.
• PICTURE clause*: fixed compiler crash with malformed picture-string (bug #659).
• RENAMES clause: fixed bug #623, where RENAMES items had a LENGTH OF zero.
• Screen description: the rules on which clauses must be specified when now de-
pend on the dialect (see bug #382).
xxv
Changelog
• USAGE clause: added option to make COMP-1 mean a 16-bit signed integer (fea-
ture request #272).
Procedure division
• ACCEPT statement (environment): added recognition of INPUT STATUS and TERMINAL-
INFO and SYSTEM-INFO phrases.
• ACCEPT statement (screen): fixed ACCEPT WITH UPDATE and not working (bug #423).
• ACCEPT statement (screen): fixed bug #426, where backspacing at the start of a
field moved the cursor to the second-to-last character of the preceding field.
• ACCEPT statement (screen): fixed error when filling in a one character field with
insert mode on (bug #498).
• ACCEPT statement (screen): pressing the home key, or end key, now toggles be-
tween going to the start of, or end of, the field and the cursor’s original position.
• ACCEPT statement (screen): added support for Microsoft COBOL position speci-
fiers.
• ACCEPT statement (temporal): fixed bug #469, where ACCEPT FROM DAY was
off by −1.
xxvi
Changelog
• CALL statement: fixed ON EXCEPTION not working properly with -fstatic (bug #462).
• CALL statement*: fixed RETURN-CODE being set with RETURNING field (bug #651).
• Conditions: fixed LESS OR EQUAL being accepted, but LESS OR EQUALS being
rejected (bug #663).
• CONTINUE (after): added support for (from COBOL 202X draft standard). See
feature request #354.
• DISPLAY statement (screen): fixed bug #428, where DISPLAY ALL “x” WITH SIZE
only displayed “x” once.
• DISPLAY statement (screen): added support for Microsoft COBOL’s position spec-
ifiers and ERASE phrase.
• Error messages: runtime error messages now include “error: ” after the filename
and before the actual error message.
• Error messages: fixed incorrect use of “parameter” where “argument” was meant.
• Error messages: fixed bug #586, where GnuCOBOL would cause a buffer overflow
when outputting an error message with a very long literal.
• EVALUATE statement: added partial support for WHEN clauses not containing any
statements, which transfer control to the next WHEN clause containing a state-
ment, if any (so the behaviour is like C’s switch statement).
• Exceptions: the exception status is now only reset by SET LAST EXCEPTION TO
OFF.
xxvii
Changelog
• File I-O: fixed bug #457, where file status 30 was set instead of the correct perma-
nent error status (34, 35 or 37).
• File I-O: error messages from libcob now include the file I-O statement that caused
them, when known.
• File I-O (BDB): fixed file status after OPEN OUTPUT on an OPTIONAL file.
• File I-O (ISAM): fixed bug involving START . . . LESS EQUAL followed by READ PRE-
VIOUS.
• File I-O (ISAM): fixed bug #589, where READ would skip records with duplicate
keys after a DELETE.
• Floating-point arithmetic: fixed incorrect SIZE ERROR exceptions (see bug #470).
• Floating-point arithmetic: fixed bug #478, where calculations with the SIZE ERROR
phrase have different results to calculations without it.
• Floating-point arithmetic: now activate the SIZE ERROR handler when a floating-
point variable is set to a non-finite value (see bug #122).
• LENGTH OF phrase: fixed error message when used on group fields (bug #175).
xxviii
Changelog
• PERFORM statement: added check for non-zero item in BY phrase (feature re-
quest #268).
• PERFORM statement (inline): added partial support for inline PERFORM state-
ments not containing any statements.
• Procedure division header: error if two USING BY REFERENCE parameters are the
same (bug #635).
• Procedure division header*: fixed use of variable-length RETURNING item (bug #641).
• OPEN statement: fail with file status 39 when the first record of an indexed file is
larger than specified in the FD.
• READ statement (indexed): fail with file status 43 when the read record is larger
than specified in the FD.
• Report writer: implemented, including features from COBOL 2002 and the IBM
Report Writer.
xxix
Changelog
• REWRITE statement (indexed): now sets file status to 02 when duplicate key is
detected.
• SET statement: fixed bug #225, where an invalid SET statement caused an error
saying “invalid MOVE statement”.
• SUBTRACT statement: fixed bug #603, where subtracting an integer from a floating-
point variable lead to incorrect results.
• STOP statement: fixed the NORMAL phrase causing a compilation error (bug #433).
• WRITE statement: fixed compilation error when writing to a GLOBAL file in a sub-
program (bug #87).
• WRITE statement (indexed): now sets file status to 02 when duplicate key is de-
tected.
Intrinsic functions
• WHEN-COMPILED function: fixed timezone, which was missing its sign and con-
tained nonsense when negative (bug #436).
xxx
Changelog
Built-in subprograms
• C$GETPID: fixed wrong process ID being returned after forking (bug #451).
• C$SLEEP: if the requested time is too large, sleep for the maximum possible time
instead of not at all.
3. GnuCOBOL 2.2
This list tracks changes made from 23 November 2013. This excludes many changes
made in 2009–2013 which would be pertinent to those upgrading from a 2009 build of
OpenCOBOL 1.1 found in many package repositories.
General
• 64-bit numbers: fixed bugs in handling of 64-bit numbers (e.g. bug #229).
• C API (data): added several functions for getting and setting cob_field items.
• C API (screen): added several functions from Micro Focus’ C to COBOL API: cob_display_text,
cob_sys_get_char, cob_get_char, cob_get_text, cob_display_formatted_text, cob_sys_get_csr_pos,
cob_sys_set_csr_pos, cobmove, cobaddstrc, cobprintf and cobgetch (feature re-
quests #148 and #187).
xxxi
Changelog
• cobc command-line options: added -t and -T for complete listing support (-t for
80-characters wide listings and -T for 132-characters wide) which includes cross-
references (thanks to Dave Pitts).
• cobc command-line options: added -vvv (like -vv but passes verbose option to the
linker as well) and -### (like -v but commands are not executed).
• COBOL-85 NIST testsuite: tests now refer to $COBC, $COBCRUN and $COBCRUN_DIRECT
environment variables instead of directly calling cobc and cobcrun, allowing the
testsuite to run in conjunction with tools like valgrind.
• COBOL-85 NIST testsuite: tests for obsolete feature flagging are now executed,
if possible.
• configure: added useful error message when help2man, bison and flex are miss-
ing when they are needed.
• curses: fixed compilation errors when configured without curses (bug #90).
• Error messages: error messages are now lowercase, in line with the GNU Coding
Standards (bug #198).
• Error messages: segfaults in the compiler now cause an error message to be dis-
played.
xxxii
Changelog
xxxiii
Changelog
Configuration options
• New compiler configurations: all dialects have been split into standard and strict
dialects, with strict dialects maintaining source compatibility with the dialect’s
compiler(s).
• New compiler configurations: acu for ACUCOBOL, cobol2014 for COBOL 2014, rm
for RM-COBOL, xopen for X/Open.
• Registers: compiler configurations can now specify all the registers to generate.
• Reserved words: compiler configurations can now specify all the reserved words
and context-sensitive words permitted.
• Support options: options which specify if a feature is supported can now take a “+”
before their argument to indicate it takes effect only if the current level of support
is less strict than “ok”.
Compiler directives
• >>IF directive: fixed bug #263, where nested >>IF directives were not handled cor-
rectly.
xxxiv
Changelog
Identification division
Environment division
• ASSIGN clause: temporarily prohibit BASED and linkage items in ASSIGN USING
due to bug #421.
• CURRENCY phrase: fixed bug #182, where a preceding SWITCH phrase caused an
incorrect duplicate CURRENCY clause error.
• File-control entry: fixed bug #71, where referring to a global constant caused an
internal error.
xxxv
Changelog
• File-control entry: fixed bug #331, where using an identifier in a file record qualified
with the file’s name caused an error.
• FUNCTION phrase: compiler will no longer stop when it encounters a syntax error.
• SWITCH phrase: added check for duplicate on/off clauses (bug #136).
Data division
• ANY NUMERIC clause: ANY NUMERIC items must now have PIC 9.
• ANY LENGTH clause: ANY LENGTH items may no longer be BY VALUE parameters
(see bug #219).
• ANY LENGTH clause: ANY LENGTH items must now have PIC X or PIC N.
• BLANK clause: fixed bug #143, where BLANK LINE/SCREEN did not colour line/
screen.
• BLANK WHEN ZERO clause: added checks that BLANK WHEN ZERO is not speci-
fied with PICTURE clauses containing S.
• ERASE clause: fixed bug #186, where ERASE EOL and ERASE EOS could be speci-
fied simultaneously.
xxxvi
Changelog
• FULL clause: added warning for useless FULL clauses on numeric items (feature
request #209).
• HIGHLIGHT and LOWLIGHT clauses: added checks that HIGHLIGHT and LOW-
LIGHT are not specified simultaneously.
• Local-storage section: fixed bug #78, where local-storage items where initialised
after file section items.
• OCCURS clause: fixed internal compiler when used with SYNC (bug #155).
• OCCURS clause: allow KEY phrase and INDEXED phrase in any order.
• OCCURS clause: fixed bug #167, where overly large numeric literals where ac-
cepted in the OCCURS clause.
• OCCURS clause (depending): require the minimum length to be less than the max-
imum length (feature request #99).
• USAGE clause: added ACUCOBOL’s HANDLE phrases (see feature request #77).
• VALUE clause: VALUE clauses in REDEFINES entries now cause warnings, not
errors, for compatibility.
• Variable records: added checks that the minimum size of a variable record is large
enough to contain the record key.
xxxvii
Changelog
Procedure division
• ACCEPT statement (screen): enhanced support for special keys (insert, tab, delete,
alt-delete, etc.).
• ACCEPT statement (screen): fixed bug #161 where screens terminated after en-
tering a few characters in a field.
• ACCEPT statement (screen): ERASE and BLANK clauses in screens are now ig-
nored (bug #192).
• ACCEPT statement (screen): fixed bug #160 where ACCEPT statement LINE/COLUMN
clauses did not work.
• ACCEPT statement (screen): added checks that screen attributes are not speci-
fied multiple times or after conflicting attributes.
• ACCEPT statement (screen): fixed some phrases not being recognised without
being preceded by WITH (bug #402).
• ACCEPT statement (screen): fixed the backspace and delete keys not working
and the insert key not toggling between insertion and overwriting.
xxxviii
Changelog
• CALL statement: the generation of C function declarations for static CALLs can
now be disabled.
• Conditions: added warnings for always true/false conditions (including the reason
why it is always true/false).
• DISPLAY statement (screen): fixed bug where EC-SCREEN exceptions did not trig-
ger ON EXCEPTION handler (bug #243).
• DISPLAY statement (screen): added checks that screen attributes are not speci-
fied multiple times or after conflicting attributes.
• DISPLAY statement (screen): fixed some phrases not being recognised without
being preceded by WITH (bug #402).
• END DECLARATIVES phrase: fixed bug #88, where an erroneous unreachable code
warning was emitted for code without a main procedure.
xxxix
Changelog
• File I-O: added detection of and handling for error when no disc space is available
for output files.
• INITIALIZE statement: fixed bug #84, where literals could be passed to INITIALIZE.
• INITIALIZE statement: fixed bug #287, where reference-modified group items were
not treated like elementary items.
• INSPECT statement: fixed bug #47, where clauses were permitted in invalid or-
ders.
• LENGTH OF phrase: fixed bug #89, where the length of REDEFINES item where
calculated incorrectly.
• LENGTH OF phrase: fixed bug #110, where LENGTH OF was not allowed in the
UNTIL phrase of a PERFORM statement or in a VALUE clause.
• MOVE statement: fixed truncation of COMP numbers not conforming to the binary-
truncate setting (bug #69).
• PERFORM statement: fixed bug #368, where the compiler segfaulted when there
was a PERFORM statement with an empty body and DEBUGGING MODE was spec-
ified.
• Procedure division header: fixed bug #55, where a user-defined function without
parameters failed to compile.
• Procedure division header: disabled the BY VALUE phrase, pending a working im-
plementation.
xl
Changelog
• Procedure division header: fixed bug #349, where BY VALUE pointer parameters
lead to code that couldn’t be compiled by older versions of Microsoft Visual C++
(patched by Mario Matos).
• Procedure division header: RETURNING items must now be declared in the link-
age section.
• Procedure division header: now mandatory in function definitions (see bug #271).
• READ statement: a failed second READ of a missing OPTIONAL file now results
in a file status of 46, not 23.
• Screen I-O: added support for the LINE 0 and COL 0 extensions.
• Screen I-O: added some ACUCOBOL synonyms (NO ECHO, OFF, REVERSED, RE-
VERSE, etc.).
• Screen I-O: added detection of ACUCOBOL’s non-standard clauses like TAB, NO-
ECHO, STANDARD, BACKGROUND-HIGH, BACKGROUND-LOW, BACKGROUND-STANDARD
and SIZE.
• SEARCH statement (ALL): fixed bug #314, where SEARCH ALL with an empty OC-
CURS DEPENDING table did not exit as soon as possible.
• SET statement (attribute): made HIGHLIGHT ON imply LOWLIGHT OFF and vice
versa.
xli
Changelog
• Tracing: fixed bug #216, where a segfault occurred with a program made from
modules some of which had been compiled with tracing and physical CANCEL
enabled and some of which hadn’t.
• UNSTRING statement: fixed bug #54, where the POINTER value was calculated
incorrectly when the delimiter was longer than one character.
Intrinsic functions
Built-in subprograms
• CBL_GC_FORK: added.
• CBL_GC_WAITPID: added.
xlii
Changelog
xliii
Changelog
1
1. Key
Element Notes
Braces, { } One element within the braces must be se-
lected.
Brackets, One or zero elements within the brackets
must be selected.
Vertical lines, | | Each element may be selected once and in
any order; if within braces, at least one ele-
ment must be selected.
Ellipsis, . . . The preceding element may be repeated any
number of times.
OPTIONAL-RESERVED-WORD
MANDATORY-RESERVED-WORD Mandatory reserved words in brackets are
often used instead of optional reserved
words to indicate an optional feature.
Deleted element These elements were previously in the
COBOL standard but have since been
deleted. Their use is strongly discouraged.
Archaic element These elements remain in the standard, but
their use is considered poor style and is
strongly discouraged.
Obsolete element These elements are slated to be deleted
from the standard. Their use is strongly dis-
couraged.
X/Open extension
GnuCOBOL-only extension
Miscellaneous extension An extension which may have come from
COBOL dialects by AcuCorp, CA, Fujitsu,
HP, IBM, Micro Focus, Microsoft or Ryan-
McFarland.
Unimplemented element These elements are recognised by Gnu-
COBOL, but are non-functional.
3
2. Language fundamentals
2.1. Lexical elements
2.1.1. COBOL words
2.1.2. User-defined words
2.1.3. Reserved words
2.1.4. Literals
Alphanumeric literals
Format 1 (standard)
h i
' character-1 . . . '
h i
" character-2 . . . "
Format 2 (hexadecimal)
h i
X' hex-character-1 . . . '
h i
X" hex-character-2 . . . "
Format 3 (null-terminated)
h i
Z' character-3 . . . '
h i
Z" character-4 . . . "
5
2. Language fundamentals
Format 4 (raw-C-string)
h i
L' character-5 . . . '
h i
L" character-6 . . . "
Numeric literals
Format 5 (integer)
0
1
2
3
" #
+ 4
...
-
5
6
7
8
9
Format 6 (fixed-point)
0
0
1 1
2 2
3 3
" # ()
+ 4 . 4
. . . ...
-
5
,
5
6 6
7 7
8 8
9 9
Format 7 (floating-point)
6
2. Language fundamentals
0 0
0
1 1 1
2 2 2
3 3 3
" # () " #
+ 4 . 4 + 4
. . . , 5. . . E - 5. . .
5
-
6 6 6
7 7 7
8 8 8
9 9 9
Format 8 (binary)
( )
0
B# ...
1
Format 9 (octal)
0
1
2
( )
O# 3
...
% 4
5
6
7
Format 10 (hexadecimal-number)
7
2. Language fundamentals
0
1
2
( )
H# 3
...
X#
4
5
6
7
Format 11 (hexadecimal-string)
h i
H' character-7 . . . '
h i
H" character-8 . . . "
Boolean literals
Format 12 (standard)
h i
B' character-9 . . . '
h i
B" character-10 . . . "
Format 13 (hexadecimal)
h i
BX' hex-character-3 . . . '
h i
BX" hex-character-4 . . . "
National literals
Format 14 (standard)
8
2. Language fundamentals
h i
N' character-11 ...'
h i
N" character-12 . . . "
h i
NC' character-13 ...'
h i
NC" character-14 . . . "
Format 15 (hexadecimal)
h i
NX' hex-character-5 . . . '
h i
NX" hex-character-6 . . . "
Figurative constants
Format 16 (zero)
ZERO
ALL ZEROES
ZEROS
Format 17 (space)
( )
SPACE
ALL
SPACES
Format 18 (high-value)
( )
HIGH-VALUE
ALL
HIGH-VALUES
9
2. Language fundamentals
Format 19 (low-value)
( )
LOW-VALUE
ALL
LOW-VALUES
Format 20 (quote)
( )
QUOTE
ALL
QUOTES
Format 21 (null)
( )
NULL
ALL
NULLS
Format 22 (literal)
ALL literal-1
Format 23 (symbolic-character)
ALL symbolic-character-1
10
2. Language fundamentals
2.2. References
11
2. Language fundamentals
2.3. Expressions
2.3.1. Arithmetic expressions
Arithmetic expressions may contain the following operators:
Unary operators
+ no effect 4
– multiplication by −1 4
Binary operators must have a numeric item or expression to both their left and right.
Unary operators must have a numeric item or expression to their right only.
Operators with greatest precedence are evaluated first. If an expression contains mul-
tiple operators of equal precedence, they are evaluated from left to right.
Arithmetic expressions may contain arithmetic expressions surrounded by parenthe-
ses. These nested expressions are evaluated first, before any of the operators of the
outer expression.
Second symbol
First symbol
Identifier or literal Binary operator Unary operator ( )
Identifier or literal 3 3
Binary operator 3 3 3
Unary operator 3 3
( 3 3 3
) 3 3
12
2. Language fundamentals
13
2. Language fundamentals
2.4. Concepts
2.4.1. Files
I-O status
00 Success
02 Success – duplicate
04 Success – incomplete
05 Success – optional
07 Success – no unit
End of file
10 End of file
21 Key invalid
22 Key exists
24 Key boundary
31 Inconsistent filename
34 Boundary violation
37 Permission denied
39 Conflict attribute
14
2. Language fundamentals
44 Record overflow
46 Read error
47 Input denied
48 Output denied
49 I-O denied
51 Record locked
57 I-O linage
61 File sharing
71 Bad character
91 Not available
Organizations
Locking
2.4.2. Locales
2.4.3. Screens
2.4.4. User-defined functions
15
3. Compiler directives
3.1. CALL-CONVENTION directive
COBOL
EXTERN
>>CALL-CONVENTION
STDCALL
STATIC
Syntax rules
General rules
17
3. Compiler directives
SOURCE
NOSOURCE
( )
*CBL LIST
*CONTROL
NOLIST
MAP
NOMAP
Syntax rules
General rules
18
3. Compiler directives
Syntax rules
General rules
19
3. Compiler directives
3.4. D directive
>>D source-text-1
Syntax rules
General rules
20
3. Compiler directives
Syntax rules
General rules
21
3. Compiler directives
( )
>>
DISPLAY source-text-1
$
Format 2 (vcs)
Syntax rules
General rules
22
3. Compiler directives
EJECT
Syntax rules
General rules
23
3. Compiler directives
3.8. IF directive
DEFINED
( )
>> SET
IF compilation-variable-1 IS NOT
$ relation
compilation-variable-2
source-text-1
"( )( ) #
>> ELIF
condition-1 source-text-2 . . .
$ ELSE-IF
"( ) #
>>
ELSE source-text-3
$
" #
>>END-IF
$END
Syntax rules
General rules
24
3. Compiler directives
>>LEAP-SECOND
Syntax rules
General rules
25
3. Compiler directives
Syntax rules
General rules
26
3. Compiler directives
Syntax rules
General rules
27
3. Compiler directives
Syntax rules
General rules
28
3. Compiler directives
PROCESS
Syntax rules
General rules
29
3. Compiler directives
( ) ( )
== pseudo-text-1 == == pseudo-text-2 ==
BY
h identifier-1
i identifier-2
REPLACE ALSO ( ) ....
LEADING
TRAILING == partial-word-1 == BY == partial-word-2 ==
Format 2 (off)
h i
REPLACE LAST OFF.
Syntax rules
General rules
30
3. Compiler directives
Syntax rules
General rules
31
3. Compiler directives
SKIP1
Syntax rules
General rules
32
3. Compiler directives
SKIP2
Syntax rules
General rules
33
3. Compiler directives
SKIP3
Syntax rules
General rules
34
3. Compiler directives
Syntax rules
General rules
35
3. Compiler directives
Syntax rules
General rules
36
3. Compiler directives
Syntax rules
General rules
37
3. Compiler directives
Syntax rules
General rules
38
3. Compiler directives
Syntax rules
General rules
39
3. Compiler directives
Syntax rules
General rules
40
3. Compiler directives
BOUND
Format 2 (disable)
( )
NOBOUND
NO-BOUND
Syntax rules
General rules
41
3. Compiler directives
Syntax rules
General rules
42
3. Compiler directives
Syntax rules
General rules
43
3. Compiler directives
( ) ( )
FOLDCOPYNAME "UPPER"
AS
FOLD-COPY-NAME "LOWER"
Format 2 (disable)
NOFOLDCOPYNAME
NOFOLD-COPY-NAME
NO-FOLD-COPY-NAME
Syntax rules
General rules
44
3. Compiler directives
Syntax rules
General rules
45
3. Compiler directives
Syntax rules
General rules
46
3. Compiler directives
Syntax rules
General rules
47
3. Compiler directives
Syntax rules
General rules
48
3. Compiler directives
"1"
SSRANGE "2"
"3"
Format 2 (disable)
( )
NOSSRANGE
NO-SSRANGE
Syntax rules
General rules
49
3. Compiler directives
Name Condition
DEBUG The -d debug flag is specified.
EXECUTABLE The module being compiled contains the main program.
GCCOMP The size of a COMP item is determined according to the Gnu-
COBOL scheme, where for a PICTURE of length:
MODULE The module being compiled does not contain the main pro-
gram.
NOHOSTSIGNS A signed packed-decimal item’s value may not be considered
NUMERIC if the sign has value X"F".
NOIBMCOMP The size of a COMP item is not determined according to the
IBM scheme.
NOSTICKY- Sticky-linkage (linkage-section items remaining allocated be-
LINKAGE tween invocations) is not enabled.
NOTRUNC Numeric data items are truncated according to their internal
representation.
50
3. Compiler directives
51
4. Compilation group
" #
program-definition
...
function-definition
where program-definition is
"( ) #
IDENTIFICATION
DIVISION.
ID
COMMON
( )
INITIAL
( )
program-name-1 h i
PROGRAM-ID. AS literal-2 IS RECURSIVE PROGRAM.
literal-1
EXTERNAL
h i
comment-paragraphs
h i
environment-division
h i
data-division
h h i i
procedure-division program-definition . . .
" ( )#
program-name-1
END PROGRAM .
literal-1
where function-definition is
"( ) #
IDENTIFICATION
DIVISION.
ID
( )
function-name-1 h i
FUNCTION-ID. AS literal-4 .
literal-3
h i
comment-paragraphs
h i
environment-division
h i
data-division
h i
procedure-division
( )
function-name-1
END FUNCTION .
literal-3
53
4. Compilation group
Syntax rules
General rules
54
5. Identification division
"( ) #
IDENTIFICATION
DIVISION.
ID
( )
function-id-paragraph
program-id-paragraph
h i
options-paragraph
AUTHOR. comment-text.
DATE-WRITTEN. comment-text.
DATE-MODIFIED. comment-text.
DATE-COMPILED. comment-text. . . .
INSTALLATION. comment-text.
REMARKS. comment-text.
SECURITY. comment-text.
Syntax rules
General rules
56
5. Identification division
Syntax rules
General rules
57
5. Identification division
Syntax rules
General rules
58
5. Identification division
OPTIONS.
NATIVE
STANDARD
STANDARD-BINARY
ARITHMETIC IS
STANDARD-DECIMAL
OSVS
AWAY-FROM-ZERO
NEAREST-AWAY-FROM-ZERO
NEAREST-EVEN
NEAREST-TOWARD-ZERO
DEFAULT ROUNDED MODE IS
PROHIBITED
TOWARD-GREATER
TOWARD-LESSER
TRUNCATION
COBOL
ENTRY-CONVENTION IS EXTERN
STDCALL
NEAREST-AWAY-FROM-ZERO
NEAREST-EVEN
INTERMEDIATE ROUNDING IS .
PROHIBITED
TRUNCATION
Syntax rules
General rules
59
6. Environment division
h i
ENVIRONMENT DIVISION.
h i
configuration-section
h i
input-output-section
Syntax rules
General rules
CONFIGURATION
h SECTION. i
source-computer-paragraph
h i
object-computer-paragraph
h h i i
special-names-header special-names-entry . . .
h i
repository-paragraph
Format 2 (micro-focus-and-gnucobol)
h i
CONFIGURATION SECTION.
source-computer-paragraph
object-computer-paragraph
special-names-header
special-names-entry
repository-paragraph
61
6. Environment division
Syntax rules
General rules
Syntax rules
General rules
62
6. Environment division
Syntax rules
General rules
63
6. Environment division
mnemonic-name-clause
alphabet-name-clause
symbolic-characters-clause
symbolic-constant-class
LOCALE locale-name-1 IS literal-1
class-clause
h i
CURRENCY SIGN IS literal-2 WITH PICTURE-SYMBOL literal-3
DECIMAL-POINT IS COMMA ... .. . .
NUMERIC SIGN IS TRAILING SEPARATE
CURSOR IS identifier-1
CRT STATUS IS identifier-2
SCREEN-CONTROL IS identifier-3
EVENT-STATUS IS identifier-4
TOP IS identifier-5
where mnemonic-name-clause is
IS CRT
integer-1 IS system-name-1
mnemonic-name-1 h (
i ON STATUS IS switch-status-name-1
)
IS switch-name-1
OFF STATUS IS switch-status-name-2
where alphabet-name-clause is
64
6. Environment division
ALPHABET
alphabet-name-1 IS
ASCII
EBCDIC
STANDARD-1
STANDARD-2
NATIVE
h i
FOR ALPHANUMERIC
LOCALE
( )
THROUGH
literal-5
THRU
literal-4 . . .
n o
ALSO literal-6 . . .
UTF-8
UTF-16
UCS-4
NATIVE
h i
FOR NATIONAL
LOCALE
( )
THROUGH
literal-8
literal-7 THRU . . .
n o
ALSO literal-9 . . .
where symbolic-characters-clause is
SYMBOLIC
( CHARACTERS ( ) )
n o IS n o h i
symbolic-character-name-1 . . . integer-2 . . . . . . IN WORD
ARE
where symbolic-constant-clause is
n o
SYMBOLIC CONSTANT identifier-6 IS literal-10 . . .
where class-clause is
" # ( "( ) #)
FOR ALPHANUMERIC THRU
CLASS class-name-1 IS literal-11 literal-12 . . .
FOR NATIONAL THROUGH
h i
IN alphabet-name-1
Syntax rules
General rules
65
6. Environment division
REPOSITORY.
(n o )
function-name-1 . . .
FUNCTION INTRINSIC
ALL
... .
h i
FUNCTION function-name-2 AS literal-1
h i
PROGRAM program-name-1 AS literal-2
Syntax rules
General rules
66
6. Environment division
Syntax rules
General rules
where file-control-entry is
actual-key-clause
assign-clause
access-mode-clause
alternate-record-key-clause
collating-sequence-clause
collating-sequence-key-clause
file-limit-clause
file-status-clause
lock-mode-clause
" #
OPTIONAL nominal-key-clause
SELECT file-name-1 . . . .
NOT OPTIONAL organization-clause
padding-character-clause
password-clause
record-delimiter-clause
record-key-clause
relative-key-clause
reserve-clause
sharing-clause
track-area-clause
track-limit-clause
67
6. Environment division
where actual-key-clause is
where assign-clause is
h i
device-or-line-adv-file literal-1
device
"
#
EXTERNAL
( )
external-file-name
h i
DYNAMIC device-or-line-adv-file
ASSIGN TO identifier-2
( )
h i USING
device-or-line-adv-file identifier-3
VARYING
DISK FROM identifier-4
where device-or-line-adv-file is
( )
device
LINE ADVANCING FILE
where device is
CARD-PUNCH
CARD-READER
CASSETTE
DISC
DISK
DISPLAY
INPUT
INPUT-OUTPUT
KEYBOARD
MAGNETIC-TAPE
OUTPUT
PRINT
PRINTER
PRINTER-1
RANDOM
TAPE
where access-mode-clause is
68
6. Environment division
SEQUENTIAL
ACCESS MODE IS DYNAMIC
RANDOM
where alternate-record-key-clause is
"( ) #
= n o
ALTERNATE RECORD KEY IS identifier-5 identifier-6 . . .
SOURCE IS
h h i i
WITH NO DUPLICATES
h i
PASSWORD IS identifier-7
h i
SUPPRESS WHEN literal-2
where collating-sequence-clause is
h i
IS alphanumeric-collating-sequence national-collating-sequence
COLLATING SEQUENCE (FOR ALPHANUMERIC IS alphanumeric-collating-sequence)
FOR NATIONAL IS national-collating-sequence
where collating-sequence-key-clause is
where file-limit-clause is
( )( ) (( )( )( ))
FILE-LIMIT IS identifier-9 THROUGH identifier-10
...
FILE-LIMITS ARE literal-3 THRU literal-4
where file-status-clause is
" #
FILE h i
STATUS IS identifier-11 identifier-12
SORT
where lock-mode-clause is
69
6. Environment division
LOCK
(( MODE IS ) " ( )# )
MANUAL h i RECORD
WITH LOCK ON MULTIPLE WITH ROLLBACK
AUTOMATIC RECORDS
h i
EXCLUSIVE WITH MASS-UPDATE
where nominal-key-clause is
where organization-clause is
INDEXED
"( ) #
ORGANIZATION LINE SEQUENTIAL
IS
ORGANISATION RECORD BINARY SEQUENTIAL
RELATIVE
where padding-character-clause is
( )
identifier-14
PADDING CHARACTER IS
literal-5
where password-clause is
PASSWORD IS identifier-15
where record-delimiter-clause is
STANDARD-1
RECORD DELIMITER IS LINE-SEQUENTIAL
BINARY-SEQUENTIAL
where record-key-clause is
"( ) #
= n o
RECORD KEY IS identifier-16 identifier-17 . . .
SOURCE IS
h i
PASSWORD IS identifier-18
h h i i
WITH NO DUPLICATES
where relative-key-clause is
70
6. Environment division
where reserve-clause is
( )" #
NO AREA
RESERVE
integer-1 AREAS
where sharing-clause is
ALL OTHER
SHARING WITH NO OTHER
READ ONLY
where track-area-clause is
( )
identifier-20
TRACK-AREA IS CHARACTERS
literal-6
where track-area-clause is
( )
TRACK
TRACK-LIMIT IS integer-2
TRACKS
Syntax rules
General rules
71
6. Environment division
Syntax rules
General rules
72
7. Data division
h i
DATA DIVISION.
h i
file-section
h i
working-storage-section
h i
communication-section
h i
local-storage-section
h i
report-section
h i
screen-section
Syntax rules
General rules
74
7. Data division
Syntax rules
General rules
block-clause
h n o i
CODE-SET IS alphabet-name-1 FOR identifier-1 . . .
( )" #
DATA RECORD IS
n o
identifier-2 . . .
RECORDS ARE
IS EXTERNAL
IS GLOBAL
( )" #( )
LABEL RECORD IS STANDARD
RECORDS ARE OMITTED
linage-clause
( )
F
( )
FD
file-name-1 . . . .
FIXED
SD
( )
V
RECORDING MODE IS
VARIABLE
U
S
( )
REPORT IS n o
identifier-3 . . .
REPORTS ARE
FILE-ID ( )
literal-1
VALUE OF ID IS
identifier-5
identifier-4
record-clause
Syntax rules
General rules
75
7. Data division
WORKING-STORAGE
" # SECTION.
constant-definition
...
record-description
Syntax rules
General rules
76
7. Data division
Format 2 (output)
CD
entry-name FOR OUTPUT
DESTINATION COUNT IS identifier-23
TEXT LENGTH IS identifier-24
STATUS KEY IS identifier-25
h n o i
DESTINATION TABLE OCCURS integer-1 TIMES INDEXED BY index-name-1 . . . .
ERROR KEY IS identifier-26
DESTINATION IS identifier-27
SYMBOLIC DESTINATION IS identifier-28
77
7. Data division
Format 3 (I-O)
78
7. Data division
LOCAL-STORAGE
" SECTION.
#
constant-definition
...
record-description
Syntax rules
General rules
79
7. Data division
LINKAGE SECTION. #
"
constant-definition
...
record-description
Syntax rules
General rules
80
7. Data division
REPORT
" SECTION. #
constant-definition
...
report-description
Syntax rules
General rules
RD report-name-1
IS GLOBAL
( )
identifier-1
WITH CODE IS
literal-1
... .
( n o
identifier-2 . . .
) " #
CONTROL IS
h i
CONTROLS ARE FINAL identifier-3 . . .
page-limits-clause
n o
report-group-description-1 . . .
where page-limits-clause is
81
7. Data division
" #" #( )( )
LIMIT IS integer-1 LINE
PAGE
LIMITS ARE identifier-4 LINES
"( )( )#
integer-2 COLUMNS
identifier-5 COLS
( )
integer-3
HEADING IS
identifier-6
( ) ( )
DETAIL integer-4
FIRST IS
DE identifier-7
( ) ( )
CONTROL HEADING integer-5
LAST IS
CH identifier-8
...
( ) ( )
DETAIL integer-6
LAST IS
DE identifier-9
( )
integer-7
FOOTING IS
identifier-10
( )
integer-8
LINE LIMIT IS
identifier-11
where report-group-description is
blank-clause
column-clause
GROUP INDICATE
justified-clause
line-clause
next-group-clause
picture-clause
present-when-clause
level-number entry-name
. . . .
occurs-clause
sign-clause
source-clause
sum-clause
type-clause
USAGE IS DISPLAY
value-clause
varying-clause
82
7. Data division
Syntax rules
General rules
83
7. Data division
84
7. Data division
85
7. Data division
Syntax rules
General rules
h h i i
level-number entry-name control-definition control-attributes . . .
appearance-attribute-clauses
AUTO
AUTO-SKIP
AUTOTERMINATE
column-clause
ccol-clause
cline-clause
csize-clause
EOL
EOS
ERASE
( )
h
TO END OF
i LINE
SCREEN
( )
FULL
LENGTH-CHECK
IS GLOBAL
GRID
. . . .
INITIAL
LEFTLINE
justified-clause
line-clause
NO-ECHO
NO ECHO
OFF
occurs-clause
picture-clause
( )
REQUIRED
EMPTY-CHECK
source-destination-clauses
SECURE
sign-clause
size-clause
usage-clause
value-clause
86
7. Data division
where appearance-attribute-clauses is
87
7. Data division
"( ) ( )#
BACKGROUND-COLOR identifier-1
IS
BACKGROUND-COLOUR integer-1
" #
BELL
BEEP
( )
LINE
BLANK
SCREEN
( )
BLINK
BLINKING
( ) ( )
COLOR identifier-2
WITH IS
COLOUR integer-2
"( ) ( )#
FOREGROUND-COLOR identifier-3
IS
FOREGROUND-COLOUR integer-3
HIGHLIGHT
HIGH
BOLD
LOWLIGHT
LOW
h i
WITH STANDARD
h i
WITH BACKGROUND-HIGH
h i
WITH BACKGROUND-STANDARD
h i
WITH BACKGROUND-LOW
h i
OVERLINE
REVERSE-VIDEO
88
REVERSED
REVERSE
" #
UNDERLINE
UNDERLINED
7. Data division
where source-destination-clauses is
" ( )#
identifier-5
FROM
literal-2
h i
TO identifier-6
h i
USING identifier-7
Syntax rules
General rules
89
7. Data division
level-number
( entry-name
)
LENGTH
ANY
NUMERIC
blank-when-zero-clause
h i
IS EXTERNAL AS literal-1
IS EXTERNAL-FORM
( )
IS IDENTIFIED BY identifier-1
literal-2
IS GLOBAL
justified-clause
h i
LIKE identifier-2 ( literal-3 )
occurs-clause
. . . .
( )
PICTURE
h h i i
IS picture-string-1 LOCALE IS locale-name-1 SIZE IS integer-1
PIC
REDEFINES identifier-3
SAME AS identifier-4
sign-clause
special-names-clause
h i
IS TYPEDEF STRONG
SYNCHRONIZED
" #
LEFT
TYPE TO type-name-1 SYNCHRONISED
RIGHT
SYNC
usage-clause
value-clause
Format 2 (renames)
"( ) #
THROUGH
66 identifier-5 RENAMES identifier-6 identifier-7 .
THRU
90
7. Data division
Format 3 (condition-name)
( )" #( "( ) #)
VALUE IS THROUGH
88 identifier-8 literal-4 literal-5 ...
VALUES ARE THRU
h i
WHEN SET TO FALSE IS literal-6 .
Syntax rules
General rules
91
7. Data division
literal-1
( )
( )
1 h AS
i BYTE-LENGTH
identifier-1 CONSTANT IS GLOBAL OF identifier-2 .
01 LENGTH
FROM identifier-3
Format 2 (micro-focus)
( )" # literal-2
VALUE IS
h i
78 identifier-4 IS GLOBAL START OF identifier-5 .
VALUES ARE
NEXT
Syntax rules
General rules
92
7. Data division
Syntax rules
General rules
93
7. Data division
AUTO
AUTO-SKIP
AUTOTERMINATE
Syntax rules
General rules
94
7. Data division
Syntax rules
General rules
95
7. Data division
BACKGROUND-HIGH
Syntax rules
General rules
96
7. Data division
BACKGROUND-LOW
Syntax rules
General rules
97
7. Data division
BACKGROUND-STANDARD
Syntax rules
General rules
98
7. Data division
Syntax rules
General rules
99
7. Data division
Syntax rules
General rules
100
7. Data division
ZERO
BLANK WHEN ZEROES
ZEROS
Syntax rules
General rules
101
7. Data division
Syntax rules
General rules
102
7. Data division
Syntax rules
General rules
103
7. Data division
Syntax rules
General rules
104
7. Data division
Format 1 (report-section)
COLUMN
# LEFT
# h i
PLUS integer-1
" "
COLUMNS NUMBER
IS
RIGHT
n o
COL NUMBERS ARE integer-2 . . .
CENTER
COLS
Format 2 (screen-section)
COLUMN +
( )
COL
- identifier-1
NUMBER IS
POSITION PLUS integer-3
POS MINUS
Syntax rules
General rules
105
7. Data division
+
( )
- identifier-1
CCOL NUMBER IS
PLUS integer-1
MINUS
Syntax rules
General rules
106
7. Data division
+
( )
- identifier-1
CLINE NUMBER IS
PLUS integer-1
MINUS
Syntax rules
General rules
107
7. Data division
Syntax rules
General rules
108
7. Data division
Syntax rules
General rules
109
7. Data division
DESTINATION IS identifier-1
Syntax rules
General rules
110
7. Data division
Syntax rules
General rules
111
7. Data division
Syntax rules
General rules
112
7. Data division
Syntax rules
General rules
113
7. Data division
Syntax rules
General rules
114
7. Data division
EOL
EOS
ERASE h (
i LINE
)
TO END OF
SCREEN
Syntax rules
General rules
115
7. Data division
Syntax rules
General rules
116
7. Data division
Syntax rules
General rules
117
7. Data division
IS EXTERNAL-FORM
( )
identifier-1
IS IDENTIFIED BY
literal-1
Syntax rules
General rules
118
7. Data division
Syntax rules
General rules
119
7. Data division
Syntax rules
General rules
120
7. Data division
Syntax rules
General rules
121
7. Data division
Syntax rules
General rules
122
7. Data division
GRID
Syntax rules
General rules
123
7. Data division
HIGHLIGHT
HIGH
BOLD
Syntax rules
General rules
124
7. Data division
Syntax rules
General rules
125
7. Data division
Syntax rules
General rules
126
7. Data division
Syntax rules
General rules
127
7. Data division
LEFTLINE
Syntax rules
General rules
128
7. Data division
7.10.37. Level-number
A 1- or 2-digit integer having a value that is either between 1 and 49 or is 66, 77, 78 or
88.
Syntax rules
General rules
129
7. Data division
Syntax rules
General rules
130
7. Data division
Syntax rules
General rules
131
7. Data division
+
( )
- identifier-1
LINE NUMBER IS
MINUS integer-2
PLUS
" #( )" #
IS identifier-2 CELL
LINES
= integer-3 PIXEL
Syntax rules
General rules
132
7. Data division
Syntax rules
General rules
133
7. Data division
Syntax rules
General rules
134
7. Data division
Syntax rules
General rules
135
7. Data division
Syntax rules
General rules
136
7. Data division
Syntax rules
General rules
137
7. Data division
Syntax rules
General rules
138
7. Data division
Format 1 (usual)
OCCURS
h i h i
integer-1 TO integer-2 TIMES DEPENDING ON identifier-1
h ih ih ih i
DYNAMIC CAPACITY IN identifier-2 FROM integer-3 TO integer-4 INITIALIZED
(( ) )
ASCENDING n o
KEY IS identifier-3 . . . . . .
DESCENDING
n o
INDEXED BY index-name-1 . . .
h i h ih i
OCCURS integer-5 TO integer-6 TIMES DEPENDING ON identifier-4 STEP integer-7
Format 4 (unbounded)
h i
OCCURS integer-9 TO UNBOUNDED TIMES DEPENDING ON identifier-5
(( ) )
ASCENDING n o
KEY IS identifier-6 . . . . . .
DESCENDING
n o
INDEXED BY index-name-2 . . .
139
7. Data division
Syntax rules
General rules
140
7. Data division
OVERLINE
Syntax rules
General rules
141
7. Data division
Syntax rules
General rules
142
7. Data division
WHEN condition-1
PAGE
( )
BEFORE NEW
)
identifier-1 . . .
(
PRESENT AFTER
ABSENT OR
( )( )
JUSTIFIED BEFORE
NEW PAGE
JUST AFTER
Syntax rules
General rules
143
7. Data division
Syntax rules
General rules
144
7. Data division
Syntax rules
General rules
145
7. Data division
Syntax rules
General rules
146
7. Data division
Syntax rules
General rules
147
7. Data division
Syntax rules
General rules
148
7. Data division
Syntax rules
General rules
149
7. Data division
REVERSE-VIDEO
REVERSED
REVERSE
Syntax rules
General rules
150
7. Data division
Syntax rules
General rules
151
7. Data division
Syntax rules
General rules
152
7. Data division
Syntax rules
General rules
153
7. Data division
Syntax rules
General rules
154
7. Data division
Syntax rules
General rules
155
7. Data division
Syntax rules
General rules
156
7. Data division
CURSOR
IS SPECIAL-NAMES SCREEN CONTROL
EVENT STATUS
Syntax rules
General rules
157
7. Data division
Syntax rules
General rules
158
7. Data division
Syntax rules
General rules
159
7. Data division
Syntax rules
General rules
160
7. Data division
Syntax rules
General rules
161
7. Data division
Syntax rules
General rules
162
7. Data division
Syntax rules
General rules
163
7. Data division
Syntax rules
General rules
164
7. Data division
Syntax rules
General rules
165
7. Data division
Syntax rules
General rules
166
7. Data division
SYNCHRONIZED
" #
LEFT
SYNCHRONISED
RIGHT
SYNC
Syntax rules
General rules
167
7. Data division
Syntax rules
General rules
168
7. Data division
7.10.76. TO clause
TO identifier-1
Syntax rules
General rules
169
7. Data division
Format 1 (type-name)
TYPE TO type-name-1
Format 2 (report-group)
( )" #( )
CONTROL HEADING ON identifier-1 h i
OR PAGE
CH FOR FINAL
( )
identifier-2
h i
( ) " #
CONTROL FOOTING ON OR PAGE
FINAL
CF FOR
ALL
( )
DETAIL
DE
( )
TYPE IS PAGE FOOTING
PF
( )
PAGE HEADING
PH
( )
REPORT FOOTING
RF
( )
REPORT HEADING
RH
Syntax rules
General rules
TYPEDEF clause
h i
IS TYPEDEF STRONG
170
7. Data division
Syntax rules
General rules
171
7. Data division
Syntax rules
General rules
172
7. Data division
where fixed-length-integers is
BINARY-CHAR
BINARY-SHORT
( )
BINARY-LONG
" #
SIGNED
BINARY-INT
UNSIGNED
BINARY-C-LONG
( )
BINARY-DOUBLE
BINARY-LONG-LONG
SIGNED-SHORT
SIGNED-INT
SIGNED-LONG
UNSIGNED-SHORT
UNSIGNED-INT
UNSIGNED-LONG
173
7. Data division
where computation-usages is
( )
COMP
COMPUTATIONAL
( )
COMP-0
COMPUTATIONAL-0
( )
COMP-1
COMPUTATIONAL-1
( )
COMP-2
COMPUTATIONAL-2
( )
COMP-3
COMPUTATIONAL-3
( )
COMP-4
COMPUTATIONAL-4
( )
COMP-5
COMPUTATIONAL-5
( )
COMP-6
COMPUTATIONAL-6
( )
COMP-N
COMPUTATIONAL-N
( )
COMP-X
COMPUTATIONAL-X
where handle-usages is
174
7. Data division
DEFAULT-FONT
FIXED-FONT
TRADITIONAL-FONT
FONT
SMALL-FONT
MEDIUM-FONT
LARGE-FONT
OF
HANDLE h i
LAYOUT-MANAGER LM-RESIZE
MENU
SUBWINDOW
THREAD
VARIANT
WINDOW
Syntax rules
General rules
175
7. Data division
Syntax rules
General rules
176
7. Data division
Format 1 (initialization)
( )" #
VALUE IS
literal-1
VALUES ARE
Format 2 (condition)
( )" #( "( ) #)
VALUE IS THROUGH
literal-2 literal-3 ...
VALUES ARE THRU
h i
WHEN SET TO FALSE IS literal-4
Syntax rules
General rules
177
7. Data division
Syntax rules
General rules
178
7. Data division
Syntax rules
General rules
179
7. Data division
VOLATILE
Syntax rules
General rules
180
8. Procedure division
8.1. Concepts
8.1.1. Exceptions
• EC-ALL
• EC-ARGUMENT
– EC-ARGUMENT-FUNCTION
– EC-ARGUMENT-IMP
• EC-BOUND
– EC-BOUND-IMP
– EC-BOUND-ODO
– EC-BOUND-OVERFLOW
– EC-BOUND-PTR
– EC-BOUND-REF-MOD
– EC-BOUND-SET
– EC-BOUND-SUBSCRIPT
– EC-BOUND-TABLE-LIMIT
• EC-DATA
– EC-DATA-CONVERSION
– EC-DATA-IMP
– EC-DATA-INCOMPATIBLE
– EC-DATA-OVERFLOW
– EC-DATA-PTR-NULL
• EC-FLOW
– EC-FLOW-GLOBAL-EXIT
– EC-FLOW-GLOBAL-GOBACK
– EC-FLOW-IMP
– EC-FLOW-RELEASE
182
8. Procedure division
– EC-FLOW-REPORT
– EC-FLOW-RETURN
– EC-FLOW-SEARCH
– EC-FLOW-USE
• EC-FUNCTION
– EC-FUNCTION-PTR-INVALID
– EC-FUNCTION-PTR-NULL
• EC-I-O
– EC-I-O-AT-END
– EC-I-O-EOP
– EC-I-O-EOP-OVERFLOW
– EC-I-O-FILE-SHARING
– EC-I-O-IMP
– EC-I-O-INVALID-KEY
– EC-I-O-LINAGE
– EC-I-O-LOGIC-ERROR
– EC-I-O-PERMANENT-ERROR
– EC-I-O-RECORD-OPERATION
• EC-IMP
– EC-IMP-ACCEPT
– EC-IMP-DISPLAY
– EC-IMP-FEATURE-DISABLED
– EC-IMP-FEATURE-MISSING
– EC-IMP-UTC-UNKNOWN
• EC-JSON
– EC-JSON-IMP
• EC-LOCALE
– EC-LOCALE-IMP
– EC-LOCALE-INCOMPATIBLE
– EC-LOCALE-INVALID
– EC-LOCALE-INVALID-PTR
– EC-LOCALE-MISSING
183
8. Procedure division
– EC-LOCALE-SIZE
• EC-OO
– EC-OO-CONFORMANCE
– EC-OO-EXCEPTION
– EC-OO-FINALIZABLE
– EC-OO-IMP
– EC-OO-METHOD
– EC-OO-NULL
– EC-OO-RESOURCE
– EC-OO-UNIVERSAL
• EC-ORDER
– EC-ORDER-IMP
– EC-ORDER-NOT-SUPPORTED
• EC-OVERFLOW
– EC-OVERFLOW-IMP
– EC-OVERFLOW-STRING
– EC-OVERFLOW-UNSTRING
• EC-PROGRAM
– EC-PROGRAM-ARG-MISMATCH
– EC-PROGRAM-ARG-OMITTED
– EC-PROGRAM-CANCEL-ACTIVE
– EC-PROGRAM-IMP
– EC-PROGRAM-NOT-FOUND
– EC-PROGRAM-PTR-NULL
– EC-PROGRAM-RECURSIVE-CALL
– EC-PROGRAM-RESOURCES
• EC-RAISING
– EC-RAISING-IMP
– EC-RAISING-NOT-SPECIFIED
• EC-RANGE
– EC-RANGE-IMP
– EC-RANGE-INDEX
184
8. Procedure division
– EC-RANGE-INSPECT-SIZE
– EC-RANGE-INVALID
– EC-RANGE-PERFORM-VARYING
– EC-RANGE-PTR
– EC-RANGE-SEARCH-INDEX
– EC-RANGE-SEARCH-NO-MATCH
• EC-REPORT
– EC-REPORT-ACTIVE
– EC-REPORT-COLUMN-OVERLAP
– EC-REPORT-FILE-MODE
– EC-REPORT-IMP
– EC-REPORT-INACTIVE
– EC-REPORT-LINE-OVERLAP
– EC-REPORT-NOT-TERMINATED
– EC-REPORT-PAGE-LIMIT
– EC-REPORT-PAGE-WIDTH
– EC-REPORT-SUM-SIZE
– EC-REPORT-VARYING
• EC-SCREEN
– EC-SCREEN-FIELD-OVERLAP
– EC-SCREEN-IMP
– EC-SCREEN-ITEM-TRUNCATED
– EC-SCREEN-LINE-NUMBER
– EC-SCREEN-STARTING-COLUMN
• EC-SIZE
– EC-SIZE-ADDRESS
– EC-SIZE-EXPONENTIATION
– EC-SIZE-IMP
– EC-SIZE-OVERFLOW
– EC-SIZE-TRUNCATION
– EC-SIZE-UNDERFLOW
– EC-SIZE-ZERO-DIVIDE
185
8. Procedure division
• EC-SORT-MERGE
– EC-SORT-MERGE-ACTIVE
– EC-SORT-MERGE-FILE-OPEN
– EC-SORT-MERGE-IMP
– EC-SORT-MERGE-RELEASE
– EC-SORT-MERGE-RETURN
– EC-SORT-MERGE-SEQUENCE
• EC-STORAGE
– EC-STORAGE-IMP
– EC-STORAGE-NOT-ALLOC
– EC-STORAGE-NOT-AVAIL
• EC-USER
• EC-VALIDATE
– EC-VALIDATE-CONTENT
– EC-VALIDATE-FORMAT
– EC-VALIDATE-IMP
– EC-VALIDATE-RELATION
– EC-VALIDATE-VARYING
• EC-XML
– EC-XML-CODESET
– EC-XML-CODESET-CONVERSION
– EC-XML-COUNT
– EC-XML-DOCUMENT-TYPE
– EC-XML-IMPLICIT-CLOSE
– EC-XML-INVALID
– EC-XML-NAMESPACE
– EC-XML-STACKED-OPEN
– EC-XML-RANGE
186
8. Procedure division
paragraph-name-2. ...
imperative-statement-1 .
where using-chaining-clause is
( )
USING
CHAINING
( ( ) )
REFERENCE h i h i h i
BY param-size OPTIONAL identifier-2 memory-size ...
VALUE
where param-size is
( )
AUTO
h i
UNSIGNED SIZE IS
integer-1
SIZE IS DEFAULT
where memory-size is
" #
identifier-3
WITH MEMORY SIZE IS
literal-1
where declaratives is
DECLARATIVES.
" " # #
paragraph-name-2.
section-name-1 SECTION. use-statement ... ...
imperative-statement-2 .
END DECLARATIVES.
Syntax rules
General rules
187
8. Procedure division
C
EXTERN
PASCAL
STATIC
STDCALL
mnemonic-name-1
Syntax rules
General rules
188
8. Procedure division
C
STDCALL
Syntax rules
General rules
189
8. Procedure division
Syntax rules
General rules
190
8. Procedure division
Syntax rules
General rules
191
8. Procedure division
Syntax rules
General rules
192
8. Procedure division
Format 1 (device)
( )
identifier-1 h ih i
ACCEPT FROM mnemonic-name-1 END-ACCEPT
OMITTED
Format 2 (screen)
193
8. Procedure division
h i
position-specifier identifier-2
ACCEPT
OMITTED
( )
identifier-3
AT LINE NUMBER
integer-1
COLUMN
( )
COL identifier-4
AT POSITION NUMBER integer-2
POS
( )
identifier-5
AT
integer-3
FROM CRT
MODE IS BLOCK
accept-appearance-attribute-clauses
accept-attribute-clauses
( )
EXCEPTION h i
ON identifier-6 imperative-statement-1
ESCAPE
( )
EXCEPTION h i
NOT ON identifier-7 imperative-statement-2
ESCAPE
h i
END-ACCEPT
where position-specifier is
( position-specifier-num , position-specifier-num )
( , position-specifier-num )
( position-specifier-num , )
where position-specifier-num is
( ) "( ) #
identifier-8 +
literal-2
literal-1 -
where accept-appearance-attribute-clauses is
194
8. Procedure division
( )
h i BELL
WITH NO
BEEP
( )
BLINK
WITH
BLINKING
HIGHLIGHT
HIGH
WITH BOLD
LOWLIGHT
LOW
WITH STANDARD
WITH BACKGROUND-HIGH
WITH BACKGROUND-STANDARD
WITH BACKGROUND-LOW
WITH LEFTLINE
WITH OVERLINE" ( )#
identifier-9
WITH PROMPT CHARACTER IS
literal-3
REVERSE-VIDEO
WITH REVERSED
REVERSE
WITH SAME
( )
identifier-10
WITH PROTECTED SIZE IS
integer-4
( )
UNDERLINE
WITH
UNDERLINED
( ) ( )
FOREGROUND-COLOR identifier-11
WITH IS
FOREGROUND-COLOUR integer-5
( ) ( )
BACKGROUND-COLOR identifier-12
WITH IS
BACKGROUND-COLOUR integer-6
( ) ( )
COLOR identifier-13
WITH IS
COLOUR integer-7
( ) "( )( )#
UP identifier-14 LINE
WITH SCROLL
DOWN integer-8 LINES
where accept-attribute-clauses is
195
8. Procedure division
( )
AUTO
WITH
TAB
Format 3 (temporal)
h i
DATE YYYYMMDD
h i
DAY YYYYDDD
ACCEPT identifier-17 FROM
DAY-OF-WEEK
TIME
Format 4 (environment)
196
8. Procedure division
ARGUMENT-NUMBER
( )
COLUMNS
COLS
COMMAND-LINE
ESCAPE KEY
EXCEPTION STATUS
ACCEPT identifier-18 FROM ( INPUT STATUS
)
LINES
LINE NUMBER
TERMINAL-INFO
SYSTEM-INFO
USER NAME
WORD
Format 5 (environment-exception)
ARGUMENT-VALUE
( )
identifier-20
ACCEPT identifier-19 FROM ENVIRONMENT
literal-5
ENVIRONMENT-VALUE
( )
EXCEPTION h i
ON identifier-21 imperative-statement-3
ESCAPE
( )
EXCEPTION h i
NOT ON identifier-22 imperative-statement-4
ESCAPE
Format 6 (message)
197
8. Procedure division
( )
identifier-24
AT LINE NUMBER
integer-10
COLUMN
( )
COL identifier-25
AT NUMBER
POSITION integer-11
ACCEPT identifier-23 FROM SCREEN ...
POS
( )
identifier-26
AT
integer-12
( )
identifier-27
SIZE IS
literal-6
Syntax rules
Format 2
1. Position specifiers may not be used with any of the ON EXCEPTION clauses.
General rules
198
8. Procedure division
Format 1 (simple)
( )
identifier-1 n o
ADD . . . TO identifier-2 . . .
literal-1
" #
ON SIZE ERROR imperative-statement-1
NOT ON SIZE ERROR imperative-statement-2
h i
END-ADD
Format 2 (giving)
( )
identifier-3 h h i i
ADD . . . TO identifier-4 . . .
literal-2
n h io
GIVING identifier-5 rounded-phrase . . .
" #
ON SIZE ERROR imperative-statement-3
NOT ON SIZE ERROR imperative-statement-4
h i
END-ADD
Format 3 (corresponding)
199
8. Procedure division
( )
CORRESPONDING h i
ADD identifier-6 TO identifier-7 rounded-phrase
CORR
" #
ON SIZE ERROR imperative-statement-5
NOT ON SIZE ERROR imperative-statement-6
h i
END-ADD
Format 4 (table)
h i
ADD TABLE identifier-8 TO identifier-9 rounded-phrase
h i
FROM INDEX integer-1 TO integer-2
h i
DESTINATION INDEX integer-3
" #
ON SIZE ERROR imperative-statement-7
NOT ON SIZE ERROR imperative-statement-8
h i
END-ADD
Syntax rules
General rules
200
8. Procedure division
" ( )#
24
LOC
31
h i
RETURNING identifier-3
Syntax rules
General rules
201
8. Procedure division
Syntax rules
General rules
202
8. Procedure division
identifier-1
literal-1
function-name-1
identifier-2
( )
NESTED
AS
literal-2
program-prototype-name
function-name-2
h i
HANDLE IN identifier-3
OMITTED
REFERENCE
(
)
USING BY CONTENT identifier-4 ...
h i
size-phrase
VALUE literal-3
INTO identifier-5
ADDRESS OF identifier-6
(
)
RETURNING
NOTHING
GIVING
NULL
OMITTED
( )
ON EXCEPTION imperative-statement-1
OVERFLOW
NOT ON EXCEPTION imperative-statement-2
h i
END-CALL
Syntax rules
General rules
203
8. Procedure division
Syntax rules
General rules
204
8. Procedure division
Format 1 (file)
( )
REEL h
i
FOR REMOVAL
UNIT
CLOSE file-name-1 ...
WITH NO REWIND
WITH LOCK
Format 2 (window)
h i
CLOSE WINDOW identifier-1 WITH NO DISPLAY
Syntax rules
General rules
205
8. Procedure division
Syntax rules
General rules
206
8. Procedure division
" #
ON SIZE ERROR imperative-statement-1
NOT ON SIZE ERROR imperative-statement-2
h i
END-COMPUTE
Syntax rules
General rules
207
8. Procedure division
Format 1 (plain)
CONTINUE
Format 2 (after)
Syntax rules
General rules
208
8. Procedure division
Format 1 (record)
h i
END-DELETE
Format 2 (file)
n o
DELETE FILE file-name-2 . . .
" #
ON EXCEPTION imperative-statement-3
NOT ON EXCEPTION imperative-statement-4
h i
END-DELETE
Syntax rules
General rules
209
8. Procedure division
Syntax rules
General rules
210
8. Procedure division
INPUT TERMINAL
" ( )#
OUTPUT identifier-1
DISABLE cd-name-1 WITH KEY
I-O TERMINAL literal-1
TERMINAL
Syntax rules
General rules
211
8. Procedure division
Format 1 (device)
( ) " #
identifier-1 UPON mnemonic-name-1
DISPLAY ...
literal-1 WITH NO ADVANCING
" #
ON EXCEPTION imperative-statement-1
NOT ON EXCEPTION imperative-statement-2
h i
END-DISPLAY
Format 2 (environment)
ARGUMENT-NUMBER
( )
identifier-2 COMMAND-LINE
DISPLAY UPON
literal-2
ENVIRONMENT-NAME
ENVIRONMENT-VALUE
" #
ON EXCEPTION imperative-statement-3
NOT ON EXCEPTION imperative-statement-4
h i
END-DISPLAY
Format 3 (screen)
212
8. Procedure division
position-clauses
( )
identifier-3 CRT
UPON
DISPLAY literal-3
CRT-UNDER . . .
OMITTED
MODE IS BLOCK
display-appearance-attribute-clauses
" #
ON EXCEPTION imperative-statement-5
NOT ON EXCEPTION imperative-statement-6
h i
END-DISPLAY
ERASE
identifier-4
DISPLAY
disp-position-specifier literal-4 ...
ERASE
h n o i
WITH display-appearance-attribute-clauses . . .
h i
END-DISPLAY
213
8. Procedure division
( )
WINDOW h i
DISPLAY UPON identifier-5
SUBWINDOW
h i
END-DISPLAY
h i h i
DISPLAY FLOATING GRAPHICAL WINDOW UPON identifier-9
h i
END-DISPLAY
214
8. Procedure division
INITIAL
h i h i
DISPLAY STANDARD GRAPHICAL WINDOW UPON identifier-13
INDEPENDENT
h i
END-DISPLAY
215
8. Procedure division
( )
identifier-17
DISPLAY MESSAGE BOX ...
literal-8
" #( )
IS identifier-18
TITLE
= literal-9
" #( )
IS identifier-19
TYPE
= literal-10
" #( )
IS identifier-20
ICON . . .
= literal-11
" #( )
IS identifier-21
DEFAULT
= literal-12
( )( )
RETURNING identifier-22
GIVING literal-13
h i
END-DISPLAY
where position-clauses is
( )
identifier-23
LINE NUMBER
literal-14
COLUMN
( )
COL identifier-24
AT NUMBER
POSITION
literal-15
POS
( )
identifier-25
AT
literal-16
where display-appearance-attribute-clauses is
216
8. Procedure division
( )
BELL
WITH
BEEP
( )
LINE
WITH BLANK
SCREEN
( )
BLINK
WITH
BLINKING
( )
CONVERSION
WITH
CONVERT
EOL
EOS
WITH ERASE h (
i LINE
)
TO END OF
SCREEN
HIGHLIGHT
HIGH
WITH BOLD
LOWLIGHT
LOW
WITH STANDARD
WITH BACKGROUND-HIGH
WITH BACKGROUND-STANDARD
WITH BACKGROUND-LOW
WITH OVERLINE
REVERSE-VIDEO
WITH REVERSED
REVERSE
WITH SAME
( )
identifier-26
WITH SIZE IS
literal-17
( )
UNDERLINE
WITH
UNDERLINED
( )" #( )
FOREGROUND-COLOR IS identifier-27
WITH
FOREGROUND-COLOUR = integer-4
( )" #( )
BACKGROUND-COLOR IS identifier-28
WITH
BACKGROUND-COLOUR = integer-5
( ) ( )
COLOR identifier-29
WITH IS
COLOUR integer-6
( ) "( )( )#
UP identifier-30 LINE
WITH SCROLL
DOWN integer-7 LINES
217
8. Procedure division
where disp-position-specifier is
( disp-position-specifier-num , disp-position-specifier-num )
( , disp-position-specifier-num )
( disp-position-specifier-num , )
where disp-position-specifier-num is
( ) "( ) #
identifier-31 +
literal-19
literal-18 -
Syntax rules
General rules
218
8. Procedure division
Format 1 (into)
( ) (( ) )
identifier-1 identifier-2 h i
DIVIDE INTO rounded-phrase ...
literal-1 literal-2
" #
ON SIZE ERROR imperative-statement-1
NOT ON SIZE ERROR imperative-statement-2
h i
END-DIVIDE
Format 2 (giving)
( )( )( )
identifier-3 BY identifier-4
DIVIDE
literal-3 INTO literal-4
(( ) )
identifier-5 h i
GIVING rounded-phrase ...
literal-5
" ( )#
identifier-6
REMAINDER
literal-6
" #
ON SIZE ERROR imperative-statement-3
NOT ON SIZE ERROR imperative-statement-4
h i
END-DIVIDE
Syntax rules
General rules
219
8. Procedure division
INPUT TERMINAL
" ( )#
OUTPUT identifier-1
ENABLE cd-name-1 WITH KEY
I-O TERMINAL literal-1
TERMINAL
Syntax rules
General rules
220
8. Procedure division
Format 1 (usual)
h i
ENTRY call-convention-phrase literal-1
h i
linkage-phrase
REFERENCE OMITTED
( ( ))
USING BY CONTENT identifier-1 ...
h i
size-phrase
VALUE literal-2
Syntax rules
General rules
221
8. Procedure division
FALSE FALSE
n h i o
WHEN selection-object ALSO selection-object . . . imperative-statement-1 . . .
h i
WHEN OTHER imperative-statement-2
h i
END-EVALUATE
where selection-object is
"( ) #
THROUGH
partial-expression-1 expression-3
THRU
ANY
TRUE
FALSE
Syntax rules
General rules
222
8. Procedure division
( )
literal-1
...
identifier-1
h i
UPON mnemonic-name-1
where exhibit-pos-spec is
( exhibit-pos-spec-num , exhibit-pos-spec-num )
( , exhibit-pos-spec-num )
( exhibit-pos-spec-num , )
where exhibit-pos-spec-num is
( ) "( ) #
identifier-2 +
literal-3
literal-2 -
Syntax rules
General rules
223
8. Procedure division
FUNCTION
PARAGRAPH
h i
PERFORM CYCLE
EXIT
"( )# ( )
RETURNING identifier-1
PROGRAM
GIVING literal-1
SECTION
Syntax rules
General rules
224
8. Procedure division
Syntax rules
General rules
225
8. Procedure division
Syntax rules
General rules
226
8. Procedure division
8.26. GO TO statement
The GO TO statement transfer execution to another part of the program.
( )
procedure-name-1 . . . h i
GO TO DEPENDING ON identifier-1
ENTRY entry-name . . .
Syntax rules
General rules
227
8. Procedure division
Syntax rules
General rules
228
8. Procedure division
8.28. IF statement
The IF statement evaluates a condition and executes statements depending on whether
the condition was true or false.
( )
imperative-statement-1
IF condition THEN ...
ELSE imperative-statement-2
h i
END-IF
Syntax rules
General rules
229
8. Procedure division
ALPHABETIC
ALPHANUMERIC
ALPHANUMERIC-EDITED
( )
identifier-2
REPLACING NATIONAL DATA BY . . .
literal-1
NATIONAL-EDITED
NUMERIC
NUMERIC-EDITED
h i
THEN TO DEFAULT
Syntax rules
General rules
230
8. Procedure division
Syntax rules
General rules
231
8. Procedure division
( ) (( )" # )
identifier-1 control-property IN
INQUIRE identifier-2 . . .
CONTROL LAYOUT-DATA =
Format 2 (window)
) LAYOUT-MANAGER " #
identifier-3h
(
IN
INQUIRE i SIZE identifier-5 . . .
WINDOW identifier-4 =
TITLE
Syntax rules
General rules
232
8. Procedure division
where tallying-phrase is
TALLYING
CHARACTERS
( )
identifier-2 ALL
( )
h i
FOR identifier-3 . . . before-after-phrase ...
literal-2 LEADING
literal-3
TRAILING
where replacing-phrase is
CHARACTERS
ALL
( )
identifier-5
( )
h i
REPLACING LEADING identifier-4 BY before-after-phrase ...
literal-5
FIRST literal-4
TRAILING
where converting-phrase is
( ) ( )
identifier-6 identifier-7 h i
CONVERTING TO before-after-phrase
literal-6 literal-7
where before-after-phrase is
( )
identifier-8
BEFORE INITIAL
literal-8
( )
identifier-9
AFTER INITIAL
literal-9
Syntax rules
General rules
233
8. Procedure division
h i
END-JSON
Syntax rules
General rules
234
8. Procedure division
h i
END-JSON
Syntax rules
General rules
235
8. Procedure division
h i
IS alphanumeric-collating-sequence national-collating-sequence
COLLATING SEQUENCE IS
( )
FOR ALPHANUMERIC IS alphanumeric-collating-sequence
FOR NATIONAL IS national-collating-sequence
h n o i
USING file-name-1 . . .
n o
GIVING file-name-2 . . .
"( ) #
THROUGH
OUTPUT PROCEDURE IS procedure-name-1 procedure-name-2
THRU
Syntax rules
General rules
236
8. Procedure division
( )
identifier-1 n o h i
MODIFY control-attributes . . . END-MODIFY
CONTROL
Format 2 (window)
) LAYOUT-MANAGER " #
identifier-2h
(
IN
h i
MODIFY i SIZE identifier-4 . . . END-MODIFY
WINDOW identifier-3 =
TITLE
Syntax rules
General rules
237
8. Procedure division
Syntax rules
General rules
238
8. Procedure division
Format 1 (simple)
( ) (( ) )
identifier-1 identifier-2 h i
MULTIPLY BY rounded-phrase ...
literal-1 literal-2
" #
ON SIZE ERROR imperative-statement-1
NOT ON SIZE ERROR imperative-statement-2
h i
END-MULTIPLY
Format 2 (giving)
( ) ( )
identifier-3 identifier-4
MULTIPLY BY
literal-3 literal-4
(( ) )
identifier-5 h i
GIVING rounded-phrase ...
literal-5
" #
ON SIZE ERROR imperative-statement-3
NOT ON SIZE ERROR imperative-statement-4
h i
END-MULTIPLY
Syntax rules
General rules
239
8. Procedure division
Syntax rules
General rules
240
8. Procedure division
where open-body is
INPUT
h i OUTPUT
h ih in o h i
EXCLUSIVE sharing-mode retry-phrase file-name-1 . . . open-options
I-O
EXTEND
where sharing-mode is
ALL OTHER
SHARING WITH NO OTHER
READ ONLY
where open-options is
# LOCK
"
FOR
MASS-UPDATE
WITH
BULK-ADDITION
ALL
READERS
"
#
WITH NO REWIND
ALLOWING UPDATERS
REVERSED
WRITERS
NO OTHERS
DISP
LEAVE
REREAD
Syntax rules
General rules
241
8. Procedure division
Format 1 (procedure)
"( ) #
h i THROUGH
PERFORM IN THREAD procedure-name-1 procedure-name-2
THRU
FOREVER
h i times-phrase
HANDLE IN identifier-1
until-phrase
varying-phrase
Format 2 (inline)
FOREVER
h i times-phrase h i
PERFORM IN THREAD HANDLE IN identifier-2
until-phrase
varying-phrase
imperative-statement-1
h i
END-PERFORM
where times-phrase is
identifier-3
literal-1 TIMES
function-name-1
where until-phrase is
" ( )# ( )
BEFORE condition-1
WITH TEST UNTIL
AFTER EXIT
242
8. Procedure division
" ( )#
BEFORE
WITH TEST
AFTER
( )" ( )#
identifier-5 identifier-6
VARYING identifier-4 FROM BY UNTIL condition-2
literal-2 literal-3
" ( )" ( )# #
identifier-8 identifier-9
AFTER identifier-7 FROM BY UNTIL condition-3 . . .
literal-4 literal-5
Syntax rules
General rules
243
8. Procedure division
Syntax rules
General rules
244
8. Procedure division
Syntax rules
General rules
245
8. Procedure division
h i
KEY IS identifier-2
( )
INVALID KEY imperative-statement-1
NOT INVALID KEY imperative-statement-2
( )
AT END imperative-statement-3
NOT AT END imperative-statement-4
h i
END-READ
Syntax rules
General rules
246
8. Procedure division
Syntax rules
General rules
247
8. Procedure division
" #
WITH DATA imperative-statement-1
NO DATA imperative-statement-2
h i
END-RECEIVE
Syntax rules
General rules
248
8. Procedure division
Syntax rules
General rules
249
8. Procedure division
Syntax rules
General rules
250
8. Procedure division
AT END imperative-statement-1
h i
NOT AT END imperative-statement-2
h i
END-RETURN
Syntax rules
General rules
251
8. Procedure division
h i
retry-phrase
h h i i
WITH NO LOCK
" #
INVALID KEY imperative-statement-1
NOT INVALID KEY imperative-statement-2
h i
END-REWRITE
Syntax rules
General rules
252
8. Procedure division
Syntax rules
General rules
253
8. Procedure division
Format 1 (simple)
h i
SEARCH identifier-1 VARYING identifier-2
h i
AT END imperative-statement-1
n o
WHEN condition-1 imperative-statement-2 . . .
h i
END-SEARCH
Format 2 (all)
Syntax rules
General rules
254
8. Procedure division
Format 1 (from)
identifier-3
h i ESI
SEND cd-name-2 FROM identifier-2 WITH
EMI
EGI
( )" #
identifier-4 LINE
( )
BEFORE literal-1
LINES
ADVANCING
AFTER mnemonic-name-1
PAGE
h i
REPLACING LINE
Syntax rules
General rules
255
8. Procedure division
Format 1 (simple)
identifier-2
SET identifier-1 TO literal-1
arithmetic-expression-1
Format 2 (entry)
( )
identifier-4
SET identifier-3 TO ENTRY
literal-2
Format 3 (environment)
( ) ( )
identifier-5 identifier-6
SET ENVIRONMENT TO
literal-3 literal-4
Format 4 (attribute)
( )
BELL
BEEP
BLINK
HIGHLIGHT
( )
ON
SET identifier-7 ATTRIBUTE LOWLIGHT ...
OFF
REVERSE-VIDEO
UNDERLINE
LEFTLINE
OVERLINE
256
8. Procedure division
Format 5 (arithmetic)
( )
n o UP
SET index-name-1 . . . BY arithmetic-expression-2
DOWN
Format 6 (on/off)
( ( ))
n o ON
SET mnemonic-name-1 . . . TO ...
OFF
Format 7 (true/false)
( ( ))
n o TRUE
SET condition-name-1 . . . TO ...
FALSE
Format 8 (exception)
Format 9 (thread)
( )
h i identifier-9
SET THREAD identifier-8 PRIORITY TO
integer-1
Format 10 (file-handler)
( )
n o FH--FCD
SET identifier-10 . . . TO ADDRESS OF OF file-name-1
FH--KEYDEF
257
8. Procedure division
Syntax rules
General rules
258
8. Procedure division
h i
IS alphanumeric-collating-sequence national-collating-sequence
COLLATING SEQUENCE IS
( )
FOR ALPHANUMERIC IS alphanumeric-collating-sequence
FOR NATIONAL IS national-collating-sequence
n o
USING file-name-1 . . .
"( ) #
THROUGH
INPUT PROCEDURE IS procedure-name-1 procedure-name-2
THRU
n o
GIVING file-name-2 . . .
"( ) #
THROUGH
OUTPUT PROCEDURE IS procedure-name-3 procedure-name-4
THRU
Syntax rules
General rules
259
8. Procedure division
Format 1 (file)
FIRST
LAST
" ( ) #
SIZE
WITH arithmetic-expression-1
LENGTH
" #
INVALID KEY imperative-statement-1
NOT INVALID KEY imperative-statement-2
h i
END-START
Format 2 (transaction)
START TRANSACTION
Syntax rules
General rules
260
8. Procedure division
Format 1 (standard)
( )( )
RETURNING identifier-1
GIVING literal-1
STOP RUN
( ) " #
ERROR identifier-2
WITH STATUS
NORMAL literal-2
Format 2 (literal)
STOP literal-3
Format 3 (identifier)
STOP identifier-3
Format 4 (ACUCOBOL)
( )
identifier-4
STOP RUN
literal-4
Format 5 (thread)
h i
STOP THREAD identifier-5
261
8. Procedure division
Syntax rules
General rules
262
8. Procedure division
h i
WITH POINTER IS identifier-4
" #
ON OVERFLOW imperative-statement-1
NOT ON OVERFLOW imperative-statement-2
h i
END-STRING
Syntax rules
General rules
263
8. Procedure division
Format 1 (simple)
( ) (( ) )
identifier-1 identifier-2 h i
SUBTRACT . . . FROM rounded-phrase ...
literal-1 literal-2
" #
ON SIZE ERROR imperative-statement-1
NOT ON SIZE ERROR imperative-statement-2
h i
END-SUBTRACT
Format 2 (giving)
( ) ( )
identifier-3 identifier-4
SUBTRACT . . . FROM
literal-3 literal-4
(( ) )
identifier-5 h i
GIVING rounded-phrase ...
literal-5
" #
ON SIZE ERROR imperative-statement-3
NOT ON SIZE ERROR imperative-statement-4
h i
END-SUBTRACT
Format 3 (corresponding)
264
8. Procedure division
( )
CORR h i
SUBTRACT identifier-6 FROM identifier-7 rounded-phrase
CORRESPONDING
" #
ON SIZE ERROR imperative-statement-5
NOT ON SIZE ERROR imperative-statement-6
h i
END-SUBTRACT
Format 4 (table)
h i
SUBTRACT TABLE identifier-8 TO identifier-9 rounded-phrase
h i
FROM INDEX integer-1 TO integer-2
h i
DESTINATION INDEX integer-3
" #
ON SIZE ERROR imperative-statement-7
NOT ON SIZE ERROR imperative-statement-8
h i
END-SUBTRACT
Syntax rules
General rules
265
8. Procedure division
Syntax rules
General rules
266
8. Procedure division
Syntax rules
General rules
267
8. Procedure division
Syntax rules
General rules
268
8. Procedure division
Syntax rules
General rules
269
8. Procedure division
h i
END-UNSTRING
Syntax rules
General rules
270
8. Procedure division
( )
h i EXCEPTION
USE GLOBAL AFTER STANDARD PROCEDURE ON
ERROR
INPUT
n o OUTPUT
file-name-1 . . . . . .
I-O
EXTEND
Format 2 (debugging)
procedure-name-1
USE FOR DEBUGGING ON ALL PROCEDURES ...
ALL REFERENCES OF identifier-1
Format 3 (start/end)
( )
START
USE AT PROGRAM
END
Format 4 (reporting)
h i
USE GLOBAL BEFORE REPORTING identifier-2
271
8. Procedure division
Format 5 (exception)
n h i o
USE EXCEPTION exception-name FILE file-name-2 . . . . . .
Syntax rules
General rules
272
8. Procedure division
Syntax rules
General rules
273
8. Procedure division
Format 1 (sequential)
identifier-1
record-name-1 FROM literal-1
function-name-1
WRITE
identifier-2
FILE file-name-1 FROM
literal-2
function-name-2
( )" #
identifier-3 LINE
( )
BEFORE literal-3
LINES
ADVANCING
AFTER mnemonic-name-1
PAGE
h i h h i i
retry-phrase WITH NO LOCK
( )
END-OF-PAGE
AT imperative-statement-1
EOP
( )
END-OF-PAGE
NOT AT imperative-statement-2
EOP
h i
END-WRITE
Format 2 (random)
274
8. Procedure division
identifier-4
record-name-2 FROM literal-4
function-name-3
WRITE
identifier-5
FILE file-name-2 FROM
literal-5
function-name-4
( )" #
identifier-6 LINE
( )
BEFORE literal-6
LINES
ADVANCING
AFTER mnemonic-name-2
PAGE
h i h h i i
retry-phrase WITH NO LOCK
" #
INVALID KEY imperative-statement-3
NOT INVALID KEY imperative-statement-4
h i
END-WRITE
Syntax rules
General rules
275
8. Procedure division
ATTRIBUTE
TYPE OF identifier-8 IS ELEMENT ...
CONTENT
identifier-9
ATTRIBUTE
( )
NUMERIC
ELEMENT
NONNUMERIC
CONTENT
SUPPRESS EVERY ...
ATTRIBUTE
ELEMENT
CONTENT
h i
WHEN
non-quote-alnum-fig-const OR . . . non-quote-alnum-fig-const
" #
ON EXCEPTION imperative-statement-1
NOT ON EXCEPTION imperative-statement-2
h i
END-XML
where non-quote-alnum-fig-const is
276
8. Procedure division
ZERO
ZEROES
ZEROS
SPACE
SPACES
HIGH-VALUE
HIGH-VALUES
LOW-VALUE
LOW-VALUES
Syntax rules
General rules
277
8. Procedure division
h i
END-XML
Syntax rules
General rules
278
9. Intrinsic functions
9.1. ABS function
( )
ABS
FUNCTION ( argument-1 )
ABSOLUTE-VALUE
Syntax rules
General rules
280
9. Intrinsic functions
Syntax rules
General rules
281
9. Intrinsic functions
Syntax rules
General rules
282
9. Intrinsic functions
Syntax rules
General rules
283
9. Intrinsic functions
Syntax rules
General rules
284
9. Intrinsic functions
Syntax rules
General rules
285
9. Intrinsic functions
Syntax rules
General rules
286
9. Intrinsic functions
Syntax rules
General rules
287
9. Intrinsic functions
Syntax rules
General rules
288
9. Intrinsic functions
Syntax rules
General rules
289
9. Intrinsic functions
Syntax rules
General rules
290
9. Intrinsic functions
Syntax rules
General rules
291
9. Intrinsic functions
Syntax rules
General rules
292
9. Intrinsic functions
Syntax rules
General rules
293
9. Intrinsic functions
Syntax rules
General rules
294
9. Intrinsic functions
Syntax rules
General rules
295
9. Intrinsic functions
Syntax rules
General rules
296
9. Intrinsic functions
Syntax rules
General rules
297
9. Intrinsic functions
Syntax rules
General rules
298
9. Intrinsic functions
Syntax rules
General rules
299
9. Intrinsic functions
Syntax rules
General rules
300
9. Intrinsic functions
9.22. E function
FUNCTION E
Syntax rules
General rules
301
9. Intrinsic functions
Syntax rules
General rules
302
9. Intrinsic functions
FUNCTION EXCEPTION-FILE-N
Syntax rules
General rules
303
9. Intrinsic functions
Syntax rules
General rules
304
9. Intrinsic functions
FUNCTION EXCEPTION-LOCATION-N
Syntax rules
General rules
305
9. Intrinsic functions
Syntax rules
General rules
306
9. Intrinsic functions
Syntax rules
General rules
307
9. Intrinsic functions
Syntax rules
General rules
308
9. Intrinsic functions
Syntax rules
General rules
309
9. Intrinsic functions
Syntax rules
General rules
310
9. Intrinsic functions
Syntax rules
General rules
311
9. Intrinsic functions
Syntax rules
General rules
312
9. Intrinsic functions
Syntax rules
General rules
313
9. Intrinsic functions
Syntax rules
General rules
314
9. Intrinsic functions
Syntax rules
General rules
315
9. Intrinsic functions
Syntax rules
General rules
316
9. Intrinsic functions
Syntax rules
General rules
317
9. Intrinsic functions
Syntax rules
General rules
318
9. Intrinsic functions
Syntax rules
General rules
319
9. Intrinsic functions
Syntax rules
General rules
320
9. Intrinsic functions
Syntax rules
General rules
321
9. Intrinsic functions
Syntax rules
General rules
322
9. Intrinsic functions
Syntax rules
General rules
323
9. Intrinsic functions
Syntax rules
General rules
324
9. Intrinsic functions
Syntax rules
General rules
325
9. Intrinsic functions
Syntax rules
General rules
326
9. Intrinsic functions
Syntax rules
General rules
327
9. Intrinsic functions
Syntax rules
General rules
328
9. Intrinsic functions
Syntax rules
General rules
329
9. Intrinsic functions
Syntax rules
General rules
330
9. Intrinsic functions
Syntax rules
General rules
331
9. Intrinsic functions
Syntax rules
General rules
332
9. Intrinsic functions
Syntax rules
General rules
333
9. Intrinsic functions
Syntax rules
General rules
334
9. Intrinsic functions
Syntax rules
General rules
335
9. Intrinsic functions
Syntax rules
General rules
336
9. Intrinsic functions
Syntax rules
General rules
337
9. Intrinsic functions
Syntax rules
General rules
338
9. Intrinsic functions
Syntax rules
General rules
339
9. Intrinsic functions
Syntax rules
General rules
340
9. Intrinsic functions
Syntax rules
General rules
341
9. Intrinsic functions
Syntax rules
General rules
342
9. Intrinsic functions
Syntax rules
General rules
343
9. Intrinsic functions
Syntax rules
General rules
344
9. Intrinsic functions
Syntax rules
General rules
345
9. Intrinsic functions
Syntax rules
General rules
346
9. Intrinsic functions
Syntax rules
General rules
347
9. Intrinsic functions
Syntax rules
General rules
348
9. Intrinsic functions
Syntax rules
General rules
349
9. Intrinsic functions
Syntax rules
General rules
350
9. Intrinsic functions
Syntax rules
General rules
351
9. Intrinsic functions
Syntax rules
General rules
352
9. Intrinsic functions
Syntax rules
General rules
353
9. Intrinsic functions
Syntax rules
General rules
354
9. Intrinsic functions
Syntax rules
General rules
355
9. Intrinsic functions
Syntax rules
General rules
356
9. Intrinsic functions
9.78. PI function
FUNCTION PI
Syntax rules
General rules
357
9. Intrinsic functions
Syntax rules
General rules
358
9. Intrinsic functions
Syntax rules
General rules
359
9. Intrinsic functions
Syntax rules
General rules
360
9. Intrinsic functions
Syntax rules
General rules
361
9. Intrinsic functions
Syntax rules
General rules
362
9. Intrinsic functions
Syntax rules
General rules
363
9. Intrinsic functions
Syntax rules
General rules
364
9. Intrinsic functions
Syntax rules
General rules
365
9. Intrinsic functions
Syntax rules
General rules
366
9. Intrinsic functions
Syntax rules
General rules
367
9. Intrinsic functions
FUNCTION STANDARD-COMPARE
h ih i
( argument-1 argument-2 argument-3 argument-4 )
Syntax rules
General rules
368
9. Intrinsic functions
Syntax rules
General rules
369
9. Intrinsic functions
Syntax rules
General rules
370
9. Intrinsic functions
Syntax rules
General rules
371
9. Intrinsic functions
Syntax rules
General rules
372
9. Intrinsic functions
Syntax rules
General rules
373
9. Intrinsic functions
Syntax rules
General rules
374
9. Intrinsic functions
Syntax rules
General rules
375
9. Intrinsic functions
Syntax rules
General rules
376
9. Intrinsic functions
Syntax rules
General rules
377
9. Intrinsic functions
Syntax rules
General rules
378
9. Intrinsic functions
Syntax rules
General rules
379
9. Intrinsic functions
Syntax rules
General rules
380
9. Intrinsic functions
Syntax rules
General rules
381
9. Intrinsic functions
Syntax rules
General rules
382
9. Intrinsic functions
Syntax rules
General rules
383
9. Intrinsic functions
Syntax rules
General rules
384
9. Intrinsic functions
Syntax rules
General rules
385
9. Intrinsic functions
387
Appendices
389
A. GNU Free Documentation License
Version 1.3, 3 November 2008
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
<http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document,
but changing it is not allowed.
A.1. Preamble
The purpose of this License is to make a manual, textbook, or other functional and use-
ful document “free” in the sense of freedom: to assure everyone the effective freedom
to copy and redistribute it, with or without modifying it, either commercially or noncom-
mercially. Secondarily, this License preserves for the author and publisher a way to get
credit for their work, while not being considered responsible for modifications made by
others.
This License is a kind of “copyleft”, which means that derivative works of the docu-
ment must themselves be free in the same sense. It complements the GNU General
Public License, which is a copyleft license designed for free software.
We have designed this License in order to use it for manuals for free software, be-
cause free software needs free documentation: a free program should come with man-
uals providing the same freedoms that the software does. But this License is not limited
to software manuals; it can be used for any textual work, regardless of subject matter
or whether it is published as a printed book. We recommend this License principally for
works whose purpose is instruction or reference.
391
A. GNU Free Documentation License
392
A. GNU Free Documentation License
and standard-conforming simple HTML, PostScript or PDF designed for human modi-
fication. Examples of transparent image formats include PNG, XCF and JPG. Opaque
formats include proprietary formats that can be read and edited only by proprietary word
processors, SGML or XML for which the DTD and/or processing tools are not generally
available, and the machine-generated HTML, PostScript or PDF produced by some word
processors for output purposes only.
The “Title Page” means, for a printed book, the title page itself, plus such following
pages as are needed to hold, legibly, the material this License requires to appear in the
title page. For works in formats which do not have any title page as such, “Title Page”
means the text near the most prominent appearance of the work’s title, preceding the
beginning of the body of the text.
The “publisher” means any person or entity that distributes copies of the Document
to the public.
A section “Entitled XYZ” means a named subunit of the Document whose title either
is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in
another language. (Here XYZ stands for a specific section name mentioned below, such
as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve
the Title” of such a section when you modify the Document means that it remains a
section “Entitled XYZ” according to this definition.
The Document may include Warranty Disclaimers next to the notice which states that
this License applies to the Document. These Warranty Disclaimers are considered to be
included by reference in this License, but only as regards disclaiming warranties: any
other implication that these Warranty Disclaimers may have is void and has no effect
on the meaning of this License.
393
A. GNU Free Documentation License
394
A. GNU Free Documentation License
395
A. GNU Free Documentation License
A.5. Modifications
You may copy and distribute a Modified Version of the Document under the conditions of
sections 2 and 3 above, provided that you release the Modified Version under precisely
this License, with the Modified Version filling the role of the Document, thus licensing
distribution and modification of the Modified Version to whoever possesses a copy of
it. In addition, you must do these things in the Modified Version:
A. Use in the Title Page (and on the covers, if any) a title distinct from that of the
Document, and from those of previous versions (which should, if there were any,
be listed in the History section of the Document). You may use the same title as a
previous version if the original publisher of that version gives permission.
B. List on the Title Page, as authors, one or more persons or entities responsible for
authorship of the modifications in the Modified Version, together with at least five
of the principal authors of the Document (all of its principal authors, if it has fewer
than five), unless they release you from this requirement.
C. State on the Title page the name of the publisher of the Modified Version, as the
publisher.
E. Add an appropriate copyright notice for your modifications adjacent to the other
copyright notices.
F. Include, immediately after the copyright notices, a license notice giving the public
permission to use the Modified Version under the terms of this License, in the form
shown in the Addendum below.
G. Preserve in that license notice the full lists of Invariant Sections and required Cover
Texts given in the Document’s license notice.
I. Preserve the section Entitled “History”, Preserve its Title, and add to it an item
stating at least the title, year, new authors, and publisher of the Modified Version
as given on the Title Page. If there is no section Entitled “History” in the Document,
create one stating the title, year, authors, and publisher of the Document as given
on its Title Page, then add an item describing the Modified Version as stated in
the previous sentence.
J. Preserve the network location, if any, given in the Document for public access to
a Transparent copy of the Document, and likewise the network locations given in
the Document for previous versions it was based on. These may be placed in the
396
A. GNU Free Documentation License
“History” section. You may omit a network location for a work that was published
at least four years before the Document itself, or if the original publisher of the
version it refers to gives permission.
L. Preserve all the Invariant Sections of the Document, unaltered in their text and
in their titles. Section numbers or the equivalent are not considered part of the
section titles.
M. Delete any section Entitled “Endorsements”. Such a section may not be included
in the Modified Version.
If the Modified Version includes new front-matter sections or appendices that qualify
as Secondary Sections and contain no material copied from the Document, you may at
your option designate some or all of these sections as invariant. To do this, add their
titles to the list of Invariant Sections in the Modified Version’s license notice. These titles
must be distinct from any other section titles.
You may add a section Entitled “Endorsements”, provided it contains nothing but en-
dorsements of your Modified Version by various parties—for example, statements of
peer review or that the text has been approved by an organization as the authoritative
definition of a standard.
You may add a passage of up to five words as a Front-Cover Text, and a passage of
up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified
Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be
added by (or through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or by arrangement
made by the same entity you are acting on behalf of, you may not add another; but you
may replace the old one, on explicit permission from the previous publisher that added
the old one.
The author(s) and publisher(s) of the Document do not by this License give permis-
sion to use their names for publicity for or to assert or imply endorsement of any Modi-
fied Version.
397
A. GNU Free Documentation License
398
A. GNU Free Documentation License
399
A. GNU Free Documentation License
400
A. GNU Free Documentation License
A.9. Translation
Translation is considered a kind of modification, so you may distribute translations of
the Document under the terms of section 4. Replacing Invariant Sections with trans-
lations requires special permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the original versions of these
Invariant Sections. You may include a translation of this License, and all the license no-
tices in the Document, and any Warranty Disclaimers, provided that you also include the
original English version of this License and the original versions of those notices and
disclaimers. In case of a disagreement between the translation and the original version
of this License or a notice or disclaimer, the original version will prevail.
If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “His-
tory”, the requirement (section 4) to Preserve its Title (section 1) will typically require
changing the actual title.
401
A. GNU Free Documentation License
A.10. Termination
You may not copy, modify, sublicense, or distribute the Document except as expressly
provided under this License. Any attempt otherwise to copy, modify, sublicense, or dis-
tribute it is void, and will automatically terminate your rights under this License.
However, if you cease all violation of this License, then your license from a particular
copyright holder is reinstated (a) provisionally, unless and until the copyright holder ex-
plicitly and finally terminates your license, and (b) permanently, if the copyright holder
fails to notify you of the violation by some reasonable means prior to 60 days after the
cessation.
Moreover, your license from a particular copyright holder is reinstated permanently
if the copyright holder notifies you of the violation by some reasonable means, this is
the first time you have received notice of violation of this License (for any work) from
that copyright holder, and you cure the violation prior to 30 days after your receipt of the
notice.
Termination of your rights under this section does not terminate the licenses of par-
ties who have received copies or rights from you under this License. If your rights have
been terminated and not permanently reinstated, receipt of a copy of some or all of the
same material does not give you any rights to use it.
402
A. GNU Free Documentation License
403
A. GNU Free Documentation License
A.12. Relicensing
“Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web
server that publishes copyrightable works and also provides prominent facilities for any-
body to edit those works. A public wiki that anybody can edit is an example of such a
server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means
any set of copyrightable works thus published on the MMC site.
“CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license pub-
lished by Creative Commons Corporation, a not-for-profit corporation with a principal
place of business in San Francisco, California, as well as future copyleft versions of that
license published by that same organization.
“Incorporate” means to publish or republish a Document, in whole or in part, as part
of another Document.
An MMC is “eligible for relicensing” if it is licensed under this License, and if all works
that were first published under this License somewhere other than this MMC, and subse-
quently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant
sections, and (2) were thus incorporated prior to November 1, 2008.
The operator of an MMC Site may republish an MMC contained in the site under CC-
BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible
for relicensing.
404
A. GNU Free Documentation License
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the
“with . . . Texts.” line with this:
with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover
Texts being LIST, and with the Back-Cover Texts being LIST.
If you have Invariant Sections without Cover Texts, or some other combination of the
three, merge those two alternatives to suit the situation.
If your document contains nontrivial examples of program code, we recommend re-
leasing these examples in parallel under your choice of free software license, such as
the GNU General Public License, to permit their use in free software.
405
B. Language element lists
This appendix is required for conformance to the COBOL standard.
4. ACCEPT statement, screen format (when data is verified, behavior for inconsis-
tent data):
10. ASSIGN clause, USING phrase (meaning and rules for operands; consistency
rules):
11. BACKGROUND-COLOR clause (the background color when the clause is not spec-
ified or the value specified is not in the range 0 to 7):
13. CALL statement (rules for program-name formation for a non-COBOL program):
407
B. Language element lists
23. Characters prohibited from use in text-words in COPY ... REPLACING and RE-
PLACE statements:
25. COBOL character repertoire (encoding of, mapping of, substitute graphics):
26. COBOL character repertoire (if more than one encoding in a compilation group,
control functions if any):
27. Color number (for a monochrome terminal, the mapping of the color attributes
onto other attributes):
28. Compiler directives, compiler directive IMP (syntax rules and general rules):
29. Computer’s coded character set (characters in and encoding of computer’s al-
phanumeric coded character set and computer’s national coded character set,
encoding for usage DISPLAY and usage NATIONAL):
30. Computer’s coded character set (coded character values for certain COBOL items):
31. Computer’s coded character set (correspondence between alphanumeric and na-
tional characters):
32. Computer’s coded character set (for literals, correspondence between compile-
time and runtime character sets, when conversion takes place):
33. Computer’s coded character set (correspondence between lowercase and upper-
case letters when a locale is not in effect):
34. Computer’s coded character set (when composite alphanumeric and national,
mapping of characters to each):
35. Computer’s coded character set (when more than one encoding, the mechanism
for selecting encoding for runtime):
408
B. Language element lists
36. Computer’s coded character set (whether UTF-8 or mixed alphanumeric and na-
tional characters recognized in class alphanumeric; applicable syntax and gen-
eral rules):
37. COPY statement (rules for identifying and locating default library text):
38. CRT status 9xxx (the value of xxx for unsuccessful completion with implementor-
defined conditions):
39. Cultural ordering table (allowable content of literal defines a cultural ordering
table):
42. Cursor (the cursor movement if keys are defined that change the cursor position):
409
B. Language element lists
59. External repository (mechanism for specifying whether checking and updating
occur):
60. External repository information (other information beyond the required informa-
tion):
62. Fatal exception condition (whether detected at compile time, circumstances un-
der which detected):
63. Fatal exception condition (whether or not execution will continue, how it will con-
tinue, and how any receiving operands are affected when events that would cause
a fatal exception to exist occur but checking for that condition is not enabled):
64. FILE-CONTROL entry, ASSIGN clause (TO phrase meaning and rules):
65. FILE-CONTROL entry, ASSIGN clause (consistency rules for external file connec-
tors):
66. FILE-CONTROL entry, ASSIGN clause (USING phrase meaning and rules):
69. File sharing (which devices allow concurrent access to the file):
71. Fixed file attribute (whether the ability to share a file is a fixed file attribute):
75. Floating-point numeric literals (maximum permitted value and minimum permit-
ted value of the exponent):
76. FOREGROUND-COLOR clause (the foreground color when the clause is not spec-
ified or the value specified is not in the range 0 to 7):
410
B. Language element lists
79. Format validation (rules for checking items of usages other than display or na-
tional):
83. Function-identifier (result when argument rules are violated and checking for the
EC-ARGUMENT-FUNCTION exception condition is not enabled):
84. Function keys (context-dependent keys, function number, and method for en-
abling and disabling):
85. Function returned values (characteristics, representation, and returned value for
native arithmetic):
89. Hexadecimal national literals (mapping when characters not multiples of four
bits):
411
B. Language element lists
98. I-O status 24 (manner in which the boundaries of a file are defined):
99. I-O status 34 (manner in which the boundaries of a file are defined):
102. LEAP-SECOND directive (whether a value greater than 59 seconds may be re-
ported and, if so, the maximum number of seconds that may be reported):
103. LEAP-SECOND directive (whether standard numeric time form values greater
than or equal to 86,400 may be reported):
104. Life cycle for objects (timing and algorithm for taking part in continued execu-
tion):
105. Linkage section (whether access to linkage section items is meaningful when
called from a non-COBOL program):
106. Listings (whether and when produced by the compiler, effect of logical conver-
sion):
107. Locale specification (how user and system defaults defined; at least one user
and one system default):
111. National literals (number of hexadecimal digits that map to a national character):
412
B. Language element lists
119. OPEN statement with OUTPUT phrase (positioning of the output file with regard
to physical page boundaries):
120. OPEN statement without the SHARING phrase and no SHARING clause in the file
control entry (definition of sharing mode established for each file connector):
122. Procedure division header rules when either the activating or the activated run-
time element is not a COBOL element (restrictions and mechanisms for all sup-
ported language products with details such as the matching of parameters, data
type representation, returning of a value, and omission of parameters):
128. RECORD clause (implicit RECORD clause if RECORD clause is not specified):
129. RECORD clause (whether fixed or variable records produced for fixed-or-variable-
length format):
130. RECORD DELIMITER clause (consistency rules when used with external file con-
nectors):
131. RECORD DELIMITER clause (feature-name and associated method for determin-
ing length of variable-length records):
132. RECORD DELIMITER clause (if not specified, method for determining length of
variable-length records):
133. Record locking (circumstances other than a locked logical record that return a
locked record status):
138. Reference format (meaning of lines and character positions in free-form and
fixed-form format):
413
B. Language element lists
141. Report writer printable item (fixed correspondence between columns and na-
tional characters):
143. REPOSITORY paragraph, INTERFACE phrase (how interface specifier and exter-
nal repository determine which interface is used):
146. RETRY phrase (interval between attempts to obtain access to a locked file or
record):
147. RETRY phrase (maximum meaningful time-out value and internal representation;
technique for determining frequency of retries):
151. SEARCH ALL statement (varying of the search index during the search opera-
tion):
153. SECURE clause (cursor movement when data is entered into a field for which the
SECURE clause is specified):
154. SELECT WHEN clause (whether a SELECT WHEN takes effect for READ state-
ments and REWRITE or WRITE statements with the FILE phrase in the absence of
a CODE-SET clause or a FORMAT clause):
155. SET statement (effect of SET on function whose address is being stored in a
function-pointer):
156. SET statement (effect of SET on program whose address is being stored in a
program-pointer):
158. SIGN clause (representation when PICTURE contains character ’S’ with no op-
tional SIGN clause):
414
B. Language element lists
159. SIGN clause (valid sign when SEPARATE CHARACTER phrase not present):
160. Size error condition (whether or not range of values allowed for the intermediate
data item is to be checked):
168. SPECIAL-NAMES paragraph, ALPHABET clause, UCS-4, UTF-8, and UTF-16 phrases
(correspondence with native character set):
173. STOP statement (constraints on the value of the STATUS literal or on the contents
of the data item referenced by the STATUS identifier):
415
B. Language element lists
182. Text manipulation (stage of processing the LISTING and PAGE directives and the
SUPPRESS phrase of COPY):
184. Time formats and corresponding function values (maximum precision not less
than nine fractional digits):
185. THROUGH phrase in VALUE clause and EVALUATE statement (collating sequence
used for determining range of values when no alphabet-name is specified):
186. TURN directive (whether location information is available when the LOCATION
phrase is not specified):
187. USAGE BINARY clause (computer storage allocation, alignment and representa-
tion of data):
416
B. Language element lists
198. USAGE POINTER clause (alignment, size, representation, and range of values):
200. USE statement (action taken following execution of the USE procedure when I-O
status value indicates a fatal exception condition):
202. Variable-length data items (actual time when the resources used are freed):
417
B. Language element lists
6. File sharing and record locking: Support is claimed, but the level of support is
processor-dependent.
8. Locale support and related functions: The syntax is recognised, but no function-
ality is claimed.
418
B. Language element lists
Note: Flagging syntax extensions You can flag many syntax extensions when compil-
ing with -std=cobol2014 or one of the other strict COBOL syntax definitions.
419
B. Language element lists
420