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
 
Initilizzation of COMP-3 variables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Initilizzation of COMP-3 variables
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Tue Aug 16, 2011 12:11 pm    Post subject: Re: Initilizzation of COMP-3 variables
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

Site Director


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

PostPosted: Tue Aug 16, 2011 1:11 pm    Post subject:
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: 6970
Location: porcelain throne

PostPosted: Tue Aug 16, 2011 1:31 pm    Post subject:
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    Post subject: Re: Initilizzation of COMP-3 variables
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Wed Aug 17, 2011 1:44 pm    Post subject: Reply to: Initilizzation of COMP-3 variables
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

Active Member


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

PostPosted: Wed Aug 17, 2011 5:32 pm    Post subject:
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    Post subject: Reply to: Initilizzation of COMP-3 variables
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    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 Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
No new posts CONDITIONAL USING COMP-2 WITH PROBLEMS. JOSUEGENTIL COBOL Programming 7 Wed Nov 08, 2017 11:13 pm
No new posts how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am
This topic is locked: you cannot edit posts or make replies. Need help how to pass the ESP variabl... Venkichaitu JCL & VSAM 12 Thu Nov 02, 2017 3:53 am
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm

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