Troubleshooting
Problem
Some users found that their programs are producing different results in Enterprise COBOL for z/OS V5.x than they did in previous versions of Enterprise COBOL for z/OS.
Cause
The problem occurs when data items declared as USAGE DISPLAY contain values that are incompatible with their data description. In the case of invalid data in programs, Enterprise COBOL for z/OS V5.x does not guarantee the results to be the same as produced with previous versions of Enterprise COBOL for z/OS, unless using compiler options that could guarantee certain behaviors between Enterprise COBOL for z/OS 5.x and previous versions of Enterprise COBOL for z/OS.
Enterprise COBOL for z/OS V5.x also introduces a method of detecting invalid zone bits so that the user could address the problem.
Please note that the differences in behavior with invalid programs or data may also be observed at different OPT levels in Enterprise COBOL for z/OS V5.x.
Environment
Users migrating to Enterprise COBOL for z/OS V5.x from previous versions of the Enterprise COBOL for z/OS.
Diagnosing The Problem
1. How to locate the source of invalid data in zoned decimal (numeric DISPLAY) data items.
APAR PI40323/PI40822 available in the June 2015 PTF for Enterprise COBOL V5.1 and in the May 2015 PTF for Enterprise COBOL V5.2 introduces the new compile-time option ZONECHECK that allows users to specify implicit IF NUMERIC class tests for zoned decimal data items that are used as senders in COBOL statements.
ZONECHECK option syntax
+--NOZONECHECK--------------+
| |
>>-+---------------------------+-->>
| |
+--ZONECHECK--(-+--MSG--+-)-+
| |
+--ABD--+
Default: NOZONECHECK
Abbreviations: ZC
MSG
The MSG suboption requests that an IF NUMERIC test be done
on every use of zoned decimal data items as senders, and if
the data is invalid (for example, NOT NUMERIC), a runtime
warning message with the line number and data item name is
issued.
ABD
The ABD suboption requests that an IF NUMERIC test be done
on every use of zoned decimal data items as senders, and if
the data is invalid (for example, NOT NUMERIC), a
terminating message is issued that causes an abend.
Both ZONECHECK(MSG) and ZONECHECK(ABD) result in the compiler generating an implicit numeric class test for each zoned decimal data item that is referenced as a sender in a COBOL statement. Receivers are not checked, unless they are both a sender and a receiver, such as data item B in the following sample statements:
ADD A TO B
DIVIDE A INTO B
COMPUTE B = A + B
INITIALIZE B REPLACING ALPHANUMERIC BY B
1. If the data item is NOT NUMERIC, the compiler will issue:
- a warning message for ZONECHECK(MSG)
- a terminating message for ZONECHECK(ABD)
2. If the data item is NUMERIC, the external behavior of the statement is the same as NOZONECHECK, other than being slower.
Performance considerations:
ZONECHECK(MSG) and ZONECHECK(ABD) are much slower than NOZONECHECK, depending on how many zoned decimal data items are used in COBOL statements in a program.
2. How to determine what Enterprise COBOL for z/OS V5.x compile options to use if USAGE DISPLAY data items may contain invalid zone bits.
Comparisons using data with invalid zone bits in USAGE DISPLAY data items may produce different results in COBOL applications compiled with Enterprise COBOL for z/OS V5.x compared to previous versions of Enterprise COBOL for z/OS.
The problem occurs due to Enterprise COBOL for z/OS V5.x assuming that the zone bits were valid so that comparisons could be done with instructions that were optimized to string compares rather than instructions to convert to numeric and do numeric compares in relation conditions.
Enterprise COBOL for z/OS V5.x users who would like their applications generate the same results as they did with earlier versions of Enterprise COBOL for z/OS, will need to recompile their applications with the correct ZONEDATA suboption.
In general, please follow these guidelines which would help you to ease your migration to Enterprise COBOL for z/OS V5.x:
1. If your zone bits are valid:
- use ZONEDATA(PFD) and the same NUMPROC setting that you used with previous versions of Enterprise COBOL for z/OS when using Enterprise COBOL for z/OS V5.x
2. If you have invalid zone bits:
- If you used NUMPROC(MIG) with previous versions of Enterprise COBOL for z/OS, use ZONEDATA(MIG) and NUMPROC(NOPFD) with Enterprise COBOL for z/OS V5.x.
- If you used NUMPROC(NOPFD) with previous versions of Enterprise COBOL for z/OS, use ZONEDATA(NOPFD) and NUMPROC(NOPFD) with Enterprise COBOL for z/OS V5.x.
- If you used NUMPROC(PFD) with previous versions of Enterprise COBOL for z/OS, use ZONEDATA(NOPFD) and NUMPROC(PFD) in Enterprise COBOL for z/OS V5.x.
When comparing USAGE DISPLAY data items with ZONEDATA(NOPFD) Enterprise COBOL for z/OS V5.x will behave like previous versions of Enterprise COBOL for z/OS when NUMPROC(NOPFD|PFD) was used.
When comparing USAGE DISPLAY data items with ZONEDATA(MIG), Enterprise COBOL for z/OS V5.x will behave like previous versions of Enterprise COBOL for z/OS when NUMPROC(MIG) was used.
ZONEDATA option syntax:
+--PFD--+
| |
>>---ZONEDATA--(-+--MIG--+-)--->>
| |
+-NOPFD-+
Default: ZONEDATA(PFD)
Abbreviations: ZD
Each digit of a valid zoned decimal number is represented by a
single byte X'F0' through X'F9'. The 4 high-order bits of each
byte are zone bits . The 4 low-order bits of each byte contain
the value of the digit. The 4 high-order bits of the low-order
byte (for SIGN TRAILING) represent the sign of the item.
The sign is in the high-order byte with SIGN LEADING, or in a
separate byte for SIGN IS SEPARATE.
ZONEDATA(PFD)
When the ZONEDATA(PFD) option is in effect, the compiler
assumes that the zone bits in zoned decimal data items are
valid, and generates the most efficient code possible to
make numeric comparisons. For example, the compiler might
generate a string comparison to avoid numeric conversion.
ZONEDATA(MIG)
When the ZONEDATA(MIG) option is in effect, the compiler
generates instructions to do numeric comparisons that
ignore the zone bits of each digit in zoned decimal data
items. For example, the zoned decimal value is converted
to packed-decimal with a PACK instruction before the
comparison. Start of change The compiler will also avoid
performing known optimizations that might produce a
different result than COBOL V4 when a zoned decimal data
item has invalid zone bits.
ZONEDATA(NOPFD)
When the ZONEDATA(NOPFD) option is in effect, the compiler
generates instructions for numeric comparisons of zoned
decimal data in the same manners as COBOL V4 does:
In the cases where COBOL V4 considered the zone bits,
the numeric comparisons consider the zone bits of each
digit in zoned decimal data items. The zoned decimal value
remains as zoned decimal and a string comparison is used.
In the cases where COBOL V4 ignored the zone bits, the
numeric comparisons ignore the zone bits of each digit in
zoned decimal data items. The zoned decimal value is
converted to packed-decimal with a PACK instruction
before the comparison.
The compiler will also avoid performing known optimizations
that might produce a different result than COBOL V4 when a
zoned decimal data item has invalid zone bits.
Note: The sign zone must be a valid sign according to the
NUMPROC compiler option setting. In addition, the low-order
byte must have a valid zone (x'F') for unsigned and signed
with either SIGN IS LEADING or SIGN IS SEPARATE.
Related Information
Was this topic helpful?
Document Information
Modified date:
08 August 2018
UID
swg21961494