Declaratives
Declaratives provide one or more special-purpose sections that are executed when an exceptional 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 statement that identifies the section's function. The series of procedures that follow specify the actions that are to be taken when the exceptional condition occurs. Each declarative section ends with another section-name followed by a USE statement, or with the keywords END DECLARATIVES.
The entire group of declarative sections is preceded by the keyword 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 can appear on the same line.
In the declaratives part of the PROCEDURE DIVISION, each section header must be followed by a separator period, and must be followed by a USE statement followed by a separator period. No other text can appear on the same line.
The USE statement has the following formats:
The USE statement itself is never executed; instead, the USE statement 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 activated it.
A declarative procedure can be performed from a nondeclarative procedure.
A nondeclarative procedure can be performed from a declarative procedure.
A declarative procedure can be referenced in a GO TO statement in a declarative procedure.
A nondeclarative procedure can be referenced in a GO TO statement in a declarative procedure.
You can include a statement that executes a previously called USE procedure that is still in control. However, to avoid an infinite loop, you must be sure there is an eventual exit at the bottom.
The declarative procedure is exited when the last statement in the procedure is executed.