Open topic with navigation
By default, ReportWriter assumes a year of 19YY for all dates stored in YYMMDD, YYJJJ, and YYPP formats. You can use %RW_CENTURY_METHOD to specify in what century a date stored in any of these formats will fall.
function RW_CENTURY_METHOD, ^val a_date ,d ;Date to provide default century for a_class ,n ;ReportWriter class for the date (see Discussion) a_structure_name ,a ;Name of date field's structure a_field_name ,a ;Name of date field a_user_text ,a ;Contents of user text field in repository
The %RW_CENTURY_METHOD function returns the century to be used for a given date. ReportWriter does not validate the return value for the routine and expects it always to be 19 or 20.
A_date is provided in storage format.
Valid field classes for a_class are as follows (as defined in reports.def):
D_RW_YYMMDD ,1 ; YYMMDD D_RW_YYJJJ ,3 ; YYJJJ D_RW_YYPP ,5 ; YYPP
You can overload the routine using RW_METHOD(M_RW_CENTURY, “RW_CENTURY_METHOD”).
If %RW_CENTURY_METHOD is not defined, the ReportWriter routine RW_INIT checks the value of the RPTDATE environment variable, which specifies the year used to “split” two-digit years between centuries. (Years prior to the specified year use one century, while years the same as or later than the specified year use a different century.)
If the method is not overloaded and SYNCENTURY is not defined or is invalid, ReportWriter uses 19 as the century for all dates stored in YYMMDD, YYJJJ, and YYPP formats.
D6, d5, and d4 dates will not be optimized if %RW_CENTURY_METHOD is specified or SYNCENTURY is set. YYYYPP will still be optimized.
This sample century method returns the two-digit century for each date passed.
function rw_century_method, ^val a_date ,d ;Date to provide default century for a_class ,n ;Storage format of date a_structure_name ,a ;Structure name for the field a_field_name ,a ;Field name a_user_text ,a ;Contents of user text field in repository stack record century ,i4 ;Century for current field year ,i4 ;Year of date passed in proc century = 19 ;Default to 19XX year = a_date(1:2) ; Change the century for certain dates using (a_structure_name) select ("CUSMAS "), ;Customer master using (a_field_name) select ("INVCDT "), ;Invoice date if (year .lt. 75) century = 20 ;Use 20XX (), ;Other fields if (year .lt. 50) century = 20 ;Use 20XX endusing (), ;All other structures using (a_class) select (D_RW_YYJJJ), if (year .lt. 50) century = 20 ;Use 20XX (), if (year .lt. 70) century = 20 ;Use 20XX endusing endusing freturn century endfunction