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
.
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.
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.
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 |
|
Default is: NOINVDATA
The
default is INVDATA(NOFORCENUMCMP,CLEANSIGN)
when INVDATA
is
specified without suboptions.
- INVD | NOINVD
- CS | NOCS
- FNC | NOFNC
NOINVDATA
- When the
NOINVDATA
option is in effect, the compiler assumes that all data inUSAGE DISPLAY
andPACKED-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 whenINVDATA
is specified and neitherFORCENUMCMP
norNOFORCENUMCMP
is specified.
INVDATA(CLEANSIGN | NOCLEANSIGN)
CLEANSIGN
is the default whenINVDATA
is specified and neitherCLEANSIGN
norNOCLEANSIGN
is specified.
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.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
- With COBOL V4 or earlier versions, the test is true if the
NUMPROC(MIG)
option is used, and false forNUMPROC(NOPFD | PFD)
. - With V6.2 or later versions:
- When you use
NOINVDATA
, the test is true atOPT(0)
and false atOPT(1 | 2)
. - When you use
INVDATA(NOFORCENUMCMP)
, the test is false at anyOPT
setting.
- When you use
- If your digits, sign codes, and zone bits are valid, use
NOINVDATA
, and if you usedNUMPROC(PFD)
orNUMPROC(NOPFD)
in COBOL V4 or earlier versions, then use the sameNUMPROC
setting when you use COBOL V6; if you usedNUMPROC(MIG)
in COBOL V4 or earlier versions, then useNUMPROC(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 forINVDATA
:- If you are migrating from COBOL V4 or earlier versions and used
NUMPROC(MIG)
with COBOL V4, then useINVDATA(FORCENUMCMP,NOCLEANSIGN)
andNUMPROC(NOPFD)
with COBOL V6.2 or later versions to most closely mimic the previousNUMPROC(MIG)
behavior when invalid data is present. - If you are migrating from COBOL V4 or earlier versions and used
NUMPROC(NOPFD)
with COBOL V4, then useINVDATA(NOFORCENUMCMP,CLEANSIGN)
(or simplyINVDATA
) andNUMPROC(NOPFD)
with COBOL V6. - If you are migrating from COBOL V4 or earlier versions and used
NUMPROC(PFD)
with COBOL V4, then useINVDATA(NOFORCENUMCMP,CLEANSIGN)
(or simplyINVDATA
) andNUMPROC(PFD)
with COBOL V6.
- If you are migrating from COBOL V4 or earlier versions and used
- 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, useINVDATA(FORCENUMCMP,CLEANSIGN)
instead ofZONEDATA(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.