DTFM38Subroutine {COBOL}

Purpose:

Generates formatted output for an 8-digit input date in 3 components [CCYYMMDD].

Output date formats supported:

 

1.

"MM_DD_CCYY", where "_" is a variable delimiter;

Note -- Leading zeroes removed from month & day,

 

2.

"MONTH DD, CCYY", where "MONTH" is the spelled-out month name;

Note -- Leading zero removed from day;

 

Resultant formatted date returned in an alpha character "mask" that can easily be transferred where needed.

Usage:

Dates shown in reports, forms, or other types of "dated" text output.

Applications include leasing, mortgages, interest, investments, billings/collections, and any other financial applications; as well as mail or shipping documents.

Calling Sequence:

 
 

CALL 'DTFM38' USING

INP-CCYYMMDD

INP-DTFMT

INP-DELIM

   

OUT-YYERR

OUT-MMERR

OUT-DDERR

   

OUT-DTOUTPUT

OUT-NCHAR

OUT-FATALERR

 

Where:

 

INP-CCYYMMDD

X(08)

<INP>

=

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

 

INP-DTFMT

X(01)

<INP>

=

Output date format (alpha 1-char)
"1" = "MM_DD_CCYY" ("_" =
INP-DELIM)
"2" = "MONTH DD, CCYY";

 

INP-DELIM

X(01)

<INP>

=

Delimiter for date output (format 1 only);

 

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-DTOUTPUT

X(18)

<OUT>

=

Formatted date output (text) mask
[allocation must be X(18) always], with content packed left-justified;

 

OUT-NCHAR

9(02)

<OUT>

=

Number of "date-value" characters filled into the date output mask (per above);

 

OUT-FATALERR

9(05)

<OUT>

=

Fatal Error Number -- 0 = No Errors:
[4 = Any of above 3 error flags set > 0
5 = Incorrect
INP-DTFMT value].

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 "output date format number" – discontinues processing if incorrect.

 

3.

If date-format # 1:
maps date into
OUT-DTOUTPUT (left justified) in format "MM_DD_CCYY", where "_" is replaced with value of INP-DELIM, removing leading zeros in month, day;
Example: "20010409" into "4-9-2001" or "4/9/2001";
Example: "20011227" into "12-27-2001" or "12/27/2001".

   

If date-format # 2:
maps date into
OUT-DTOUTPUT (left justified) in format "MONTH DD, CCYY", removing leading zero in day;
Example: "20010409" into "April 9, 2001";
Example: "20011227" into "December 27, 2001".

 

4.

Output variable OUT-NCHAR is set to the number of date-format characters filled into OUT-DTOUTPUT – calling program can use this to pull "meaningful" text.

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}