MF 

The DECLARE Statement

Declares one or more local variables within the procedure division body. The scope of any inline local variable is from the point of declaration until the end of the innermost containing block, where paragraphs, sections and the whole method are considered to be blocks.

General Formats for Format 1

Syntax for format 1 of the DECLARE statement
NETJVM 

General Formats for Format 2

Syntax for format 2 of the DECLARE statement

General Rules for Format 1

  1. In native COBOL, local data items are statically scoped, but (unlike JVM COBOL local items) they are not perform-range-local: if you re-enter a paragraph or section, fresh copies of any associated local data items are not created.

Example

       01 names pic x(10) typedef.
       ...
       declare i1 as binary-long
       display i1 
         
       *>   Optionally, the variables can be initialised inline 
        declare c2 as binary-long = 5
        display c2

        declare name-list as names occurs 3