FORMAT OF Special Register

The FORMAT OF phrase of the PROCEDURE DIVISION creates an implicit special register, called the FORMAT OF special register, whose contents equal the FORMAT literal of the data item referenced by the identifier. The FORMAT OF special register can only be specified for data items of class date-time. The length of this special register depends on the literal or locale specified in the FORMAT phrase for the data item.

The FORMAT OF special register has the implicit definition:
    USAGE DISPLAY, PICTURE X(n)
    where n equals the number of bytes of the implicit or explicit
    FORMAT literal.
For example, consider the following data description entry for date data item date2:
    05 date2 FORMAT DATE IS '%d,%m,%y'.
The following MOVE statement uses the intrinsic function CONVERT-DATE-TIME to convert date data item date3 into the format of date data item date2. The FORMAT OF phrase creates an implicit special register whose content would be %d,%m,%y.
    MOVE FUNCTION CONVERT-DATE-TIME(date3, DATE, FORMAT OF date2)
              TO alpha-num-date.
The length of the special register in this example is 8.
The following rules apply:
  • The FORMAT OF special register cannot be modified, and can only be specified in the PROCEDURE DIVISION, where a FORMAT non-numeric literal is allowed.
  • A separate FORMAT OF special register exists for each identifier referenced with the FORMAT OF phrase