View previous topic :: View next topic
|
Author |
Message |
richa gupta
New User
Joined: 29 Jul 2007 Posts: 8 Location: noida
|
|
|
|
I have a doubt in INITIALIZE verb.
INITIALIZE record-structure will initialize all alphanumerix fields to spaces and numeric to zeroes. Is it correct?
I have come across test cases wherein INITIALIZE record-structure has only initialized alphanumeric fields while for numerics, I had to specifically give INITIALIZE record-structure REPLACING NUMERIC BY ZEROES. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Quote: |
INITIALIZE record-structure will initialize all alphanumerix fields to spaces and numeric to zeroes. Is it correct? |
Yes |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Just an explanation. Consider a group variable.
Code: |
01 GROUP-ITEM.
05 NUM1 PIC 9(4).
05 ALPHA1 PIC X(2).
05 NUM2 PIC 9(6). |
In the PROCEDURE Division
Code: |
INITIALIZE GROUP-ITEM |
After the execution of the above statement NUM1 and NUM2 would contain zeroes and ALPHA1 would have spaces. |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Richa,
Quote: |
I have come across test cases wherein INITIALIZE record-structure has only initialized alphanumeric fields while for numerics, I had to specifically give INITIALIZE record-structure REPLACING NUMERIC BY ZEROES |
Not Necessary to give REPLACING data-type BY. INITIALIZE verb will take care of it.
But when you are trying to initialize it with some other values or other varialble values then use REPLACING BY variable-name.
If you are looking for some other doubt/query, post the same. |
|
Back to top |
|
|
nuthan
Active User
Joined: 26 Sep 2005 Posts: 146 Location: Bangalore
|
|
|
|
VALUE clause is used to initialize the data items in the working
storage section whereas INITIALIZE is used to initialize the data items in the procedure division.
INITIALIZE sets the alphabetic, alphanumeric and alphanumeric-edited
items to SPACES and numeric and numeric-edited items to ZERO. This can be overridden by REPLACING option of INITIALIZE. FILLER, OCCURS DEPENDING ON items are not affected. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Richa,
Quote: |
I had to specifically give INITIALIZE record-structure REPLACING NUMERIC BY ZEROES. |
What is the value in the NUMERIC field after INITIALIZING the group variable. Could you please display the numeric field and post the result?
According to your statement it should have some numeric value other than zeroes. |
|
Back to top |
|
|
|