MF 

The CONSTANT Clause

The CONSTANT clause specifies that the 01 level item has a constant value, which cannot be modified.

General Format

Syntax for the CONSTANT clause

Syntax Rules

  1. This clause can only be specified at the 01 level.
  2. This clause can only be specified in WORKING-STORAGE and LINKAGE SECTION.
  3. The data item can only be used as sending item in a COBOL statement, and cannot be used in an operand that the statement could modify.
  4. Every elementary item must be subject to a VALUE clause; except, if CONSTANT is specified with a TYPEDEF definition.
  5. This clause cannot be used with the following qualifiers or usage: COMP-1, COMP-2, PIC 1, any pointer type, REDEFINES, EXTERNAL-FORM, index-names, THREAD-LOCAL, or the REENTRANT"2" directive.
  6. If a CALL statement includes a CONSTANT parameter, and a matching call prototype is defined, the equivalent parameter in the prototype must also include the CONSTANT clause.
  7. If the clause is used on a data item in a call prototype, the CONSTANT clause must also be specified for the corresponding parameter used in the sub-program.

General Rules

  1. Data items specifying CONSTANT that will be allocated to WORKING-STORAGE will be placed in read-only memory for native code execution.
  2. CONSTANT items used for EXTERNAL and LINKAGE SECTION means cannot be modified by COBOL statements in the program.
  3. .NET COBOL has its own implementation of a CONSTANT qualifier, which can only be used with .NET native types.
  4. The CONSTANT clause on tables is limited to one level of OCCURS.
  5. In table initialization, if a Value clause is used with multiple values (which can initialize individual elements in the table), any other Value clause that follows this one in the code must use multiple values as well or none at all.