IBM Support

RPG Cafe: Fall 2024: Find where you use 2-digit years, to avoid the "2039 problem"

News


Abstract

Information about the PTFs to provide the ILE RPG enhancement to locate where you use dates with 2-digit years in your RPG programs

Content

You are in: RPG Cafe > RPG Cafe: Fall 2024: Find where you use 2-digit years, to avoid the "2039 problem"

Short URL: https://ibm.biz/rpgcafe_fall_2024_dateyy_2039_problem

Fall 2024: Find where you use 2-digit years, to avoid the "2039 problem"

The year 2039 is approaching fast, along with the "2039 problem" for code that is still using dates with 2-digit years.

  • Use the DATEYY parameter for CRTBNDRPG and CRTRPGMOD or use the DATEYY Control keyword to get the RPG compiler ot find all the places your program or module uses dates with 2-digit years.
    • DATEYY(*WARN) gives you a sev-10 diagnostic message when your code uses
      • A date format that has 2 digits for the year, such as *MDY or *JOBRUN.
      • An externally-described file or data structure with a field that has a 2-digit year format
      • UDATE or UYEAR
      • TIME opcode with a 12-digit result
    • DATEYY(*NOALLOW) gives you a sev-30 error message for the same situations, which causes the compile to fail.
    • DATEYY(*ALLOW) does not check for dates with 2-digit years. This is the default.

    You can temporarily change the command default for the DATEYY parameter of CRTBNDRPG and CRTRPGMOD to *NOALLOW and try to compile your code to find out how many places you are still using dates with 2-digits for the year.

  • *LONGJOBRUN is a new date format that you can use instead of *JOBRUN when you are working with character or numeric values with dates, and you want 4 digits for the year. For example, if your job date format is *MDY and convert D'2024-11-08' using *JOBRUN, the result is '11/08/24'. If you use *LONGJOBRUN, the result is '11/08/2024'.

Example of *LONGJOBRUN

          dcl-s today date(*iso) inz(*sys);

          snd-msg 'The date today is ' + %char(today:*jobrun);
          snd-msg 'The date today is ' + %char(today:*longjobrun);

          *inlr = *on;

I set *INLR on because the job date format and separator (and other job values) are only retrieved during the *INIT phase of the cycle. (For a linear main module or a NOMAIN module, they are only retrieved the first time any procedure in the module is called.). See Program Flow in RPG Modules: Cycle Versus Linear

The joblog from my session using this program:

> chgjob datfmt(*mdy) datsep('.')
> call qtemp/test
  The date today is 10.08.24
  The date today is 10.08.2024
> chgjob datfmt(*jul) datsep('/')
> call qtemp/test
  The date today is 24/282
  The date today is 2024/282
> chgjob datfmt(*ymd)
> call qtemp/test
  The date today is 24/10/08
  The date today is 2024/10/08

Example of DATEYY(*NOALLOW) from the compile listing

          1    ctl-opt DATEYY(*NOALLOW);
          2    dcl-s today date(*iso) inz(*sys);
          3    dcl-s msg varchar(20);
          4
          5    msg = 'The date today is ' + %char(today:*jobrun);

         *RNF0203 30  A date with 2 digits for the year is not allowed
                      due to DATEYY(*NOALLOW). Reason code: JOBRUN.

.                                                            .
.                                                            .

PTFs for 7.4 and 7.5

7.4:

  • ILE RPG compiler: 5770WDS SJ03205
  • ILE RPG CRTBNDRPG and CRTRPGMOD commands: 5770WDS SJ02911.

    Note: Be sure to read the Special Instructions in the cover letter before applying this PTF. When you apply or remove this PTF, any changes you have made with CHGCMDDFT will revert to the shipped defaults.

    It is only necessary to have this PTF if you want to specify the DATEYY parameter for CRTBNDRPG or CRTRPGMOD. If you only want to specify the DATEYY keyword in your Control statement, you don't need this PTF.

7.5:

  • ILE RPG compiler: 5770WDS SJ03204
  • ILE RPG CRTBNDRPG and CRTRPGMOD commands: 5770WDS SJ02921.

    Note: Be sure to read the Special Instructions in the cover letter before applying this PTF. When you apply or remove this PTF, any changes you have made with CHGCMDDFT will revert to the shipped defaults.

    It is only necessary to have this PTF if you want to specify the DATEYY parameter for CRTBNDRPG or CRTRPGMOD. If you only want to specify the DATEYY keyword in your Control statement, you don't need this PTF.

  • ILE RPG compiler, TGTRLS(V7R4M0): 5770WDS SJ03206

RDi support

The next update for RDi will support these enhancements.

Documentation

The 7.4 and 7.5 ILE RPG Reference and ILE RPG Programmer's Guide are updated with full information about these enhancements.

[{"Type":"MASTER","Line of Business":{"code":"LOB73","label":"Power TPS"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SS69QP","label":"Rational Development Studio for i"},"ARM Category":[],"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.4.0;7.5.0;and future releases"}]

Document Information

Modified date:
08 January 2025

UID

ibm17172105