Within the procedure division, a procedure consists of:
- A section or a group of sections
- A paragraph or group of paragraphs
A procedure-name is a user-defined name that identifies a section or a
paragraph.
- Section
- A section-header optionally followed by one or more paragraphs.
- Section-header
- A section-name followed by the keyword SECTION, optionally followed by a priority-number, followed by a separator period.
Section-headers are optional after the keywords END DECLARATIVES or if there are no
declaratives.
- Section-name
- A user-defined word that identifies a section. A referenced section-name, because it
cannot be qualified, must be unique within the program in which it is defined.
- Priority-number
-
An integer or a positive signed numeric literal ranging in value from 0 through 99. Priority-number identifies a fixed segment or an independent segment that is
to contain the section.
Sections in the declaratives portion must contain priority numbers in the range of 0
through 49.
You cannot specify priority-numbers:
- In a method definition
- In a program that is declared with the RECURSIVE attribute
- In a program compiled with the THREAD compiler option
A section ends immediately before the next section header, or at the end of the
procedure division, or, in the declaratives portion, at the keywords END
DECLARATIVES.
- Segments
-
A segment consists of all sections in a program that
have the same priority-number. Priority-number determines whether a section is stored in
a fixed segment or an independent segment at run time.
Segments with a priority-number of 0 through 49 are fixed segments. Segments with a
priority-number of 50 through 99 are independent segments.
The type of segment (fixed or independent) controls the segmentation feature.
In fixed segments, procedures are always in last-used state. In independent segments,
procedures are in initial state each time the segment receives control from a segment
with a different priority-number, except when the transfer of control results from the
execution of a GOBACK or EXIT PROGRAM statement. Restrictions on the use of ALTER, SORT,
and MERGE statements in independent segments are described under those statements.
COBOL for AIX does not support the overlay feature of the Standard COBOL 85 segmentation
module.
- Paragraph
-
A paragraph-name followed by a separator period, optionally followed by one or
more sentences.
Paragraphs must be preceded by a period because paragraphs always follow either the
identification division header, a section, or another paragraph, all of which must end
with a period.
- Paragraph-name
-
A user-defined word that identifies a paragraph. A paragraph-name, because it can be
qualified, need not be unique.
If there are no declaratives (format 2), a paragraph-name is not required in the
procedure division.
A paragraph ends immediately before the next paragraph-name or section header, or at
the end of the procedure division, or, in the declaratives portion, at the keywords END
DECLARATIVES.
Paragraphs need not all be contained within sections, even if one or more paragraphs
are so contained.
- Sentence
-
One or more statements terminated by a
separator period.
- Statement
-
A syntactically valid combination of identifiers and
symbols (literals, relational-operators, and so forth) beginning
with a COBOL verb.
- Identifier
-
The word or words necessary to make unique reference to a data item, optionally
including qualification, subscripting, indexing, and reference-modification. In any
procedure division reference (except the class test), the contents of an identifier must
be compatible with the class specified through its PICTURE clause, otherwise
results are
unpredictable.
Execution begins with the first statement in the procedure division, excluding
declaratives. Statements are executed in the order in which they are presented for
compilation, unless the statement rules dictate some other order of execution.
The end of the procedure division is indicated by one of the following:
- An identification division header that indicates the start of a nested source
program
- An END PROGRAM, END METHOD, END FACTORY, or END OBJECT marker
- The physical end of a program; that is, the physical position in a source program
after which no further source program lines occur