INVDATA
The INVDATA option tells the compiler whether the data in USAGE DISPLAY and PACKED-DECIMAL data items is valid, and if not, what the behavior of the compiler should be.
Because most users have valid data in their USAGE DISPLAY and USAGE PACKED-DECIMAL data items, they should use NOINVDATA, even if they use NUMPROC=NOPFD. 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.
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.
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 | INVDATA=(NO),NUMPROC=NOPFD |
Pre-COBOL V5 | No | NUMPROC=NOPFD | INVDATA=(NO),NUMPROC=NOPFD |
Pre-COBOL V5 | No | NUMPROC=PFD | INVDATA=(NO),NUMPROC=PFD |
Pre-COBOL V5 | Yes | NUMPROC=MIG | INVDATA=(FORCENUMCMP,NOCLEANSIGN),NUMPROC=NOPFD |
Pre-COBOL V5 | Yes | NUMPROC=NOPFD | INVDATA=(NOFORCENUMCMP,CLEANSIGN),NUMPROC=NOPFD |
Pre-COBOL V5 | Yes | NUMPROC=PFD | INVDATA=(NOFORCENUMCMP,CLEANSIGN),NUMPROC=PFD |
COBOL V5 or later | No | ZONEDATA=PFD | INVDATA=(NO) |
COBOL V5 or later | Yes | ZONEDATA=NOPFD | INVDATA=(NOFORCENUMCMP,CLEANSIGN) |
COBOL V5 or later | Yes | ZONEDATA=MIG | INVDATA=(FORCENUMCMP,CLEANSIGN)1 |
|
- Default
- INVDATA=(NO)
- (NO)
- When INVDATA=(NO) is in effect, the compiler assumes that all data in USAGE DISPLAY and PACKED-DECIMAL data items is valid, and generates the most efficient code possible. For example, the compiler might generate a string comparison to avoid numeric conversion.
- (FORCENUMCMP | NOFORCENUMCMP)
-
When INVDATA=(FORCENUMCMP) is in effect, the compiler generates instructions to do comparisons of zoned decimal data items that ignore the zone bits of each digit. For example, the zoned decimal value is converted to packed-decimal with a PACK instruction before the comparison.
When INVDATA=(NOFORCENUMCMP) is in effect, the compiler generates instructions for numeric comparisons or an alphanumeric comparison of zoned-decimal data in the same manner as COBOL V4 or earlier versions do when using NUMPROC=(NOPFD | PFD) with COBOL V4 or earlier versions:- 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, the compiler generates numeric comparisons that 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.
In order for the compiler to handle zone bits in the same way as COBOL V4 or earlier versions did when generating comparisons of zoned-decimal data, the NUMPROC suboption used in COBOL V6 must match the NUMPROC suboption used in COBOL V4 or earlier versions:- To get the COBOL V4 or earlier versions NUMPROC=(NOPFD) behavior in COBOL V6, use INVDATA=(NOFORCENUMCMP) and NUMPROC=(NOPFD) in COBOL V6.
- To get the COBOL V4 or earlier versions NUMPROC=(PFD) behavior in COBOL V6, use INVDATA=(NOFORCENUMCMP) and NUMPROC=(PFD) in COBOL V6.
Note: The sign code must be a valid sign code 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. - (CLEANSIGN | NOCLEANSIGN)
- CLEANSIGN is the default when INVDATA is specified and neither CLEANSIGN nor NOCLEANSIGN is specified.
77 VALUE0 PIC X(4) VALUE '00 0'. *> x'F0F040F0'
77 VALUE1 REDEFINES VALUE0 PIC 9(4).
PROCEDURE DIVISION.
IF VALUE1 = ZERO
DISPLAY 'INVDATA(FORCENUMCMP) is in effect ' VALUE1
ELSE
DISPLAY 'INVDATA(NOFORCENUMCMP) is in effect ' VALUE1
END-IFCopy code
- With COBOL V4 or earlier versions, the test is true if the NUMPROC=(MIG) option is used, and false for NUMPROC=(NOPFD | PFD).
- With COBOL V5 or later versions:
- When using INVDATA=(NO), the test is true at OPT=(0) and false at OPT=(1 | 2).
- When using INVDATA=(NOFORCENUMCMP), the test is false at any OPT setting.
- If your digits, sign codes, and zone bits are valid, use INVDATA=(NO), and if you used NUMPROC=PFD or NUMPROC=NOPFD in COBOL V4 or earlier versions, then use the same NUMPROC setting when using COBOL V6; if you used NUMPROC=(MIG) in COBOL V4 or earlier versions, then use NUMPROC=NOPFD when using COBOL V6.
- If you have invalid digits, invalid sign codes, or invalid zone
bits in your data, change your programs or systems so that your programs
do not have invalid data in numeric data items at run time.When you have corrected your programs or systems, you can use the preferred INVDATA=(NO) option. Only if you cannot contain this work and must continue to run with invalid data, consider the following choices for INVDATA:Notes:
- If you used NUMPROC=(MIG) with COBOL V4 or earlier versions, use INVDATA=(FORCENUMCMP,NOCLEANSIGN) and NUMPROC=(NOPFD) with COBOL V6.
- If you used NUMPROC=(NOPFD) with COBOL V4 or earlier versions, use INVDATA=(NOFORCENUMCMP,CLEANSIGN) and NUMPROC=(NOPFD) with COBOL V6.
- If you used NUMPROC=(PFD) with COBOL V4 or earlier versions, use INVDATA=(NOFORCENUMCMP,CLEANSIGN) and NUMPROC=(PFD) with COBOL V6.
- If you completed migration from COBOL V4 or earlier versions to COBOL V5 or V6 in the past and used the deprecated ZONEDATA=(MIG) option in COBOL V5 or V6 and are satisfied with the behavior, use INVDATA=(FORCENUMCMP,CLEANSIGN) now instead of ZONEDATA=(MIG).
- It is not always possible to entirely match the behavior of the old compiler even with these options when faced with clearly invalid data. For example, even for comparisons, INVDATA=(NOFORCENUMCMP) does not give the same result in all cases as COBOL V4 does.
Performance consideration: INVDATA=(NO) gives better runtime performance than INVDATA(NOFORCENUMCMP | FORCENUMCMP,NOCLEANSIGN | CLEANSIGN) does. INVDATA(NOFORCENUMCMP | FORCENUMCMP,NOCLEANSIGN | CLEANSIGN) disables some of the optimizations that NUMPROC=(PFD) can give.