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 Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts Replacing Start Transid with LINK pkmurali CICS 12 Tue Apr 19, 2016 8:22 pm
No new posts pass numeric value of length 14 to ti... Ralph Zbrog Java & MQSeries 4 Fri Jan 15, 2016 3:20 pm


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