Declaratives
Declaratives provide one or more special-purpose sections that are executed when an exception-condition occurs.
When Declarative Sections are specified, they must be grouped at the beginning of the Procedure Division, and the entire Procedure Division must be divided into sections.
Each Declarative Section starts with a USE sentence that identifies the section's function; the series of procedures that follow specify what actions are to be taken when the exception condition occurs. Each Declarative Section ends with another section-name followed by a USE sentence, or with the keywords END DECLARATIVES. See USE Statement for more information on the USE statement. See Precedence Rules for Nested Programs on using the GLOBAL phrase.
The entire group of Declarative Sections is preceded by the key word DECLARATIVES, written on the line after the Procedure Division header; the group is followed by the keywords END DECLARATIVES. The keywords DECLARATIVES and END DECLARATIVES must each begin in Area A and be followed by a separator period. No other text may appear on the same line.
In the declaratives part of the Procedure Division, each section header (with an optional segment number) must be followed by a separator period, a USE sentence, and a separator period. No other text may appear on the same line.
The USE sentence itself is never executed; instead, the USE sentence defines the conditions that execute the succeeding procedural paragraphs, which specify the actions to be taken. After the procedure is executed, control is returned to the routine that caused the execution of it.
Within a declarative procedure, there must be no reference to any nondeclarative procedure.
A procedure-name associated with a USE statement can be referenced in a different declarative section or in a nondeclarative procedure only with a PERFORM statement.
A declarative is run as a separate invocation from any other declaratives or from the nondeclarative part of the COBOL program. See the section on using declaratives in the error handling chapter of the IBM® Rational® Development Studio for i: ILE COBOL Programmer's Guide.
Within a declarative procedure, no statement should be included that would cause the execution of a USE procedure that had been previously invoked and had not yet returned control to the invoking routine.
The declarative procedure is exited when the last statement in the procedure is executed.