named constants, COBOL programming language" /> Named constants
Home

 

Named constants

In this book, the names of constants are shown containing the underscore character (_) as part of the name. In COBOL, use the hyphen character (-) in place of the underscore.

Constants that have character-string values use the single-quote character as the string delimiter ('). In some environments you might need to specify an appropriate compiler option to cause the compiler to accept the single quote as the string delimiter in place of the double quote.

The named constants are declared in the COPY files as level-10 items. To use the constants, declare the level-01 item explicitly, and then use the COPY statement to copy in the declarations of the constants:

* Declare a structure to hold the constants
 01  MY-MQ-CONSTANTS.
     COPY CMQV.

The above method causes the constants to occupy storage in the program even if they are not referenced. If you include the constants in many separate programs within the same run unit, multiple copies of the constants will exist; this consumes main storage unnecessarily. Avoid this by using one of the following techniques:



 

Home