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

Initilizzation of COMP-3 variables


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

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Tue Aug 16, 2011 11:45 am
Reply with quote

Hi Experts,

I am having some confusion about the way the COMP-3 variables are initialized.

For example the variables are defined in below manner

01 WK-Rahul-1
05 WK-Rahul-11 PIC S9(13)V99.
05 WK-Rahul-12 PIC S9(13)V99.
05 WK-Rahul-13 PIC S9(13)V99.
05 WK-Rahul-14 PIC +9(13)V99.
05 WK-Rahul-15 PIC +9(13)V99.
05 WK-Rahul-16 PIC +9(13)V99.
05 WK-Rahul-17 PIC S9(13)V99 COMP-3.
05 WK-Rahul-18 PIC S9(13)V99 COMP-3.

Someone told me that when we initialize the WK-Rahul-1 like

MOVE ZERO TO WK-Rahul-1. It will initailize WK-Rahul-17 and WK-Rahul-18 with low values instead of zero.

Is this right?

Thanks.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Aug 16, 2011 12:11 pm
Reply with quote

rgupta71 wrote:
Hi Experts,

I am having some confusion about the way the COMP-3 variables are initialized.

For example the variables are defined in below manner

01 WK-Rahul-1
05 WK-Rahul-11 PIC S9(13)V99.
05 WK-Rahul-12 PIC S9(13)V99.
05 WK-Rahul-13 PIC S9(13)V99.
05 WK-Rahul-14 PIC +9(13)V99.
05 WK-Rahul-15 PIC +9(13)V99.
05 WK-Rahul-16 PIC +9(13)V99.
05 WK-Rahul-17 PIC S9(13)V99 COMP-3.
05 WK-Rahul-18 PIC S9(13)V99 COMP-3.

Someone told me that when we initialize the WK-Rahul-1 like

MOVE ZERO TO WK-Rahul-1. It will initailize WK-Rahul-17 and WK-Rahul-18 with low values instead of zero.

Is this right?

Thanks.


Firstly, it is good to format your example, but pointless then to not use the Code button (highlight the text where you want formatting preserved) to keep it all in line. Then use Preview before the final post to check the alignment is what you want.

"Someone" was wrong.

If you move ZERO (or variants thereof, ZEROS, ZEROES) to a group item, you will get Zoned Decimal zeros in every byte of the group item. You will get F0F0F0F0... in every position of every field. If you then try to add to 17 or 18, S0C7.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Aug 16, 2011 1:11 pm
Reply with quote

Hello,

Quote:
Someone told me that when we initialize the WK-Rahul-1 like
We must be quite careful of who we listen to and believe. . .
There is much mis-information around - both from people and the internet.

Putting the code into a test program and looking at the result is most helpful when one is confused icon_confused.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Aug 16, 2011 1:31 pm
Reply with quote

when all else fails,
RTFM:

start with MOVE.
then graduate to the INITIALIZE statement.

There are links to manuals at the top of every page of this forum.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Wed Aug 17, 2011 12:49 pm
Reply with quote

rgupta71 wrote:

Someone told me that when we initialize the WK-Rahul-1 like

MOVE ZERO TO WK-Rahul-1. It will initailize WK-Rahul-17 and WK-Rahul-18 with low values instead of zero.

Is this right?

Thanks.



What is stopping you from doing research by yourself.
Add a display after
Code:
MOVE ZERO TO WK-Rahul-1

go to spool and do a "set hex on" and see what's the content of your 01 level variable.


To understand the content go through the online tutorials about the 3 numeric types namely: Packed Decimal, Zoned Decimal and Binary.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Aug 17, 2011 1:44 pm
Reply with quote

Why include binary and exclude floating-point?

If the 01 is displayed, not much point in setting hex on.

Code:
DISPLAY ">" WK-Rahul-1 "<"


Nothing interesting to look for, all X'F0'.

I suppose from the display you could intuit that none of the subordinate fields conform to picture.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Wed Aug 17, 2011 5:32 pm
Reply with quote

The most important reply here is from nigelosberry, a new user, who is telling you to JUST TRY IT AND SEE WHAT YOU GET, although he didn't yell it.

Do you want the answer to just this question, or do you want to be able to find answers?

Also, your code is bad, because
Code:
01 WK-Rahul-1
needs a period at the end.

Asking folks to review code you have not even compiled or run is not cool.
Back to top
View user's profile Send private message
rgupta71

Active User


Joined: 21 Jun 2009
Posts: 160
Location: Indore

PostPosted: Thu Aug 18, 2011 10:06 am
Reply with quote

I coded the program and checked the output. It is giving x'F0' s display.

Thank You all for your reply.
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 COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts JCL with variables JCL & VSAM 1
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts JCL Variables JCL & VSAM 1
Search our Forums:

Back to Top