Troubleshooting
Problem
When using the ILE C function time() that was exported from service program QSYS/QC2UTIL1, errors may result in programs when rolling over from 9 to 10 digits.
Resolving The Problem
The ILE C function time(), exported from service program QSYS/QC2UTIL1, returns the time, in seconds, since 00:00:00 (midnight) UTC of January 1, 1970. This value reached 1,000,000,000 (10**9) seconds at 01:46:40 UTC on Sunday, September 9, 2001. This corresponds approximately to the evening hours of Saturday, September 8, 2001 in the US time zones.
The rollover from 9 to 10 digits may cause errors in programs that assign the output of time() to overly small variables. Specifically, this can happen when invoking time() from ILE RPG applications. Consider the following code sample:
D time_C PR 9B 0 EXTPROC('time')
D parm1 9B 0
D fld1 S 9B 0
D fld2 S 9B 0
D fld3 S 9A
C eval fld1 = time_C(fld2)
C eval fld3 = %char(fld1)
C eval *inlr = *on
After the rollover, this program is no longer correct for the following reasons:
Both coding errors must be corrected as in the following revised sample:
D time_C PR 10I 0 EXTPROC('time')
D parm1 10I 0
D fld1 S 10I 0
D fld2 S 10I 0
D fld3 S 10A
C eval fld1 = time_C(fld2)
C eval fld3 = %Char(fld1)
C eval *inlr = *on
Other programming changes may be needed depending on where and how the modified fields are used in the remainder of the source code for an application.
The rollover from 9 to 10 digits may cause errors in programs that assign the output of time() to overly small variables. Specifically, this can happen when invoking time() from ILE RPG applications. Consider the following code sample:
D time_C PR 9B 0 EXTPROC('time')
D parm1 9B 0
D fld1 S 9B 0
D fld2 S 9B 0
D fld3 S 9A
C eval fld1 = time_C(fld2)
C eval fld3 = %char(fld1)
C eval *inlr = *on
After the rollover, this program is no longer correct for the following reasons:
| o | fld1 and fld2 are defined as 9B0. This causes the IBM® RPG/400® compiler to allocate 4 bytes to each field but restricts the capacity of the field to 9 decimal digits each. ILE C function time() assigns the correct values into fld1 and fld2; however, built-in RPG function %char produces output that is not valid because of the 9-digit limitation. Assigning %char(fld1) into fld3 causes an MCH1210 error. |
| o | If this first problem were corrected, the program would produce output that is not correct because fld3 is only 9 characters and is, therefore, not large enough to hold a 10-digit number. Only the 9 left most digits would be assigned into fld3, and the last digit on the right would be truncated. |
Both coding errors must be corrected as in the following revised sample:
D time_C PR 10I 0 EXTPROC('time')
D parm1 10I 0
D fld1 S 10I 0
D fld2 S 10I 0
D fld3 S 10A
C eval fld1 = time_C(fld2)
C eval fld3 = %Char(fld1)
C eval *inlr = *on
Other programming changes may be needed depending on where and how the modified fields are used in the remainder of the source code for an application.
[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHtAAM","label":"Programming ILE Languages"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]
Historical Number
24391924
Was this topic helpful?
Document Information
Modified date:
06 May 2025
UID
nas8N1017242