View previous topic :: View next topic
|
Author |
Message |
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
How are these fields defined ?
> Comp-3 value
> group item
> elementary item |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
All group items are considered as ALPHANUMERIC, irrespective of their elementary declarations.
See if you get your clarification!
More 'Clarification' needs more 'Information' ! |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
venosol Warnings : 1 New User
Joined: 16 Nov 2006 Posts: 43 Location: Bangalore
|
|
|
|
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 |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|