Constants: level 78 and VALUE
| Level 78 items | |
| Using constants | |
| CONSTANT phrase |
Level 78 items
Level 78 declares a named constant. It cannot be assigned to, and it appears in expressions like a variable:
78 MAX-EMPLOYEES VALUE 50.
78 TAX-RATE VALUE 0.13.
Using constants
Use constants everywhere a literal would go. The name documents the number, and one edit changes every use:
COMPUTE WS-LIMIT = MAX-EMPLOYEES * 2.
COMPUTE WS-TAX = WS-SALARY * TAX-RATE.
CONSTANT phrase
COBOL 2014 adds the CONSTANT phrase to VALUE, which rejects redefinition at compile time. Level 78 remains the common way, and both styles are case-insensitive like all COBOL.
Next: Conditions and relation tests
Article author: Arthur Isaev