Procedure Division General Description

ANS85 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.

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

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

ISO2002MF 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)

Procedure Division General Description (with Sections)

where parameter-list is:

Parameter list

General Formats for Format 2 (without-sections)


Syntax for Format 2 of the Procedure Division
ISO2002MF 

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


Syntax for Format 3 of the Procedure Division

Syntax Rules for Format 1

  1. MF type can be one of binary-* (binary-long, binary-double, etc...), pointer, and typedef-name.
  2. MF If BY REFERENCE or BY VALUE is omitted, BY VALUE is assumed.
  3. MF Parameters that use the = default-value syntax are optional parameters, and must follow any non-optional parameters. Optional parameters must be passed BY VALUE. default-value must be such that a MOVE operation from the value into a data item of the parameter type is permitted.

General Rules for Format 1

  1. MF If a section heading contains a parameter-list or a RETURNING clause, it is a parameterized section.

General Rules for all Formats

  1. Fall through into a parameterized section is not permitted.

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.

ISO2002MF 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.

OSVSVSC2MF 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.

VSC2MF 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.)

VSC2MF 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.

MF In a call prototype the Procedure Division is never executed.

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

ISO2002 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.

MF 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).