Skip to content

INITIALIZE Statement

The INITIALIZE statement sets data items or categories of data items to prescribed values.

General Format:

       INITIALIZE { data-1 }  [ WITH FILLER ] 
              [REPLACING {initialize_category} DATA BY identifier-1 }... ]

Where initialize_category is one of the following:

  ALPHABETIC
  ALPHANUMERIC
  NUMERIC
  ALPHANUMERIC-EDITED
  NUMERIC-EDITED
  NATIONAL

Syntax:

  1. data-n is a data item.
  2. identifier-n is a data element, literal, or data returned from a function call.

General Rules:

  1. The INITIALIZE statement can be used to target data elements or classes of data elements. The initialize-category Classes of data elements that are recognized by the INITIALIZE statement are:
    • ALPHABETIC
    • ALPHANUMERIC
    • NUMERIC
    • ALPHANUMERIC EDITED
    • NUMERIC EDITED
    • NATIONAL

      For more information on Picture Catagories, see the Picture Data Categories section.
  2. The default behavior of the INITIALIZE verb is to initialize Alphabetic, Alphanumeric, Alphanumeric Edited, and National data items to SPACES, and Numeric and Numeric-Edited data items to ZERO.
  3. If a group item is initialized which contains a mixture of alphanumeric, numeric, and national data types, each data type will be initialized according to the default behaviours of COBOL-IT.
  4. If the REPLACING clause is used, the implied MOVE is evaluated by the compiler tovensure that it is valid.
  5. The following data items should not be targets of the INITIALIZE verb:
    • Data items containing an OCCURS DEPENDING ON clause.
    • FILLER data items, unless the WITH FILLER clause is present.
    • Data items with a REDEFINES clause.
    • Data items described as USAGE INDEX
  6. The following compiler configuration file entries affect the behavior of the INITIALIZE statement. See Compiler and Runtime Reference Manual for complete details.
    initialize-to-value:[yes/no]
    initialize-fd:[yes/no]
    initialize-filler:[yes/no
    initialize-pointer:[yes/no]

Code Sample:

       IDENTIFICATION DIVISION. 
       PROGRAM-ID. INITIALIZE-1. 
       ENVIRONMENT DIVISION. 
       DATA DIVISION. 
       WORKING-STORAGE SECTION. 
       77 DUMMY PIC X. 
       PROCEDURE DIVISION. 
       MAIN. 

      *INITIALIZE { TARGET } … [ WITH FILLER ] 
      *[REPLACING {INITIALIZE-CATEGORY} DATA BY VALUE }... ] 
      * 
      *WHERE INITIALIZE-CATEGORY IS ONE OF THE FOLLOWING: 
      * 
      *ALPHABETIC
      *ALPHANUMERIC 
      *NUMERIC 
      *ALPHANUMERIC-EDITED 
      *NUMERIC-EDITED 
      *NATIONAL 

              INITIALIZE DUMMY. 

              INITIALIZE DUMMY WITH FILLER. 

              INITIALIZE DUMMY 
              REPLACING ALPHABETIC DATA BY "Z" 
                     ALPHANUMERIC DATA BY "Y" 
                     NUMERIC DATA BY 0 
                     ALPHANUMERIC-EDITED DATA BY "X" 
                     NUMERIC-EDITED DATA BY "W" 
                     NATIONAL DATA BY "V". 

              DISPLAY "INITIALIZE-1 FINISHED!" LINE 10 COL 10. 
              ACCEPT DUMMY LINE 10 COL 35. 
              STOP RUN.
Back to top