`RTVCEN          RETRIEVE CENTURY                       TAARPHD`
```
The Retrieve  Century command provides  a solution  for a sliding  date
window.   The intent is  that you would input  a 2 digit  year (such as
96  or 02) and  be returned both a  2 digit century (such  as 19 or 20)
and a  one digit  century (such  as 0  or 1).   The  sliding window  is
based  on 50  years in  either direction  from the  current year.   The
function  may used  as a  command, a  sub program,  or a  subroutine in

A typical series of commands would be:

DCL           &YY *CHAR LEN(2)
DCL           &CEN2 *CHAR LEN(2)
DCL           &CEN1 *CHAR LEN(1)
.
.            /* Your code to prime &YY */
.
RTVCEN        INPUTYEAR(&YY) RTNCEN2(&CEN2) RTNCEN1(&CEN1)

Your program  then uses  either  or both  &CEN2 or  &CEN1 to  assume  a
century.

Some business  data such  as those dealing  with birthdays  or property
records  will  exceed  a 100  year  span  and can  only  be  handled by
providing for 4 digit dates throughout an application.

Most business data  does not last  more than 50  years.   Consequently,
it is possible to assume  a century for many applications by  using a 2
digit  year (such  as 98 or  02) to  determine a  2 byte  century value
(such as 19 or 20) or a 1 byte century value (such as 0 or 1).

A  sliding window differs from a fixed  window.  A typical fixed window
solution would assume:

Years  40 - 99 = 20th century
Years  00 - 39 = 21st century

The advantage of the  sliding window approach allows the program  to be
used  for hundreds or  thousands of  years without  change.   A typical
fixed window approach requires a change in about 40 years.

The  Retrieve Century  function  determines the  current year  and then
assumes a  century  based  on  50  years in  either  direction  of  the
current year.

For  example, based  on  the following  current  years, the  subroutine
would assume a century:

Current year        Input year assumptions
------------     -----------------------------

1994          45 - 99 = 19     00 - 44 = 20
1998          49 - 99 = 19     00 - 48 = 20
2000          51 - 99 = 19     00 - 50 = 20
2030          81 - 99 = 19     00 - 80 = 20
2060          11 - 99 = 20     00 - 10 = 21

Different interfaces
--------------------

The following interfaces are supported:

**   The  command RTVCEN  which may  only  be used  in a  CL program.
The command  interface  is adequate  if  you are  not  going  to
iterate on  the  command (such  as use  it for  every data  base

**   A  sub  program  TAARPHDR  which  is  the  processing  piece  of
RTVCEN.

**   As a subroutine in your RPG program.

**   As a subroutine in your RPGLE program.

A test program to allow you to try different assumed years.

Performance
-----------

The  command interface  is not efficient,  but is adequate  if you need
the function only once or a few times.

Better  performance  can   be  gained  by   calling  the  sub   program
(TAARPHDR3) or by using a subroutine in your RPG program.

If you  are calling the sub program  on an iterative basis,  be sure to
set  the SETLR parameter to *NO to  avoid reactivating the sub program.

Using a sub program approach
----------------------------

You  would  call  the  program  with  a  parameter  list  such  as  the
following RPG code:

C                     CALL 'TAARPHDR'                 Rtn century
C                     PARM           YY      2        Input year
C                     PARM           CEN2    2        Rtn cen 2
C                     PARM           CEN1    1        Rtn cen 1
C                     PARM '*YES'    SETLR   4        Set LR

All parameters  must be passed.   The  SETLR value must  contain either
*YES  or  *NO.   *YES  causes the  called  program to  end  with  LR on
meaning the  program is  deactivated.   *NO  should  be used  when  you
intend to  iteratively call the  program and want  to keep the  program
activated.

Using the subroutine in an RPG program
--------------------------------------

The  source  member TAARPHDR3  has  both  the  standard subroutine  and
instructions for its use.

First  use the CPYTAA tool to  copy the code from  the TAA Archive to a
normal source member:

CPYTAA   TAAARCMBR(TAARPHDR3)

This will copy  the code to  the TAARPHDR3 member  in the QATTRPG  file
in TAATOOL.

You may  then use the normal  SEU Browse/Copy option (F15)  to copy the
code to your own program and follow the instructions.

For  example,  the following  inputs  a 2  digit date  to  the standard
field ZYYY, calls the subroutine,  and uses the return field of  ZYCEN2
for the 2 digit century value.

C                     MOVE yy        ZYYY             Inp to subr
C                     EXSR ZYCVT                      Date slide
C                     MOVE ZYCEN2    cc      2        Return 2

Using the subroutine in an RPGLE program
----------------------------------------

The  source  member TAARPHDR4  has  both  the standard  subroutine  and
instructions for its use.

First use  the CPYTAA tool to  copy the code from the  TAA Archive to a
normal source member:

CPYTAA   TAAARCMBR(TAARPHDR4)

This will copy  the code to  the TAARPHDR4 member  in the QATTRPG  file
in TAATOOL.

You may then  use the normal SEU  Browse/Copy option (F15) to  copy the
code to your own program and follow the instructions.

For  example, the  following  inputs a  2  digit date  to  the standard
field  ZYYY, calls the subroutine, and  uses the return field of ZYCEN2
for the 2 digit century value.

C                   MOVE      XXXXX         ZYYY
C                   EXSR      ZYCVT
C                   MOVE      ZYCEN2        cc                2

Invalid year data
-----------------

The two byte field passed  to the subroutine must contain  valid digits
00 - 99.  If not, asterisks (*) are placed in the return values.

Technique used
--------------

The  RPG *DATE  function is  used to  determine the  current  4 century
year.   49 years are subtracted  to find the minimum  year range and 50
years are added to find the maximum year range.

The RTNCEN2 value is valid for current years of 0049-9949.

The RTNCEN1 value is valid for current years of 1949-2849.

Test program
------------

A test  program exists  to allow  you to  try out  the subroutine  with
different values assumed as the current year.

To test  the program,  pass a  parameter for  the assumed current  year
such as:

CALL   TAARPHDR2 PARM('1999')

Spooled output  occurs to the QPRINT spooled  file with the results for
various 2 digit years.

Command parameters                                    *CMD
------------------

INPUTYEAR     The two  digit year  to  assume a  century for.    For
example, you  would input  a YY  value such  as 98  or
02.

The  parameter must  contain numeric  data in  a range
of  00 - 99.  If not,  asterisks will be placed in the
two return parameters.

RTNCEN2       The two digit assumed  century that is returned.   For
example, 19  or 20.   The parameter must  be specified
as *CHAR LEN(2).

RTNCEN1       The  one digit assumed century that  is returned.  For
example, 0 for  the 20th  century and 1  for the  21st
century.   The parameter  must be  specified as  *CHAR
LEN(1).

SETLR         A  *YES/*NO  value  for how  to  end  the RPG  program
which is  the processing  function  of RTVCEN.    *YES
causes the RPG program  to end with LR on  meaning the
program is deactivated.

*NO  should be  used  when you  intend  to iteratively
use  the  command and  want  to keep  the  RPG program
activated.

Restrictions
------------

Because the RTVCEN command  returns variables, the command may  only be
used in a CL program.

The RTNCEN2 value is valid for current years of 0049-9949.

The RTNCEN1 value is valid for current years of 1949-2849.

When the  subroutine is used  for the first  time after the  program is
initialized,  several values are set.   If the  program is in operation
past midnight  on Dec  31 of  the last  day of  a  century, the  window
remains fixed and would only be valid for 49 years into the future.

Prerequisites
-------------

None.

Implementation
--------------

You must copy  the code into your program and  follow the instructions.

Objects used by the tool
------------------------

Object        Type    Attribute      Src member    Src file
------        ----    ---------      ----------    ----------

RTVCEN        *CMD                   TAARPHD       QATTCMD
TAARPHD       *CLP       CLP         TAARPHDC      QATTCL
TAARPHDR      *PGM       RPG         TAARPHDR      QATTRPG
TAARPHDR2     *PGM       RPG         TAARPHDR2     QATTRPG
TAARPHDR3     QATTRPG
TAARPHDR4     QATTRPG

The TAARPHDR source is the processing function for RTVCEN.

The TAARPHDR2 source is the test program.

The  TAARPHDR3  source is  the  RPG  subroutine to  be  copied  to your
program.

The TAARPHDR4  source is  the RPGLE  subroutine to  be copied  to  your
program.
```

Added to TAA Productivity tools November 1, 1997