Start of change

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.

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.

Start of changeThe 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.
Start of change
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
COBOL V5 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.
End of change
End of change

INVDATA option syntax

Read syntax diagramSkip visual syntax diagramNOINVDATAINVDATA(,CLEANSIGNNOCLEANSIGNNOFORCENUMCMPFORCENUMCMP)

Default is: NOINVDATA

The default is INVDATA(NOFORCENUMCMP,CLEANSIGN) when INVDATA is specified without suboptions.

Abbreviations are:
  • INVD | NOINVD
  • CS | NOCS
  • FNC | NOFNC
NOINVDATA
When the NOINVDATA option 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.
INVDATA(NOFORCENUMCMP | FORCENUMCMP)
NOFORCENUMCMP is the default when INVDATA is specified and neither FORCENUMCMP nor NOFORCENUMCMP is specified.
When the INVDATA(FORCENUMCMP) option 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 the INVDATA(NOFORCENUMCMP) option 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 does when you use 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 do 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 COBOL V4 or earlier versions NUMPROC(NOPFD) behavior in COBOL V6, use INVDATA(NOFORCENUMCMP) (or simply INVDATA) and NUMPROC(NOPFD) in COBOL V6.
  • To get the COBOL V4 or earlier versions NUMPROC(PFD) behavior in COBOL V6, use INVDATA(NOFORCENUMCMP) (or simply INVDATA) and NUMPROC(PFD) in COBOL V6.
Note: The sign code must be a valid sign code according to the NUMPROC option setting. In addition, the low-order byte must have a valid zone (x'F') with either SIGN IS LEADING or SIGN IS SEPARATE.
INVDATA(CLEANSIGN | NOCLEANSIGN)
CLEANSIGN is the default when INVDATA is specified and neither CLEANSIGN nor NOCLEANSIGN is specified.
When the INVDATA(CLEANSIGN) option is in effect, the compiler generates code to clean the sign nibble of USAGE DISPLAY and USAGE PACKED-DECIMAL data items on input to compare, add, subtract, multiply, and divide operations.
Note: Start of changeCLEANSIGN does not apply to USAGE DISPLAY items defined with SIGN IS SEPARATE.End of change
When the INVDATA(NOCLEANSIGN) option is in effect, the compiler avoids generating code to clean the sign nibble of USAGE DISPLAY and USAGE PACKED-DECIMAL data items on input to compare, add, subtract, multiply, and divide operations, increasing the probability of a S0C7 abend when one of the operands of the operation contains an invalid sign nibble.
Note: The INVDATA option affects the behavior of MOVE statements, comparisons, and computations for USAGE DISPLAY or PACKED-DECIMAL data items that could contain invalid digits, an invalid sign code, or invalid zone bits.
In the following example, you can see a data item with an invalid zone bit 4 in the zone bits in the middle of data item VALUE1, forced in by REDEFINES:

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-IF
In this example,
  • With COBOL V4 or earlier versions, the test is true if the NUMPROC(MIG) option is used, and false for NUMPROC(NOPFD | PFD).
  • With V6.2 or later versions:
    • When you use NOINVDATA, the test is true at OPT(0) and false at OPT(1 | 2).
    • When you use INVDATA(NOFORCENUMCMP), the test is false at any OPT setting.
In all, to ease your migration to COBOL V6:
  • If your digits, sign codes, and zone bits are valid, use NOINVDATA, and if you used NUMPROC(PFD) or NUMPROC(NOPFD) in COBOL V4 or earlier versions, then use the same NUMPROC setting when you use COBOL V6; if you used NUMPROC(MIG) in COBOL V4 or earlier versions, then use NUMPROC(NOPFD) when you use 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. Once you have corrected your programs or systems, you can use the preferred NOINVDATA option. Only if you cannot contain this work and must continue to run with invalid data, consider the following choices for INVDATA:
    • Start of changeIf you are migrating from COBOL V4 or earlier versions and used NUMPROC(MIG) with COBOL V4, then use INVDATA(FORCENUMCMP,NOCLEANSIGN) and NUMPROC(NOPFD) with COBOL V6.2 or later versions to most closely mimic the previous NUMPROC(MIG) behavior when invalid data is present.End of change
    • If you are migrating from COBOL V4 or earlier versions and used NUMPROC(NOPFD) with COBOL V4, then use INVDATA(NOFORCENUMCMP,CLEANSIGN) (or simply INVDATA) and NUMPROC(NOPFD) with COBOL V6.
    • If you are migrating from COBOL V4 or earlier versions and used NUMPROC(PFD) with COBOL V4, then use INVDATA(NOFORCENUMCMP,CLEANSIGN) (or simply INVDATA) and NUMPROC(PFD) with COBOL V6.
Notes:
  • 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) 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.

Performance considerations: NOINVDATA gives better runtime performance than INVDATA does. INVDATA disables some of the optimizations that NUMPROC(PFD) can give.

related references  
NUMCHECK
NUMPROC  

End of change