The SYMBOLIC CONSTANT clause is specified when assigning names to literals. Because the literals are located in a single place in the program, maintainability and extendibility are enhanced. The literals need only be modified at one place in the program.
000010 @OPTIONS MAIN 000020*---------------------------------------------------------------------- 000030* The SYMBOLIC CONSTANT clause assigns a name to a literal. 000040*---------------------------------------------------------------------- 000050 IDENTIFICATION DIVISION. 000060 PROGRAM-ID. SAMPLE. 000070 ENVIRONMENT DIVISION. 000080 CONFIGURATION SECTION. 000090*---------------------------------------------------------------------- 000100* The consumption tax rate has been defined. 000110* By making the consumption tax rate a symbolic constant, 000120* future changes in the rate can be easily handled. 000130*---------------------------------------------------------------------- 000140 SPECIAL-NAMES. 000150 SYMBOLIC CONSTANT 000160 CONSUMPTION-TAX-RATE IS 0.05. 000170*---------------------------------------------------------------------- 000180 DATA DIVISION. 000190 WORKING-STORAGE SECTION. 000200 01 PRICE PIC 9(8). 000210 01 CONSUMPTION-TAX PIC ZZZZZ9. 000220 PROCEDURE DIVISION. 000230 DISPLAY "Calculate the consumption tax." 000240 DISPLAY "How much does the item you want cost? >>" WITH NO 000245 ADVANCING 000250 ACCEPT PRICE. 000260*---------------------------------------------------------------------- 000270* Symbolic constants can be used in the same way as literals. 000280*---------------------------------------------------------------------- 000290 COMPUTE CONSUMPTION-TAX = PRICE * CONSUMPTION-TAX-RATE. 000300 DISPLAY "The consumption tax rate is " CONSUMPTION-TAX-RATE "." 000305 " The tax amount is " CONSUMPTION-TAX " dollars." 000310*---------------------------------------------------------------------- 000320 EXIT PROGRAM. 000330 END PROGRAM SAMPLE.