Problem:
On the mainframe an unsigned data item with usage COMP-3, containing a sign byte of either 0F or 0C would pass the if zero condition test. In Net Express or Visual COBOL only the field ending in 0F passes a compare test to zero.
Example:
program-id. packzero.
Data Division.
Working-storage section.
01 num-x pic X(3) value x'00000c'.
01 num redefines num-x pic 99V99 COMP-3.
procedure division.
main.
if num = zero
display 'Value is Zero'
else
display 'Value is Non-Zero'
end-if
move x'00000f' to num-x
if num = zero
display 'Value is Zero'
else
display 'Value is Non-Zero'
end-if
Results:
Value is Non-Zero
Value is Zero
On the mainframe the results are:
Value is Zero
Value is Zero
How can we emulate the behavior of the mainframe?
Resolution:
You can get the behavior you are looking for by setting the directive HOSTSIGNS on.
By default in MF COBOL only the 0F is a valid sign byte when the COMP-3 data item does not actually contain a sign character.
The 0C byte is used to denote a positive sign only when the data item itself is actually signed.
This is documented under Help-->Reference-->COBOL Language-->Part 1 Concepts-->Concepts of the COBOL Language-->Class and Category of Data-->Selection of Character Representation and Radix-->COMPUTATIONAL-3 or PACKED-DECIMAL-->Table 7:
Sign Convention in the PICTURE Clause Sign of Data Item Value Sign Half-character, in Hexadecimal
-----------------------------------
To make this behave like the mainframe use HOSTSIGNS and the 0C character will also be recognized.