Rational Programming Patterns

Date formatting micropatterns

You can insert these micropatterns in the code of a Program, a Screen, a Server, or a Macro.

Date format transformation

There are two groups of date format transformation micropatterns:
  • The ADF micropattern transforms a date without the century. It transforms a YYMMDD date into a date with a separator (slash): MM/DD/YY for an English version or DD/MM/YY for a French version.
    You must conform to the following input format:
          *!ADF "date1 date2"
    Where:
    • *! is the required start tag of the micropattern. The * must be entered in column 7, reserved for the comments in the COBOL code, and the ! must be entered in column 8.
    • ADF is the micropattern identifier.
    • " " must frame the operands.
    • date1 is the initial date Data Element on six characters and date2 is the transformed date Data Element on eight characters.
  • The AD, AD0, AD1, and AD2 micropatterns transform a date that is generated in a certain format into a date that is generated in another format.
    You must conform to the following input format:
          *!ADn "xy date1 date2"
    Where:
    • *! is the required start tag of the micropattern. The * must be entered in column 7, reserved for the comments in the COBOL code, and the ! must be entered in column 8.
    • ADn is the micropattern identifier: AD, AD0, AD1 or AD2
    • " " must frame the operands.
    • xy are the two formats of the generated date. The first is the initial format, whereas the second is the format that will actually be generated.
      Table 1. Correspondence between the format values and the formats of the generated dates
      Format values Generated formats
      I Year, month day (YYMMDD)
      D Day, month, year (DDMMYY)

      or

      Month, day, year (MMDDYY)

      according to the format type selected in the Generated date format of the Library Definition

      E Day/month/year (DD/MM/YY)

      or

      Month/day/year (MM/DD/YY)

      according to the format type selected in the Generated date format of the Library Definition

      These dates have an extended format.

      S Century, year, month, day (CCYYMMDD)
      G Century year-month-day (CCYY-MM-DD)
      C Day, month, century, year (DDMMCCYY)

      or

      Month, day, century year (MMDDCCYY)

      according to the format type selected in the Generated date format of the Library Definition

      M Day/month/century year (DD/MM/CCYY)

      or

      Month/day/century year (MM/DD/CCYY)

      according to the format type selected in the Generated date format of the Library Definition

    • date1 is the initial date Data Element (you can use the DATOR constant if needed), and date2 is the transformed date Data Element. These Data Elements can be called in Segments or defined in the WORKING-STORAGE SECTION only.
    These micropatterns manage the century differently:
    • AD transforms the date without a windowing. The century in date2 takes the value of the DAT-CTY variable, whose century value comes from CENTUR. The century is set to 19 for the Batch Applications function. However, it is set to the century of the system date for the OnLine Systems Development function, or if an ADT or ADC micropattern was indicated.
    • AD0 transforms the date without a windowing. The century in date2 takes the value of the DAT-CTY, which must be added with specific code. It is set to 19.
    • AD1 transforms the date with a windowing. The century in date2 is set to 19 if the year of date1 is lower that the DAT-CTYT variable. It is set to 20 otherwise. The value of DAT-CTYT is set to 61 by default.
    • AD2 transforms the date with a windowing. The century in date2 is set to 20 if the year of date1 is lower that the DAT-CTYT variable. It is set to 19 otherwise. The value of DAT-CTYT is set to 61 by default.

Batch date processing

You can invert a date or add slashes to it.

The declaration lines of these micropatterns use the same start tag as the date format transformation micropatterns. However, you must replace the micropattern identifier and enter the operands specific to each micropattern. Follow the instructions in the table:
Table 2. Batch date processing micropatterns
Micropattern identifier Micropattern function and operands
ADI Inverts the first two and the last two characters of a six-character date. For example, YYMMDD becomes DDMMYY and conversely.
Enter:
"date1 date2"
where date1 and date2 are both six-character date Data Elements. date2 is optional. If it is not indicated, date1 gets the inverted date.
ADS Inverts a date with the century. CCYYMMDD becomes DDMMCCYY, and conversely.
Enter:
"date1 date2"
where date1 and date2 are both eight-character date Data Elements. date2 is optional. If it is not indicated, date1 gets the inverted date.
ADE Adds slashes to a six-character date. For example, YYMMDD becomes YY/MM/DD.
Enter:
"date1 date2"
where date1 is a six-character date Data Element and date2 is an eight-character date Data Element.
ADM Adds slashes to a date that includes the century. For example CCYYMMDD becomes CCYY/MM/DD.
Enter:
"date1 date2"
where date1 is an eight-character date Data Element and date2 is a 10-character date Data Element.

Date computing

The declaration lines of these micropatterns use the same start tag as the date format transformation micropatterns. However, you must replace the micropattern identifier and enter the operands specific to each micropattern. Follow the instructions in the table:
Table 3. Date computing micropatterns
Micropattern identifier Micropattern function and operands
DAD Computes the number of days between two dates.
Enter:
"xy ffnn-date1 ssnn-date2"
where:

x the format of date1 (optional). If you do not specify it, it will be extracted from the repository, provided the Data Element has a date format.

y is the format of date2 (optional). If you do not specify it, it will be extracted from the repository, provided the Data Element has a date format.

The comparison result is put in NUM-DAYS field, which is automatically declared in the WORKING-STORAGE SECTION.

DAO Adds or subtracts days to a date.
Enter:
"x snumber ffnn-date1 ffnn-date2"
where:

x the format of date1 (optional). If you do not specify it, it will be extracted from the repository, provided the Data Element has a date format.

s is the sign(+ for an addition or - for a subtraction).

number the number to be added to or subtracted from the date It can be an integer or a work area.

ffnn-date1 is the input date field.

ffnn-date2 is the result date field (optional).

Time processing

The declaration lines of these micropatterns use the same start tag as the date format transformation micropatterns. However, you must replace the micropattern identifier and enter the operands specific to each micropattern. Follow the instructions in the table:
Table 4. Time processing micropatterns
Micropattern identifier Micropattern function and operands
TIM Displays the time as HHMMSS from the EIBTIME field for CICS, and the TIME field for the other platforms.
Enter:
"DELCO1"
where DELCO1 is a six-character Data Element.
TIF Transforms the time format from HHMMSS into HH:MM:SS.
Enter:
"DELCO1 DELCO2"
where DELCO1 is a six-character Data Element and DELCO2 is an eight-character Data Element

Generated result

The micropattern is recognized and expanded when the Program, Screen, or Server is generated again.
  • The required date fields are declared in the WORKING-STORAGE SECTION.
  • The COBOL code that corresponds to the micropattern is generated after the start tag. To transform a date without century into a date with century, the CENTUR variable is used to load the century.
  • The date transformation function is generated, by default in the following subfunctions
    • F9520 for the Batch Applications function. You can change the default function by entering, in the -GO lines of the Program, the DATPRO=ffss option, where ffss is the code of the function and subfunction.
    • F8120 for the OnLine Systems Development or Pacbench C/S function.

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)