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
 

 

Move comp-3 values is displaying as abnormal value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Wed Apr 04, 2007 1:41 pm    Post subject: Move comp-3 values is displaying as abnormal value
Reply with quote

When I move Comp-3 value to group item it is displaying abnormal value and when the same value is sent it to an elementary item of the group it is giving the correct output.


Please calrify me on this.
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Apr 04, 2007 1:42 pm    Post subject: Re: move comp-3 values.
Reply with quote

How are these fields defined ?
> Comp-3 value
> group item
> elementary item
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Wed Apr 04, 2007 6:52 pm    Post subject:
Reply with quote

All group items are considered as ALPHANUMERIC, irrespective of their elementary declarations.
See if you get your clarification!
More 'Clarification' needs more 'Information' ! icon_smile.gif
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: Wed Apr 04, 2007 10:10 pm    Post subject:
Reply with quote

Hello,

It is best to not move a packed-decimal field to a group item.

What purpose does moving a comp-3 field to a group field serve?
Back to top
View user's profile Send private message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Thu Apr 05, 2007 12:08 pm    Post subject:
Reply with quote

dick scherrer wrote:
Hello,

It is best to not move a packed-decimal field to a group item.

What purpose does moving a comp-3 field to a group field serve?


01 ws-num1 pic s9(4)v99 comp-3

01 ws-num2.
02 ws-num3 pic s9(6)v99.

compute ws-num1 = 3245.56
move ws-num1 to ws-num3
display ws-num3
move ws-num1 to ws-num2
display ws-num2


ws-num3 is having correct value
ws-num2 is having abormal value

Ofcourse we can use elementary item only but i why we need to use decalre a group item and elementary item.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Thu Apr 05, 2007 1:01 pm    Post subject:
Reply with quote

Quote:
why we need to use decalre a group item and elementary item.

You mean this?
Code:
01 ws-num2.
02 ws-num3 pic s9(6)v99.


You dont have to..
You can always do following.
Code:
01 ws-num3 pic s9(6)v99.
or
77 ws-num3 pic s9(6)v99.

As i said previously, group items are persieved as alphanumeric.
While generating assembly code for the numeric move between variable of different types, COBOL compiler generates code to 'align' two variables (unpacking/packing) so as to have correct computations between numbers with different declarations.
Code:
move ws-num1 to ws-num2

This is considered as an alphanumeric move, so it giving you unexpected results.
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: Thu Apr 05, 2007 10:11 pm    Post subject:
Reply with quote

Hello,

This "ws-num2 is having abormal value " is incorrect. "ws-num2" has the correct value. What you tried to do was a character display of a packec-decimal field. What you "got" is the alphanumeric characters represented by the packed value.

Rather than spending time trying to find ways to do this, it is far better to use numeric fields for numeric data.
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 BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 1 Tue Jul 25, 2017 12:12 am
No new posts Reg:Displaying the particular month o... bhavana yalavarthi All Other Mainframe Topics 4 Sat Jul 08, 2017 8:13 pm
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm


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