CICS VSAM Transparency for z/OS, Version 1.2


Converting between Julian and Gregorian date formats

DB2® supports a combination of industry and IBM® standard date formats. A local date format can be supported by a user-written exit routine. It is possible that the format you used when your VSAM files were designed may not match your chosen DB2 format.

A common requirement with CICS® VT customers is to convert Julian date fields to DB2 DATE columns.In the context of this manual, Julian and Gregorian date formats are defined as follows:

Julian date
This format of date is a combination of year plus a relative day number within the year. A typical example is 2008267 in the format YYYYDDD. This is equivalent to a calendar date of August 23rd 2008.
Gregorian date
This format of date corresponds to any of the industry or IBM standard date formats supported by DB2. For example, the International Organization for Standardization (ISO) format is CCYY-MM-DD. 2008-08-23 is equivalent to the calendar date August 23rd 2008.

There is a sample assembler exit called JULGREG which is available for converting between Julian and Gregorian dates. It supports a VSAM field format of YYDDDHHMM.

COBOL code

 CBL LIB
 IDENTIFICATION DIVISION.
 PROGRAM-ID. CJULGRG.
*
* THIS FBE CONVERTS A 7-BYTE UNSIGNED ZONED DECIMAL FIELD IN
* VSAM TO A DB2 DATE COLUMN. NO DATA VERIFICATION IS PERFORMED.
*
 ENVIRONMENT DIVISION.
 DATA DIVISION.
 WORKING-STORAGE SECTION                .
 01 WS-DB2-FIELD               PIC 9(8) .
 01 WS-VSAM-FIELD              PIC 9(7) .
*
 01 WS-DB2-TEMP-FIELD                   .
    02 TEMP-YYYY               PIC 9(4) .
    02 TEMP-MM                 PIC 9(2) .
    02 TEMP-DD                 PIC 9(2) .
 01 WS-DB2-TEMP REDEFINES
    WS-DB2-TEMP-FIELD          PIC 9(8) .
*
 LINKAGE SECTION                        .
 01 VSAM-FIELD                 PIC 9(7) .
 01 DB2-FIELD                           .
    02 DB2-YYYY                PIC 9(4) .
    02 FILLER                  PIC X    .
    02 DB2-MM                  PIC 9(2) .
    02 FILLER                  PIC X    .
    02 DB2-DD                  PIC 9(2) .
    COPY VIDFBEC                        .
*
 PROCEDURE DIVISION USING VSAM-FIELD, DB2-FIELD, EXITPARMS .
 MAIN-SECTION.
    SET ADDRESS OF VSAM-FIELD TO EXVSAFLD.
    SET ADDRESS OF DB2-FIELD TO EXDB2FLD.
    EVALUATE EXFUNCT
       WHEN 'D'      PERFORM BUILD-DB2-FIELD
       WHEN 'V'      PERFORM BUILD-VSAM-FIELD
    END-EVALUATE .
 MAIN-SECTION-END.
    GOBACK.
    EXIT.
 BUILD-VSAM-FIELD SECTION.
 10-BUILD-VSAM-FIELD.
     MOVE DB2-YYYY    TO TEMP-YYYY .
     MOVE DB2-MM      TO TEMP-MM .
     MOVE DB2-DD      TO TEMP-DD .
     COMPUTE WS-VSAM-FIELD  =
             FUNCTION INTEGER-OF-DATE(WS-DB2-TEMP) .
     COMPUTE VSAM-FIELD =
             FUNCTION DAY-OF-INTEGER(WS-VSAM-FIELD).
 10-BUILD-VSAM-FIELD-END.
    EXIT.
 BUILD-DB2-FIELD SECTION.
 10-BUILD-DB2-FIELD.
     COMPUTE WS-DB2-FIELD      =
             FUNCTION INTEGER-OF-DAY(VSAM-FIELD).
     COMPUTE WS-DB2-TEMP       =
             FUNCTION DATE-OF-INTEGER(WS-DB2-FIELD).
     MOVE TEMP-YYYY    TO DB2-YYYY .
     MOVE TEMP-MM      TO DB2-MM .
     MOVE TEMP-DD      TO DB2-DD .
 10-BUILD-DB2-FIELD-END.
     EXIT.

Notes for CJULGRG

This is a very simple exit that uses COBOL intrinsic functions to handle the data conversion between Julian and Gregorian date formats. No verification of VSAM field values is performed.


Concept topic


Last updated: November 9, 2012 20:43:55