Problem:
How do we get the GNT run the same as the INT?
Resolution:
As int code is not created for speed, there are a few checks that are always performed in int code, but by default they are not done in gnt code to get code that runs faster. This is one of those checks...
Suppose you have the following two data definitions and two statements in a COBOL program:
01 A PIC XXX VALUE SPACES.
01 B PIC XXXX.
01 B2 REDEFINES B PIC 999 USAGE DISPLAY.
MOVE A TO B
...
ADD 1 TO B2
By default in .gnt code you will never get a 163 error, and the code may appear to work, but in reality the results that you get in the B2 variable are totally undefined and you can get anything there but what you expect.
There are quite a few directives that affect the behavior, size and speed of the .gnt code, these directives only affect to the generation phase, so they have no effect in .int code. You know this because in the documentation of the directive in the help says Phase: Generate, as for the CHECKNUM directive:
Properties:
Default: NOCHECKNUM
Phase: Generate
$SET: Initial
The CHECKNUM directive is what you are looking for. By default is set as NOCHECKNUM so no checking is done and the results you get if you do it wrong are undefined. But you can set it to CHECKNUM and then your .gnt code should give you a 163 error if you have the wrong thing in a numeric variable.