IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

INITIALIZE Verb to REPLACING NUMERIC BY ZEROES


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
richa gupta

New User


Joined: 29 Jul 2007
Posts: 8
Location: noida

PostPosted: Tue Oct 16, 2007 11:09 am
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Oct 16, 2007 11:26 am
Reply with quote

Quote:
INITIALIZE record-structure will initialize all alphanumerix fields to spaces and numeric to zeroes. Is it correct?


Yes
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Oct 16, 2007 11:36 am
Reply with quote

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
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: India

PostPosted: Tue Oct 16, 2007 11:48 am
Reply with quote

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
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Tue Oct 16, 2007 12:07 pm
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Oct 16, 2007 12:07 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Remove leading zeroes SYNCSORT 4
No new posts Convert HEX to Numeric DB2 3
No new posts Find a record count/numeric is multip... COBOL Programming 1
Search our Forums:

Back to Top