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

Move comp-3 values is displaying as abnormal value


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 1448
Location: Chicago, IL

PostPosted: Wed Apr 04, 2007 1:42 pm
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: 691
Location: Earth

PostPosted: Wed Apr 04, 2007 6:52 pm
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

Moderator Emeritus


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

PostPosted: Wed Apr 04, 2007 10:10 pm
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
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: 691
Location: Earth

PostPosted: Thu Apr 05, 2007 1:01 pm
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

Moderator Emeritus


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

PostPosted: Thu Apr 05, 2007 10:11 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts IBM OnDemand Folders displaying to al... IBM Tools 6
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
Search our Forums:

Back to Top