Example: querying and changing the century window
The following example shows how to query, set, and restore the starting point of the century window using the CEEQCEN and CEESCEN services.
The example
calls CEEQCEN to obtain an integer (OLDCEN
) that
indicates how many years earlier the current century window began.
It then temporarily changes the starting point of the current century
window to a new value (TEMPCEN
) by calling CEESCEN
with that value. Because the century window is set to 30, any two-digit
years that follow the CEESCEN call are assumed to lie within the 100-year
interval starting 30 years before the current system date.
Finally, after it processes dates (not shown) using the temporary century window, the example again calls CEESCEN to reset the starting point of the century window to its original value.
WORKING-STORAGE SECTION.
77 OLDCEN PIC S9(9) COMP.
77 TEMPCEN PIC S9(9) COMP.
77 QCENFC PIC X(12).
. . .
77 SCENFC1 PIC X(12).
77 SCENFC2 PIC X(12).
. . .
PROCEDURE DIVISION.
. . .
** Call CEEQCEN to retrieve and save current century window
CALL "CEEQCEN" USING OLDCEN, QCENFC.
** Call CEESCEN to temporarily change century window to 30
MOVE 30 TO TEMPCEN.
CALL "CEESCEN" USING TEMPCEN, SCENFC1.
** Perform date processing with two-digit years
. . .
** Call CEESCEN again to reset century window
CALL "CEESCEN" USING OLDCEN, SCENFC2.
. . .
GOBACK.