IBM Support

Using Null Dates from an Externally Described File in RPGLE

Troubleshooting


Problem

The following discusses how to avoid RNX0112 error when handling null dates in RPGLE.

Resolving The Problem

Disclaimer: This is only an example. IBM accepts no responsibility for its correctness.


When reading a file that has null dates, the user may receive error message "RNX0112 Date, Time or Timestamp value is not valid." This is caused because the record read from the file contains an invalid date value. When the compiler moves the date from the input buffer to the input date field, it checks for a valid date value. Since it is not valid, the error is issued. For null capable input fields, the data is moved to the input fields with the previously mentioned validity checking and the null byte map from the file is moved to the null byte map for the program. In order to input the invalid date data into the program without getting an error, you need to use an externally described data structure and use it for the result DS on the read operation.

An example of this is as follows:
Note:
IBM ships a save file which contains some samples in library ADTSLAB.
The library can be restored from a savf QPDA/ADTSLAB which is available with license product 5770WDS Application Development ToolSet.
RSTLIB SAVLIB(ADTSLAB) DEV(*SAVF) SAVF(QPDA/ADTSLAB)

Create a view over the CUSTOMER table in library ADTSLAB adding a NullDate field using this SQL statement:
create view adtslab.customerNullDate as
select cast(null as date) as nullDate, c.*
from adtslab.customer c

In order to input the invalid date data into the program without getting an error, an externally-described data structure must be used:
 
       ctl-opt option(*srcstmt : *nodebugio) alwnull(*usrctl) debug;
       dcl-f CUSTO00001 rename(custo00001 :fcustomer);
       dcl-ds custoDS extname('CUSTO00001':*input) end-ds;

        Read fCustomer custoDS;
        Dow Not %Eof(CUSTO00001);

           If Not %NullInd(NullDate);
              Dump;
           EndIf;

           Read fCustomer custoDS;
        EndDo;

        *Inlr = *on;
        Return;       



[{"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

507851621

Document Information

More support for:
IBM i

Component:
Programming ILE Languages

Software version:
All Versions

Operating system(s):
IBM i

Document number:
635157

Modified date:
14 November 2024

UID

nas8N1013335

Manage My Notification Subscriptions