What is the default value(s) for an INITIALIZE and what keyword allows for an override of the default?

INITIALIZE moves spaces to alphabetic fields and zeros to alphanumeric fields. The REPLACING option can be used to override these defaults.

Showing Answers 1 - 19 of 19 Answers

mohan

  • Oct 4th, 2006
 

Initialize sets zero for numerics and spaces for alphabetic.

  Was this answer useful?  Yes

dpg_25

  • Feb 14th, 2008
 

INITIALIZE verb will initialize 01 level variables to their definitions. For e.g
01  VAR-A      PIC X(2).
01  VAR-B      PIC 9(2).
01  VAR-C.
      05 VAR-D PIC X(2).
      05 VAR-E PIC 9(2).

If VAR-A VAR-B and VAR-C are initialized.
VAR-A will be spaces. VAR-B will be Zeroes. VAR-C will be spaces. So there will be spaces in VAR-D and VAR-E.
If you want VAR-D to be spaces and VAR-E to be Zeroes you must write
Initialize VAR-C REPLACING ALL NUMERIC BY ZEROES.

Please correct me if I am wrong.

I think even for the follwing type
 01 Var-C.
       05 Var-d   PIC 9.

       05 Var-e   PIC X.
When we initialize the Var-C it will automatically move Zero to Var-d and Space to Var-e.
The REPLACING key word is helpful in updating these variables with characters other than zero and spaces. for example if we want to move * to Var-e the command will be INITIALIZE Var-e REPLACING ALPHANUMERIC BY '*'.

  Was this answer useful?  Yes

panzer1

  • Feb 1st, 2010
 

Yes,  the "VALUE' is used once to set the value at the beginning of the program execution.
The "INITIALIZE" can be used multiple times any where in the program after execution begins.

  Was this answer useful?  Yes

sunapana

  • Apr 17th, 2010
 

DATA DIVISION.
WORKING-STORAGE SECTION.
01 Var-C.
05 Var-d PIC x VALUE "A".
05 Var-e PIC 9 VALUE 5.
05 FILLER PIC X(2) VALUE 'HI'.
PROCEDURE DIVISION.
PUTPARA.
DISPLAY VAR-D.
DISPLAY VAR-E.
DISPLAY VAR-C.
INITIALIZE VAR-C.
DISPLAY VAR-D.
DISPLAY VAR-E.
DISPLAY VAR-C.
INITIALIZE VAR-C REPLACING NUMERIC BY 7 ALPHANUMERIC BY '*'.
DISPLAY VAR-D.
DISPLAY VAR-E.
DISPLAY VAR-C.
ENDPARA.
STOP RUN.
OUT PUT:
A
5
A5HI - Filler is not affected by INITIALIZE.
- please note here is a space
0
0HI - please note the space before 0
*
7
*7HI

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions