Figurative constants are the constant values that are predefined in the COBOL language.

These figurative constants are known to the COBOL language and perform the specific task if specified.

Below are the figurative constants in COBOL language -

  • ZERO, ZEROS, ZEROES
  • SPACE, SPACES
  • HIGH-VALUE, HIGH-VALUES
  • LOW-VALUE, LOW-VALUES
  • QUOTE, QUOTES
  • ALL
  • symbolic-character

ZERO, ZEROS, ZEROES -

ZERO is the figurative constant that represents the numeric value 0.

The figurative constant ZERO has three forms and those are - ZERO, ZEROS or ZEROES.

These three different figurative constants are defined to represent the multiple forms of 0. i.e., ZERO to represent single 0, ZEROS or ZEROES to represent two or more occurrences of 0s.

These figurative constants are used to initialize numeric or alphanumeric variables with 0.

For example -

Initializing variable during declaration -

01 WS-FIGCONSTZ         PIC 9(10) VALUE ZEROES.

WS-FIGCONSTZ initializes with ZEROES.

Initializing variable in procedure division -

MOVE ZEROES TO WS-FIGCONSTZ.

Using for comparison -

IF WS-FIGCONSTZ EQUAL ZEROES
	......
END-IF.

SPACE, SPACES -

SPACE is a figurative constant that represents space. i.e., " " or X'40'.

The figurative constant SPACE has two forms and those are - SPACE or SPACES.

These 2 different figurative constants are defined to represent the multiple forms of space. i.e., SPACE to represents single SPACE (" "), SPACES to represent two or more occurrences of space.

These figurative constants are used to initialize alphabetic or alphanumeric variables with space.

For example -

Initializing variable during declaration -

01 WS-FIGCONSTS         PIC X(10) VALUE SPACES.

WS-FIGCONSTS initializes with SPACES.

Initializing variable in procedure division -

MOVE SPACES TO WS-FIGCONSTS.

Using for comparison -

IF WS-FIGCONSTS EQUAL SPACES
	......
END-IF.

HIGH-VALUE, HIGH-VALUES -

HIGH-VALUE is a figurative constant that represents the highest position in collating sequence or assembling sequence. i.e., X'FF' (8-bit character code for all binary 1s).

The figurative constant HIGH-VALUE has two forms and those are - HIGH-VALUE or HIGH-VALUES.

These 2 different figurative constants are defined to represent the multiple forms of X'FF'. i.e., HIGH-VALUE to represent single X'FF', HIGH-VALUES to represent two or more X'FF' occurrences.

These figurative constants are used to initialize alphanumeric variables with X'FF'.

For example -

Initializing variable during declaration -

01 WS-FIGCONSTH         PIC X(10) VALUE HIGH-VALUES.

WS-FIGCONSTS initializes with HIGH-VALUES.

Initializing variable in procedure division -

MOVE HIGH-VALUES TO WS-FIGCONSTH.

Using for comparison -

IF WS-FIGCONSTH EQUAL HIGH-VALUES
	......
END-IF.

LOW-VALUE, LOW-VALUES -

LOW-VALUE is a figurative constant that represents the lowest position in collating sequence or assembling sequence. i.e., X'00' (8-bit character code for all binary 0s).

The figurative constant LOW-VALUE has two forms and those are - LOW-VALUE or LOW-VALUES.

These 2 different figurative constants are defined to represent the multiple forms of X'00'. i.e., LOW-VALUE to represent single X'00', LOW-VALUES to represent two or more X'00' occurrences.

These figurative constants are used to initialize alphanumeric variables with X'00'.

For example -

Initializing variable during declaration -

01 WS-FIGCONSTL         PIC X(10) VALUE LOW-VALUES.

WS-FIGCONSTS initializes with LOW-VALUES.

Initializing variable in procedure division -

MOVE LOW-VALUES TO WS-FIGCONSTL.

Using for comparison -

IF WS-FIGCONSTL EQUAL LOW-VALUES
	......
END-IF.

QUOTE, QUOTES -

QUOTE is a figurative constant that represents the one or more occurrences of -

  • The quotation mark character ("), if the QUOTE compiler option is in effect.
  • The apostrophe character ('), if the APOST compiler option is in effect.

The figurative constant QUOTE has two forms and those are - QUOTE or QUOTES.

These 2 different figurative constants are defined to represent the multiple forms of quotation(") or apostrophe ('). i.e., QUOTE to represent single quote, QUOTES to represent two or more quote occurrences.

These figurative constants are used to initialize alphanumeric variables with quotation(") or apostrophe (').

For example -

Initializing variable during declaration -

01 WS-FIGCONSTQ         PIC X(10) VALUE QUOTES.

WS-FIGCONSTQ initializes with QUOTES.

Initializing variable in procedure division -

MOVE QUOTES TO WS-FIGCONSTQ.

Using for comparison -

IF WS-FIGCONSTQ EQUAL QUOTES
	......
END-IF.

ALL -

ALL literal represents one or more occurrences of the characters-string that form the literal.

ALL can use as a literal and figurative constant.

When using ALL as a figurative constant, it should be followed by other figurative constants, user-defined literals, or character-strings.

ALL has no meaning and is used only to increase the readability when using as a figurative constant.

The figurative constant ALL should not be used with the CALL, INSPECT, INVOKE, STOP or STRING statements.

For example -

Initializing variable during declaration -

01 WS-FIGCONSTS         PIC X(10).

Initializing variable in procedure division -

MOVE ALL SPACES TO WS-FIGCONSTS.

Using with INSPECT -

INSPECT WS-FIGCONSTS TALLYING WS-COUNT FOR ALL " ".

symbolic-character -

The symbolic character represents one or more characters specified as a value in the SYMBOLIC CHARACTERS clause of the SPECIAL-NAMES paragraph.

SYMBOLIC CHARACTERS clause is used to assign symbolic names to any character of the specified alphabet.

Symbolic character always represents an alphanumeric character.

For example - reassign "cancel" to 27.

     ENVIRONMENT DIVISION.
     CONFIGURATION SECTION.
     SPECIAL-NAMES.
         SYMBOLIC CHARACTERS CANCEL IS 27.

Example -

Let’s take the below example to understand better -

01 A		PIC X(10) VALUE SPACES.
01 B.
   02 C		PIC 9(3) VALUE ZEROES.
   02 FILLER	PIC 9(3) VALUE LOW-VALUES.

Once the above code is executed, A is initialized with SPACES, B is initialized with ZEROES, and FILLER initialized with LOW-VALUES.

Practical Example -

Scenario - Below example describes how the figurative constants used in COBOL programming.

Code -

Figurative constant program Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. FIGCONST.                                            
       AUTHOR. MTH.                                                     
       DATA DIVISION.                                                   
       WORKING-STORAGE SECTION.                                         
       01  WS-VAR.                                                      
           05 WS-FIGCONSTH     PIC X(10) VALUE HIGH-VALUES.             
           05 WS-FIGCONSTL     PIC X(10).                               
           05 WS-FIGCONSTS     PIC X(10) VALUE SPACES.                  
           05 WS-FIGCONSTZ     PIC 9(10) VALUE ZEROES.                  
           05 WS-FIGCONSTQ     PIC X(10) VALUE QUOTES.                  
       PROCEDURE DIVISION.                                              
           DISPLAY "*****FIGURATIVE CONSTANT DISPLAY*****".             
           DISPLAY "HIGH-VALUES : " WS-FIGCONSTH.                       
                                                                        
           MOVE LOW-VALUES      TO  WS-FIGCONSTL.                       
           DISPLAY "LOW-VALUES  : " WS-FIGCONSTL.                       
                                                                        
           IF WS-FIGCONSTS EQUAL SPACES                                 
              DISPLAY "WS-FIGCONSTS INITIALIZED WITH SPACES"            
           END-IF.                                                      
           DISPLAY "SPACES      : " WS-FIGCONSTS.                       
                                                                        
           DISPLAY "ZEROES      : " WS-FIGCONSTZ.                       
                                                                        
           DISPLAY "QUOTES      : " WS-FIGCONSTQ.                       
           STOP RUN.                                                    
**************************** Bottom of Data ****************************

Output -

Figurative constant program Output

Explaining Example -

In the above example, we have shown how figurative constants are used in the COBOL program. We have initialized some figurative constant variables in WORKING-STORAGE SECTION, some in PROCEDURE DIVISION.

And it is also shown how the figurative constant is used in the IF condition for validation. Finally, the corresponding variables are displayed to see how the values are assigned.

Note! HIGH-VALUES, LOW-VALUES, and SPACES are not shown directly in general DISPLAY computation. Instead, we need to use the HEX ON option for validation to see their hexadecimal values.

Figurative constants display and their hexadecimal representation shown below -

Figurative constant program Output