Procedure Division General Description

The Procedure Division is optional.

The Procedure Division in a program definition

ISO2002MF , function definition

or method definition contains procedures to be executed. These procedures can be declarative and/or nondeclarative.

The Procedure Division for an object definition and a factory definition contains the methods that may be invoked on the object or factory object.

The Procedure Division in a call prototype contains no procedures, except that it may contain the ENTRY statement.

The Procedure Division in a function prototype, method prototype or program prototype specifies the parameters and returning item, if any.

General Formats for Format 1 (with-sections)


*

General Formats for Format 2 (without-sections)


*

General Formats for Format 3 (interface-object-or-factory)


*

Comments:

The generic term procedure-division-header is described in the topic The PROCEDURE DIVISION Header.

Formats 1 and 2 can be used only in a program definition,

ISO2002MF a program prototype definition, a function definition, a function prototype definition

ISO2002MF a method definition, or a

MF call prototype.

Format 3 can be used only in a factory definition or an interface definition

ISO2002MF or an object definition.

The declarative sentence shown above is a USE statement (see the topics The USE Statement, The USE FOR DEBUGGING Statement, and The USE BEFORE REPORTING Statement ). It specifies when the section is to be executed.

A procedure is composed of a paragraph or group of paragraphs, or a section or group of sections in the Procedure Division. A procedure-name is a word used to refer to a paragraph or section in the source element in which it occurs. It consists of a paragraph-name (that may be qualified) or a section-name.

If one paragraph is in a section, all must be.

This rule is not enforced.

A paragraph comprises a paragraph-name followed by a period and a space, and any number of sentences or, if the paragraph-name is omitted, one or more successive sentences following the PROCEDURE DIVISION header or a section header. It is terminated either immediately before the next paragraph-name or section-name or at the end of the Procedure Division, or, in the declaratives portion, with END DECLARATIVES.

A section comprises a section header followed by any number of paragraphs. It is terminated either immediately before the next section or at the end of the Procedure Division, or, in the declaratives portion, with END DECLARATIVES.

However, a section in the declaratives need not have a declarative-sentence; it can be invoked by a PERFORM statement. (See the topic The PERFORM Statement for details of the PERFORM statement.)

Sentences that are not explicitly contained within a named paragraph as described above are considered to be contained within an unnamed implicit paragraph. Paragraphs that are not explicitly contained within a section are considered to be contained within an implicit, unnamed section.

In a program definition

ISO2002MF or method definition,

execution begins with the first statement in the Procedure Division, excluding declaratives. Statements are then executed in the order in which they are written, except where the rules indicate some other order.

In a call prototype the Procedure Division is never executed.

In an object definition, declaratives behave in the same way as if they had been specified in every contained method definition

In a factory definition, declaratives behave in the same way as if they had been specified in every contained method definition.

This segment of the chapter deals with arithmetic and conditional expressions, common and input/output phrases, intrinsic functions and COBOL verbs.

The procedure-division-header is optional in Format 2 of the Procedure Division. However, it is only optional if there are no divisions coded before this and if the Procedure Division begins with a COBOL sentence (not a section header, paragraph header, or Declarative Section).