why we need to use decalre a group item and elementary item.
You mean this?
02 ws-num3 pic s9(6)v99.
You dont have to..
You can always do following.
01 ws-num3 pic s9(6)v99.
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.
move ws-num1 to ws-num2
This is considered as an alphanumeric move, so it giving you unexpected results.
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
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.