INVDATA
- Default
- NOINVDATA
- Recommended
-
NOINVDATA
Because most users have valid data in theirUSAGE DISPLAY
andUSAGE PACKED-DECIMAL
data items, useNOINVDATA
to improve the performance of your application. Even if you find that your programs are processing invalid data at run time with theNUMCHECK
compiler option, you should change your programs to avoid processing invalid data and useNOINVDATA
.Note: The goal of theINVDATA
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 theINVDATA
andNUMPROC
options when migrating to COBOL V6.2 or later versions from earlier versions of COBOL, depending on the default value of theNUMPROC
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 versionsINVDATA
andNUMPROC
settings in COBOL V6.2 or later versionsPre-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)
orINVDATA
,NUMPROC(NOPFD)
Pre-COBOL V5 Yes NUMPROC(PFD)
INVDATA(NOFORCENUMCMP,CLEANSIGN)
,NUMPROC(PFD)
orINVDATA
,NUMPROC(PFD)
COBOL V5 or later No ZONEDATA(PFD)
NOINVDATA
COBOLV5 or later Yes ZONEDATA(NOPFD)
INVDATA(NOFORCENUMCMP,CLEANSIGN)
or simplyINVDATA
COBOL V5 or later Yes ZONEDATA(MIG)
INVDATA(FORCENUMCMP,CLEANSIGN)
1INVDATA(FORCENUMCMP,NOCLEANSIGN)
is a closer representation of the pre-COBOL V5NUMPROC(MIG)
behavior thanINVDATA(FORCENUMCMP,CLEANSIGN)
when invalid data is present. If you are not satisfied with the behavior ofZONEDATA(MIG)
in COBOL V5 or later versions when invalid data is present, then consider usingINVDATA(FORCENUMCMP,NOCLEANSIGN)
to more closely mimic the pre-COBOL V5NUMPROC(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
andPACKED-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.
- When the NOINVDATA option is in effect, the compiler assumes that
the data in
- 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.