INVDATA

Default
NOINVDATA
Recommended

NOINVDATA

Because most users have valid data in their USAGE DISPLAY and USAGE PACKED-DECIMAL data items, use NOINVDATA to improve the performance of your application. Even if you find that your programs are processing invalid data at run time with the NUMCHECK compiler option, you should change your programs to avoid processing invalid data and use NOINVDATA.
Note: The goal of the INVDATA option is to provide a behavior that is as compatible as possible with the behavior of programs compiled with COBOL V4 or earlier versions in cases of invalid numeric data. When discrepancies are found, this option will be updated in favor of making the behavior more closely match the behavior of COBOL V4 or earlier versions.

When the INVDATA option is in effect, the compiler will avoid performing known optimizations that might produce a different result than COBOL V4 or earlier versions when a zoned decimal or packed decimal data item has invalid digits or an invalid sign code, or when a zoned decimal data item has invalid zone bits.

The following table provides a quick reference on how to set the INVDATA and NUMPROC options when migrating to COBOL V6.2 or later versions from earlier versions of COBOL, depending on the default value of the NUMPROC option that was used in the earlier version of COBOL and whether or not you have invalid data.
Table 1. Setting INVDATA and NUMPROC options when migrating from earlier COBOL versions
COBOL versions Invalid data present? NUMPROC/ZONEDATA used in COBOL V6.1 or earlier versions INVDATA and NUMPROC settings in COBOL V6.2 or later versions
Pre-COBOL V5 No NUMPROC(MIG) NOINVDATA,NUMPROC(NOPFD)
Pre-COBOL V5 No NUMPROC(NOPFD) NOINVDATA,NUMPROC(NOPFD)
Pre-COBOL V5 No NUMPROC(PFD) NOINVDATA,NUMPROC(PFD)
Pre-COBOL V5 Yes NUMPROC(MIG) INVDATA(FORCENUMCMP,NOCLEANSIGN),NUMPROC(NOPFD)
Pre-COBOL V5 Yes NUMPROC(NOPFD) INVDATA(NOFORCENUMCMP,CLEANSIGN),NUMPROC(NOPFD) or INVDATA,NUMPROC(NOPFD)
Pre-COBOL V5 Yes NUMPROC(PFD) INVDATA(NOFORCENUMCMP,CLEANSIGN),NUMPROC(PFD) or INVDATA,NUMPROC(PFD)
COBOL V5 or later No ZONEDATA(PFD) NOINVDATA
COBOLV5 or later Yes ZONEDATA(NOPFD) INVDATA(NOFORCENUMCMP,CLEANSIGN) or simply INVDATA
COBOL V5 or later Yes ZONEDATA(MIG) INVDATA(FORCENUMCMP,CLEANSIGN)1
  1. INVDATA(FORCENUMCMP,NOCLEANSIGN) is a closer representation of the pre-COBOL V5 NUMPROC(MIG) behavior than INVDATA(FORCENUMCMP,CLEANSIGN) when invalid data is present. If you are not satisfied with the behavior of ZONEDATA(MIG) in COBOL V5 or later versions when invalid data is present, then consider using INVDATA(FORCENUMCMP,NOCLEANSIGN) to more closely mimic the pre-COBOL V5 NUMPROC(MIG) behavior when invalid data is present.

For details about the INVDATA option and how the compiler behaves when the sign code, digits, or zone bits are invalid, see INVDATA in the Enterprise COBOL for z/OS® Programming Guide.

Reasoning
  • When the NOINVDATA option is in effect, the compiler assumes that the data in USAGE DISPLAY and PACKED-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.
  • When the INVDATA(FORCENUMCMP) option is in effect, the compiler must generate additional instructions to do numeric comparisons that ignore the zone bits of each digit in zoned decimal data items. For example, a zoned decimal value might be converted to packed-decimal with a PACK instruction before the comparison.
  • When the INVDATA(NOFORCENUMCMP) option is in effect, the V6 compiler must generate a sequence that treats the invalid zone bits, the invalid sign code and the invalid digits in the same way as the V4 compiler, even when that sequence is less efficient than another possible sequence. The following cases are considered:
    • In the cases where COBOL V4 or earlier versions considered the zone bits, the compiler generates an alphanumeric comparison which will also consider the zone bits of each digit in zoned decimal data items. The zoned decimal value remains as zoned decimal.
    • In the cases where COBOL V4 or earlier versions ignored 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.
Source Example
01 A PIC S9(5)V9(2).
01 B PIC S9(7)V9(2).
COMPUTE B = A * 100

In this example, the multiplication is 32% faster with NOINVDATA than INVDATA. With NOINVDATA, the compiler can use a shift instruction instead of a multiplication. With INVDATA, it must perform the more expensive multiplication.

Related references
INVDATA (Enterprise COBOL for z/OS Programming Guide)