Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

INITIALIZE Verb to REPLACING NUMERIC BY ZEROES

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: INITIALIZE Verb to REPLACING NUMERIC BY ZEROES
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: 1288
Location: Chennai, India

PostPosted: Tue Oct 16, 2007 11:26 am    Post subject: Reply to: INITIALIZE Verb
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: 1288
Location: Chennai, India

PostPosted: Tue Oct 16, 2007 11:36 am    Post subject: Reply to: INITIALIZE Verb
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: Chennai

PostPosted: Tue Oct 16, 2007 11:48 am    Post subject:
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    Post subject:
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: 1288
Location: Chennai, India

PostPosted: Tue Oct 16, 2007 12:07 pm    Post subject: Reply to: INITIALIZE Verb to REPLACING NUMERIC BY ZEROES
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us