× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello all,

Got a problem I cannot get to the bottom of and have been digging all
over and no luck there either. We have just upgraded to 6.1 on new
hardware. We have V5R4 still on our old box and do not have this
trouble there. We have an external UDF that accepts 3 components of a
date and returns a Date field. Within debug the service program
handling it functions as expected with DATEOUT having a valid date,
but we get the results shown below strsql. The UDF and service
program code follows. Any assistance is greatly appreciated.


Thanks in advance.

Jack W. Long Jr.
Haulers Insurance Company, Inc.


select truedate(efyy2w, efmm2w, efdd2w), efyy2w, efmm2w, efdd2w
from atdtest/hadbidb

Results:
TRUEDATE EFYY2W EFMM2W EFDD2W
++++++++++ 2,009 11 15
++++++++++ 2,009 12 21
++++++++++ 1,996 1 1
++++++++++ 1,996 1 22
Data mapping error on member HADBIDB.


Message ID . . . . . . : CPF5035 Severity . . . . . . . : 10
Message type . . . . . : Diagnostic
Date sent . . . . . . : 11/30/10 Time sent . . . . . . : 14:26:49

Message . . . . : Data mapping error on member HADBIDB.
Cause . . . . . : A data mapping error occurred on field
Cast(TRUEDATE(Cast(HADBIDB_1.EFYY2W AS Decimal(4,0)
NULL),Cast(HADBIDB_1.EFMM2W AS Decimal(2,0) NULL),Cast(HADBIDB_1.EFDD2W AS
Decimal(2,0) NULL)) AS Date) in record number 1, record format *FIRST,
member number 1, in member HADBIDB file HADBIDB in library ATDTEST, because
of error code 17. The error code meanings follow:
17 -- The format of the data in a date, time, or timestamp field is
not valid.

Definitions: efyy2w: 4s 0, efmm2w: 2s 0, efdd2w: 2s 0

Just to take the file definition out of the mix I get the same results with:

select truedate(2001,10,14), 2001, 10, 14 from sysibm/sysdummy1

Function Code:
CREATE FUNCTION TRUEDATE (DEC(4,0), DEC(2,0), DEC(2,0))
RETURNS DATE
EXTERNAL NAME 'HICPGM/TRUEDATE(TRUEDATE)'
LANGUAGE RPGLE
NO SQL
NOT DETERMINISTIC
NOT FENCED
RETURNS NULL ON NULL INPUT

Service Program Code:
H Nomain

D**/copy qrpglesrc,truedatepr
d truedate pr d
d yearin 4p 0 const
d monthin 2p 0 const
d dayin 2p 0 const

p truedate b export

d truedate pi d
d yearin 4P 0 const
d monthin 2P 0 const
d dayin 2P 0 const

d ds
d datein 8s 0
d inyear 4s 0 overlay(datein: 1)
d inmonth 2s 0 overlay(datein: 5)
d inday 2s 0 overlay(datein: 7)

d dateout s d inz(*SYS)
d default s d inz

/free
inyear = yearin;
inmonth = monthin;
inday = dayin;

// If *zero date field do not convert
if inyear = *zero or inmonth = *zero or inday = *zero;
dateout = default;
else;
// try to convert to date
monitor;
dateout = %date(datein: *iso);
on-error;
dateout = default;
endmon;
endif;

*inlr = *off;
return dateout;
/end-free
p e

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.