by Robert Sample » Thu Jul 12, 2012 5:02 pm
I think the first thing you need to do is to make crystal clear exactly what you are trying to do. You mentioned a report field of PIC X(4) -- does this mean you need to show the characters of the field since reports are usually read by humans? If so, you need to be mindful of Dolly Parton's advice ("you can't put 10 pounds of potatoes in a 5 pound sack") -- six characters before the decimal and two after the decimal means you need at least 8 characters to display the data for a human (9 if you count a decimal point, which you should). 4 characters will not allow anybody to look at the field and know what the data is without using a hexadecimal display.
If, on the other hand, your goal is merely to store the data in a 4-byte field, then you need to find the COBOL Language Reference manual and read up on internal formats for data. A PIC S9(6)V99 COMP-3 variable takes up 5 characters just like a PIC S9(7)V99 so you gain nothing by using a 4-byte variable, anyway. And using a 4-byte variable means you're going to lose two digits from the original value -- either the first two or the last two, most likely, depending upon exactly what you code up.