Joined: 31 Oct 2006 Posts: 965 Location: Richmond, Virginia
A halfword binary can hold your value, but COBOL strictly honors the field definition, which says 4 digits, so the compiled COBOL code truncates the leftmost digit.
E.g., for PIC 9(1) COMP, although a halfword is used, only unsigned single-digit values are stored.
Since PIC 9(5) COMP thru 9(9) COMP allocate a fullword, I'm not sure how you can do this directly in COBOL.
I think it is unwise to store a 5-digit number in a halfword or SMALLINT, as it will not hold any 5-digit number. That's why PIC 9(1) COMP thru 9(4) COMP use a halfword - all 4-digit values can be accomodated.