Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts Return a Non Numeric value from REXX Learncoholic CLIST & REXX 3 Fri Sep 01, 2017 8:33 pm
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts Validate if a Value from the file is ... balacsv2 COBOL Programming 8 Mon Jun 19, 2017 11:52 pm
No new posts replacing junk with hyphen Nitin32 DFSORT/ICETOOL 10 Fri Jun 02, 2017 7:47 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us