TechTalk: DATE Keyword Quirk

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

In our shop, we recently developed a batch job that is always running in its own job queue. This job produces, on demand, one-page reports for our users. One of our printer file standards is that the date and time always be displayed in the upper-right corner of the report. To produce the report, I used an external printer file with the DATE and TIME DDS keywords.

In running the report, I noticed the program was always printing the current system time but that the printed date was the date the job was submitted to the system. I checked the DDS manual for printer files and found that, indeed, the DDS keyword TIME always prints the current system time while the DDS keyword DATE always prints the current job date-i.e., the date the job started. What this means is that, if your report is printed out across midnight, the time will remain current while the date will not change.

Fortunately, there is a simple solution, but it involves retrieving the date manually rather than using DDS. In your DDS for the printer file, replace the DATE keyword with a user-defined variable as shown in 1.

Fortunately, there is a simple solution, but it involves retrieving the date manually rather than using DDS. In your DDS for the printer file, replace the DATE keyword with a user-defined variable as shown in Figure 1.

Field DATE6N is your substitute for the DATE keyword. In your program, perform the code shown in 2 before you print the date in variable DATE6N.

Field DATE6N is your substitute for the DATE keyword. In your program, perform the code shown in Figure 2 before you print the date in variable DATE6N.

Editor's Note: The same quirk applies to display files. Suppose you design a display file that uses the DATE and TIME keywords, to be used in an interactive file maintenance program. A user starts the job at 23:45 on December 1, 1992. Twenty minutes later, the time has advanced to 00:05, but the date remains the same.


TechTalk: DATE Keyword Quirk

Figure 1 Replacement for DATE keyword

 Figure 1: Replacement for DATE Keyword ... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 A DATE6N 6 0 10EDTCDE(Y) 
TechTalk: DATE Keyword Quirk

Figure 2 Retrieving date in RPG/400

 Figure 2: Retrieving Date in RPG/400 ... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 C TIME SYSCLK 120 C Z-ADDSYSCLK DATE6N 
BLOG COMMENTS POWERED BY DISQUS