I have checked the above link but the material was not much clear to explain my doubt. I think giving an example would help.
For eg. If I define a variable PIC 9(04)PP and move the value 1234 in it and try displaying the same value the value then the data that gets displayed is 0012.
However if I have 2 fields one var-1 PIC 9(04) and var-2 PIC 9(04)PP then if I move 1234 in var-1 and 1234 in var-2 and then do the following things:
display var-1 (it displays 1234)
display var-2 (it displays 0012)
add both variables i.ae., var-1 + var-2 (it displays 2434)
I would like to know whats the significance of using PP ? and why does it behave differently while displaying the data and while using it for calculations.
Joined: 06 Jun 2008 Posts: 8165 Location: East Dubuque, Illinois, USA
P in a PICTURE is a scaling factor -- having two of them means the value of the variable is expressed in hundreds. When you move 1234 to the field, the 34 is discarded since only the hundreds and more significant digits will be kept. So when you display the value, you see 12 (i.e., 12 hundred). Adding the two variables together, 1234 + 1200 = 2434, so the system is showing the expected behavior. There is no difference in behavior; there's a problem in how you see the behavior but COBOL is consistent and follows the manual in this case.