The CENTWIN run-time or installation option acts on 2-digit year data. CENTWIN generates a century window (for example, 1950 through 2049) that determines the century to which a 2-digit year belongs. At run-time, CENTWIN can be specified as either a PARM option or a SORT/MERGE control statement parameter. CENTWIN ensures that year data spanning centuries will be sequenced correctly. Without CENTWIN processing, an ascending sort would sequence the year 01 before the year 98. With CENTWIN processing, the 01 field could be recognized as a twenty-first century date (2001) and would thus be sequenced after 98 (1998).
For more information on specifying the CENTWIN option, see CENTWIN.
CENTWIN SORT/MERGE processing only applies to data defined as year data formats: Y2B, Y2C, Y2D, Y2P, Y2S, Y2Z, and the full-date formats (Y2T, Y2U, Y2V, Y2W, Y2X, and Y2Y). These data formats enable MFX to process 2-digit year fields as 4-digit years. A related data format, PD0, can be used to process the month and day portions of packed decimal date fields. To correctly specify date fields for CENTWIN SORT processing, you should be familiar with the CENTWIN-related data formats.
The following describes each of the year data formats and provides SORT control statement examples:
The Y2B Format
This format is used to sequence 2-digit, 1-byte binary year data with CENTWIN processing. The binary values are converted to decimal, and the two low order digits are used as year data. Thus, while binary and decimal values range from 00 to 255, year values range from 00 to 99. The relationship between binary, decimal and year values is shown in the following table:
|
The Y2C and Y2Z Formats
These formats represent 2-digit, 2-byte year data in either character (Y2C) or zoned decimal (Y2Z) format. Either Y2C and Y2Z formats can be used with data of the form
X'xyxy'
where y is a hexadecimal year digit 0-9 and x is hexadecimal 0 through F. Y2C and Y2Z ignore the x digits, leaving yy, the 2-digit unsigned year representation.
Suppose you have a character or zoned decimal date field mmddyy that begins at byte 20. You can use either Y2C or Y2Z to process the yy field. As the following example indicates, you could specify three sort keys to correctly sort this date:
The yy field (24,2) will be processed according to the century window setting. For example, isf CENTWIN=1945, the field yy=45 will be sequenced as if it were 1945, and yy=44 would be sequenced as if it were 2044. Thus, for an ascending sort, 44 would follow 45.
The Y2D Format
This format is used to sequence 2-digit, 1-byte packed decimal year data with CENTWIN processing. Use Y2D to extract the year data yy from packed decimal date fields. For example, consider a 3-byte packed decimal data field defined as
X'yyddds'
This field has the year yy in the first byte and the day ddd in bytes 2 and 3. The packed decimal sign s would be in the last digit (half byte) of the third byte. To sort this date field, which begins at byte 20, with 4-digit year processing, use the following SORT control statement:
The Y2P Format
This format is used to sequence 2-digit, 2-byte packed decimal year data with CENTWIN processing. Use Y2P to extract the year data yy from packed decimal date fields spanning 2 bytes. For example, a packed decimal date of the form yymmdd would be stored as 4 bytes:
yymmdd = X'0yymmddC'
where the trailing C (sometimes F) is a positive sign and the leading 0 pads the field on the left to make an even number of digits.
Notice that the components of the date span bytes:
0y ym md dC
Y2P handles this condition by ignoring the first and last half bytes of the 2-byte field specification. Thus, Y2P processes 0yym as yy, ignoring the leading digit (0) and the trailing digit m that is part of the month.
The following example uses Y2P to sort the year portion of the date field, which begins at byte 20:
The field specification 20,2,Y2P treats X'0yym' as X'yy', and CENTWIN processing sorts yy as a 4-digit year yyyy.
The PD0 format, described below, can assist Y2P by processing month and day data that overlap year data in the original field.
The Y2S Format
This format is used to sequence 2-digit, 2-byte character or zoned decimal data. The Y2S format is identical to Y2C and Y2Z for valid numeric data, but Y2S treats data that begin with X'00', X'40', or X'FF' as non-year data. Thus, the Y2S format can distinguish records that have non-year data in the first byte of the year field, allowing such records to be sorted differently from other records.
Y2S treats non-year data as follows:
-
Data with binary zeros (X'00') or a blank (X'40') in the first byte will not have century window processing applied to it. Instead, such data will be collated in sequence, before valid numeric year data for ascending order or after the year data for descending order.
-
Data with all binary ones (X'FF') in the first byte will also not have century window processing applied to it. Instead, such data will be collated after valid year numeric data for ascending order or before the year data for descending order.
-
Zones are ignored, as for Y2C and Y2Z, except for data where the first byte begins with X'00', X'40', or X'FF'.
As an example, suppose you want to preserve the input order of header and trailer records at the start or end of the file, and your header/trailer records are identified by binary zeros (X'00'), a blank (X'40'), or binary ones (X'FF') in the first byte of the date field.
The Y2S format allows CENTWIN to identify the header/trailer records and treat them differently from other records. Presuming the year data begin in column 20, you would use the following sort key specification:
The yy field (20,2) will be processed according to the century window setting. For CENTWIN=1945, data with header and trailer records would be sorted as follows:
Note that if the above data were sorted as Y2C or Y2Z format, the output order would be different because the records starting with X'00', X'40', and X'FF' would be interpreted as numeric years. For example, suppose the fields in the above list were defined as Y2Z and sorted with EQUALS:
The data would be processed as follows:
|
The header and trailer records are sequenced as year data according to the CENTWIN setting (CENTWIN=1945), and they lose their position at the start and end of the file.
The PD0 Format
This format is used to sequence 2-8 byte packed decimal data. PD0 ignores the first digit and trailing sign during processing. PD0 is normally used in conjunction with the Y2P data format. The Y2P format is used to process the 2-digit year portion of a packed decimal date field, while the PD0 format is used to process the month and day portion of the field.
Although PD0 is typically used with Y2P, the PD0 format itself is not affected by CENTWIN processing.
Consider the packed decimal date field used in the example above:
yymmdd = X'0yymmddC'
where the trailing C (sometimes F) is a positive sign and the leading 0 pads the field on the left to make an even number of digits.
Notice that the components of the date span bytes:
0y ym md dC
The date can be processed as follows:
-
Y2P processes the year component X'0yym' as X'yy'.
-
PD0 processes the month and day components X'ymmddC' as X'mmdd'.
The following SORT control statement can be used to sort the entire date with CENTWIN processing:
Full-Date Formats
Full-date formats can be used to sort or merge various date fields, processing dates ending or starting with year digits. They also process non-date data that are used with dates. For a full description of full-date formats, see the following section.