ZONEDATA

The ZONEDATA option tells the compiler whether Start of changethe data in USAGE DISPLAY and PACKED-DECIMALEnd of change data items is valid, and if not, what the behavior of the compiler should be.

ZONEDATA option syntax

Read syntax diagramSkip visual syntax diagramZONEDATA(PFDMIGNOPFD)

Default is: ZONEDATA(PFD)

Abbreviations are: ZD(PFD) | ZD(MIG) | ZD(NOPFD)

Each digit of a valid zoned decimal number is represented by a single byte from X'F0' through X'F9'. The 4 high-order bits of each byte are zone bits, and the 4 low-order bits of each byte contain the value of the digit. The 4 high-order bits of the low-order byte for SIGN TRAILING represent the sign of the item. The sign is in the high-order byte with SIGN LEADING, or in a separate byte for SIGN IS SEPARATE.

ZONEDATA(PFD)

When the ZONEDATA(PFD) option is in effect, the compiler assumes that Start of changeall data in USAGE DISPLAY and PACKED-DECIMAL data itemsEnd of change is 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.

ZONEDATA(MIG)

When the ZONEDATA(MIG) option is in effect, the compiler generates instructions to do Start of changenumericEnd of change comparisons that ignore the zone bits of each digit in zoned decimal data items. For example, the zoned decimal value is converted to packed-decimal with a PACK instruction before the comparison. The compiler will also avoid performing known optimizations that might produce a different result than COBOL V4 (or earlier versions) when Start of changea 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 bitsEnd of change.

ZONEDATA(NOPFD)
When the ZONEDATA(NOPFD) option is in effect, the compiler generates instructions for numeric comparisons Start of changeor an alphanumeric comparisonEnd of change of zoned decimal data in the same manner as COBOL V4 (or earlier versions) does when using NUMPROC(NOPFD | PFD) with COBOL V4 (or earlier versions) :
  • In the cases where COBOL V4 (or earlier versions) considered the zone bits, Start of changethe compiler generates an alphanumeric comparison which will alsoEnd of change 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, Start of changethe compiler generates numeric comparisonsEnd of change 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.
Start of changeIn order for the compiler to generate comparisons of zoned decimal data in the same way that COBOL V4 (or earlier versions) did, the NUMPROC suboption used in COBOL Start of changeV6End of change must match the NUMPROC suboption used in COBOL V4 (or earlier versions):End of change
  • To get the COBOL V4 (or earlier versions) NUMPROC(NOPFD) behavior in COBOL Start of changeV6End of change, use ZONEDATA(NOPFD) and NUMPROC(NOPFD) in COBOL Start of changeV6End of change.
  • To get the COBOL V4 (or earlier versions) NUMPROC(PFD) behavior in COBOL Start of changeV6End of change, use ZONEDATA(NOPFD) and NUMPROC(PFD) in COBOL Start of changeV6End of change.

The compiler will also avoid performing known optimizations that might produce a different result than COBOL V4 (or earlier versions) Start of changewhen 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 bitsEnd of change.

Note: Start of changeThe sign codeEnd of change 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.
Note: Start of changeThe ZONEDATA option affects the behaviour 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.End of change
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 'ZONEDATA(MIG) is in effect ' VALUE1                
     ELSE                                                           
        DISPLAY 'ZONEDATA(NOPFD | PFD) is in effect '  VALUE1                
     END-IF
In this example:
  • With COBOL V4 (or earlier versions) or earlier versions, the test is true if the NUMPROC(MIG) option is used, and false for NUMPROC(NOPFD | PFD).
  • Start of changeWith COBOL V5 or later versions:
    • When using ZONEDATA(PFD), the test is true at OPT(0) and false at OPT(1 | 2).
    • When using ZONEDATA(NOPFD), the test is false at any OPT setting.
    End of change
In all, to ease your migration to COBOL Start of changeV6End of change:
  • If your Start of changedigits, sign code, and zone bitsEnd of change are valid, use ZONEDATA(PFD) and the same NUMPROC setting that you used with COBOL V4 (or earlier versions) when using COBOL Start of changeV6End of change.
  • If you have Start of changeinvalid digits, invalid sign code, or invalid zone bitsEnd of change:
    • If you used NUMPROC(MIG) with COBOL V4 (or earlier versions) , use ZONEDATA(MIG) and NUMPROC(NOPFD) with COBOL Start of changeV6End of change.
    • If you used NUMPROC(NOPFD) with COBOL V4 (or earlier versions) , use ZONEDATA(NOPFD) and NUMPROC(NOPFD) with COBOL Start of changeV6End of change.
    • If you used NUMPROC(PFD) with COBOL V4 (or earlier versions) , use ZONEDATA(NOPFD) and NUMPROC(PFD) with COBOL Start of changeV6End of change.
Note: Start of changeIt is not always possible to entirely match the behaviour of the old compiler even with these options when faced with clearly invalid data. For example, even for compares, ZONEDATA(NOPFD) isn't going to give the same result in all cases as COBOL V4.End of change

Performance considerations: ZONEDATA(PFD) gives better runtime performance than ZONEDATA(NOPFD | MIG) does. ZONEDATA(NOPFD | MIG) disables some of the optimizations that NUMPROC(PFD) can give.

related references  
Start of changeNUMCHECKEnd of change
NUMPROC  
ZONECHECK