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 Comp Variables ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
raveendra_ibm
Currently Banned

New User


Joined: 07 Jan 2006
Posts: 31

PostPosted: Mon Jan 09, 2006 7:04 pm    Post subject: INITIALIZE Comp Variables ?
Reply with quote

Hi All,

Can anyone please explain if the following code for initializing a
group variable containing a comp variable allowed ?

01 GRP1.
02 MEM1 PIC X(2).
02 MEM2 PIC 9(2).
02 MEM3 PIC S9(4) COMP.
02 MEM4 PIC S9(8) COMP-3.
.
.
.
INITIALIZE GRP1.
ADD 10 TO MEM3.
ADD 20 TO MEM4.

Would this lead to an ABEND ?

Thanks and Regards,
Raveendra.
Back to top
View user's profile Send private message

iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Mon Jan 09, 2006 7:10 pm    Post subject: Re: INITIALIZE Comp Variables ?
Reply with quote

Hi,

I think it will abend. I need to try it out.

Correct me if I am wrong.
Back to top
View user's profile Send private message
raveendra_ibm
Currently Banned

New User


Joined: 07 Jan 2006
Posts: 31

PostPosted: Mon Jan 09, 2006 7:21 pm    Post subject: Re: INITIALIZE Comp Variables ?
Reply with quote

Hi iKnow !!!

Thanks for such a prompt reply to my query.

It actually did not ABEND ? It initialized those variables to 0.

I am working on IBM Mainframes COBOL ?

Thanks n Regards,
Raveendra.
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 413
Location: Colarado, US

PostPosted: Mon Jan 09, 2006 7:32 pm    Post subject: Re: INITIALIZE Comp Variables ?
Reply with quote

Hi Raveendra,

Thanks a lot for correcting me.
Back to top
View user's profile Send private message
raveendra_ibm
Currently Banned

New User


Joined: 07 Jan 2006
Posts: 31

PostPosted: Mon Jan 09, 2006 7:40 pm    Post subject:
Reply with quote

Hi iKnow,

Actually I was expecting an ABEND as well ?
But to my wonder it turned out error free ?
Could please check the same on your compiler, because it might not be the same on all compilers.

Thanks & Regards,
Raveendra.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Jan 10, 2006 7:05 am    Post subject:
Reply with quote

In addition, it will also init an array if it were in the 01 level.

One problem w/init is that it's not very efficient, so if you are initing in a loop it can be costly.

What some do is init the field outside the loop; move it to a hold field then move the hold field back to the original as part of the loop process.
Back to top
View user's profile Send private message
raveendra_ibm
Currently Banned

New User


Joined: 07 Jan 2006
Posts: 31

PostPosted: Tue Jan 10, 2006 9:39 am    Post subject: Re: INITIALIZE Comp Variables ?
Reply with quote

Hi mmwife,

I was expecting the comp variables to be initialized to spaces and thereby
any arithmetic operation on them further would lead to an abend.

I just wanted a clarification on whether the comp variables like the usual
numeric variables are initialized to zero or not .....

Thanks and Regards,
Raveendra.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Jan 11, 2006 6:27 am    Post subject:
Reply with quote

Hi Raveendra,

You can use init to init variables to any values consistant with their data types. The defaults are spaces for alpha/AN types; zeros for numeric types. The zeros will be consistant with the numeric type being inited. For ex. a 2 byte field:

comp signed and unsigned will get X'0000'
comp-3 unsigned will get X'000F' (pic 9 comp-3)
comp-3 signed will get X'000C' (pic S9 comp-3)
display unsigned will get X'F0F0' (pic 9)
display signed will get X'F0C0' (pic S9)

HTH
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 DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm


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