Troubleshooting
Problem
This document describes how to avoid message CPF5035 reason code 16 when running some RPG programs.
Resolving The Problem
This document describes how to avoid message CPF5035 reason code 16 when running some RPG programs.
A physical file was created with a date field. DATFMT(*MDY) was specified.
| 1. | When an RPG program adds new records, does the field default to 2001? The RPG program was compiled without specifying CVTOPT(*DATETIME). This causes the RPG program to ignore the date field in the file. However, something must be placed into the field when records are added to the file. Per the RPG/400 User's Guide, for the Date, Time, and Timestamp Fields, the program will use a value of Day 1 Month 1 Year 1. And, because DATFMT(*MDY) was specified, the system must determine which century to assign to the field. The windowing algorithm the system uses will assume that 01 actually means 2001. If 2001 is not desirable, do one of the following: o Re-create the physical file and specify a DATFMT of *USA, for example, so that a four-digit year can be processed. o Change the RPG program to set the date to a value and compile specifying CVTOPT(*DATETIME). If the program is compiled with CVTOPT(*DATETIME) and not changed to set the date to a valid value, then a data mapping error will occur when the program attempts to add records to the file. This is because the date field will be initialized to blanks in the program, which is not a valid date. o Change the physical file to include the DFT keyword with a desirable default date. Then, create a logical file over the physical file that includes all of the fields from the physical file, except for the new date field. Then, write the RPG programs against the logical file. When the RPG program adds records to the file, the date specified on the DFT keyword will be the result. |
| 2. | When an RPG program tries to read records, does message CPF5035 RC16 result? The physical file was created with a date field. The keyword DATFMT(*MDY) was also specified. Because the field is a date field, any valid date can be written to the file. However, if a date resides in the file outside the range of 1940-2039, then the CPF5035 RC16 will result when the record is read. This is because the program reading the file might not make the correct assumption if only the two-digit date is returned. For example, the program should assume 01 is 2001. So, if 1901 is really in the file, a returned 01 would incorrectly be understood by the program as 2001. If the physical file must have a date format of *MDY specified, then the file must be journaled and analyzed to determine where values outside the range of 1940-2039 are originating from. The programs must then be corrected. Otherwise, a date format of *USA should be used so that a four-digit year can be processed. Dates outside the range might get into the file by, for example, creating a logical file over the physical file and overriding the date format to *USA. Any program could then update the logical file with any valid date. This method can also be used to correct the records causing data mapping errors. |
[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0"}]
Historical Number
15903244
Was this topic helpful?
Document Information
Modified date:
18 December 2019
UID
nas8N1018063