Date/Time Additional Column Programming Example
Because Date or Date/Time values passed to DColumn properties must be in ISO format, values from LANSA fields need to be formatted before they are passed. Below is an example of adding Date values to the instance list from an RDML VLF filter.
Select Fields(#EMPNO #GIVENAME #SURNAME #DEPTMENT #SECTION #ADDRESS1 #PHONEHME #POSTCODE #STARTDTE) From_File(PSLMST2) With_Key(#SURNAME) Generic(*YES)
Use BConcat (#GiveName #SurName) #FullName
EXECUTE Subroutine(DateToISO) With_Parms(#STARTDTE #VF_ELDTS)
Invoke Method(#avListManager.AddtoList) Visualid1(#EMPNO) Visualid2(#FullName) Akey1(#DEPTMENT) Akey2(#SECTION) Akey3(#EMPNO) AColumn1(#ADDRESS1) AColumn2(#PHONEHME) NColumn1(#POSTCODE) DColumn1(#VF_ELDTS)
Endselect
SUBROUTINE Name(DateToISO) Parms((#RETDAT *RECEIVED) (#VF_ELDTS *RETURNED))
DEFINE Field(#D_Char8) Type(*CHAR) Length(8)
DEFINE Field(#D_Num8) Reffld(#DATE8)
DEFINE Field(#D_Year) Type(*CHAR) Length(4)
DEFINE Field(#D_Month) Type(*CHAR) Length(2)
DEFINE Field(#D_Day) Type(*CHAR) Length(2)
OVERRIDE Field(#D_Year) To_Overlay(#D_Char8)
OVERRIDE Field(#D_Month) To_Overlay(#D_Char8 5)
OVERRIDE Field(#D_Day) To_Overlay(#D_Char8 7)
USE Builtin(CONVERTDATE_NUMERIC) With_Args(#RETDAT B J) To_Get(#D_Num8)
USE Builtin(NUMERIC_STRING) With_Args(#D_Num8 N) To_Get(#D_Char8)
USE Builtin(CONCAT) With_Args(#D_Year '-' #D_Month '-' #D_Day) To_Get(#VF_ELDTS)
ENDROUTINE
RDMLX Examples
In RDMLX filters the processing is much easier because intrinsic functions can be used, with the following as an example of what is required to convert RDML field #STARTDTE.
* Convert #STARTDTE to the correct format for Date/Time columns
EXECUTE Subroutine(DateToISO) With_Parms(#STARTDTE 'DDMMYY' #VF_ELDTS)
* Format conversion subroutine definition
SUBROUTINE Name(DateToISO) Parms((#RETDAT *RECEIVED) (#DATEFMT *RECEIVED) (#DATEOUT *RETURNED))
DEFINE Field(#DATEFMT) Reffld(#VF_ELDTFM)
DEFINE Field(#DATEOUT) Reffld(#VF_ELDTS)
If (#RETDAT.isdate(#DATEFMT))
#DATEOUT := #RETDAT.AsDate(#DATEFMT).AsDisplayString(ISO)
ELSE
MESSAGE Msgtxt('Date is not in the correct format')
Endif
ENDROUTINE
And converting RDMLX field in RDMLX filters is even easier with only the following required to convert Date or DateTime fields to the correct format. In this case the RDMLX Date field #VF_ELDAT.
#VF_ELDTS := #VF_ELDAT.AsDisplayString(ISO)