DTDADDSubroutine {COBOL}

Purpose:

Adds an unsigned number of days to an input date in 8-digit format with 3 components, i.e. year-month-day as "CCYYMMDD", then returns resultant date (separate variable) in same format. Takes actual calendar into account.

Usage:

Computing "future" dates (commencement date, due date, return date, etc.) based upon a known "current" date and a "number of calendar days" from that point.

Applications include leasing, mortgages, interest, investments, billings/collections, and any other financial applications; also estimated mail/shipping delivery dates.

Calling Sequence:

 
 

CALL 'DTDADD' USING

INP-CCYYMMDD

INP-DAYSADD

OUT-DAYSERR

   

OUT-YYERR

OUT-MMERR

OUT-DDERR

   

OUT-CCYYMMDD

OUT-FATALERR

 
 

Where:

 

INP-CCYYMMDD

X(08)

<INP>

=

Input date mask [CCYYMMDD]
[Must be 8-digits with expanded year];

 

INP-DAYSADD

9(05)

<INP>

=

Unsigned number of days to add to input date (must always be 5 digit allocation);

 

OUT-DAYSERR

9(01)

<OUT>

=

Number of days check results
(0=OK >0=ERR);

 

OUT-YYERR

9(01)

<OUT>

=

YY Validity Results
(0=OK >0=ERR);

 

OUT-MMERR

9(01)

<OUT>

=

MM Validity Results
(0=OK >0=ERR);

 

OUT-DDERR

9(01)

<OUT>

=

DD Validity Results
(0=OK >0=ERR);

 

OUT-CCYYMMDD

X(08)

<OUT>

=

Expanded date [CCYYMMDD].

 

OUT-FATALERR

9(05)

<OUT>

=

Fatal Error Number -- 0 = No Errors:
[4 = Any of above 4 error flags set > 0
13000 = Output CCYY reached 9999
14000 = Output MM > 12 but cannot increment year since output CCYY already reached 9999].

Detailed Functions:

 
 

1.

First performs date-validity check on each component of the input date (checks actual calendar); If input date in error, returns individual error codes and does not perform addition functions.

 

2.

Checks input "number of days to add" – discontinues processing if is unusable.

 

3.

Method is to add the number of days to the "day" value of the date, then adjust the result per the calendar. Allows for leap years.

Comments:

If needed, call COBOL subroutine DTDEXP3 to expand incoming date from 6-digit (YYMMDD)-to-8-digits (CCYYMMDD) from calling program prior to this call.

 

See "copyproc" inserts "WS-DATES" (declarations) and "98-WINDOW" (procedures) for further details of how this Y2K expansion process works. See also the "Y2K Compliance COBOL Programmer’s Reference Manual".

{End}