project QadFinancials > class BPeriod > method ValDate

validation procedure

Description

Validate the end or upper limit date,
the startdate cannot be situated after the end date or
the lower limit date cannot be situated after the higher limit date


Parameters


icTargetFieldinputcharacterValue of the field to validate.
icTargetFieldNameinputcharacterName of the field to validate. Use the database field name or public data item name.
Example : 'Order.Order-Num'.
icRowidinputcharacterContents of field tc_Rowid, if the target field is a field of a component temp-table.
itEndDateinputdateEnd Date or Upper Limit Date
iiPeriodYearinputintegerYear of the period
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
validation on tPeriod.PeriodStartDate


program code (program4/bperiod.p)

if date(icTargetField) > itEndDate
    then do:
        assign vcMessage = if icTargetFieldName = "Period.PeriodStartDate":U
                           then trim(#T-3'The end date (&1) must be after the start date (&2).':255(3082)T-3#)
                           else trim(#T-4'The Higher Limit Date (&1) must be after the Lower Limit Date (&2).':250(55855)T-4#)
               vcMessage = trim(substitute(vcMessage,string(itEndDate),icTargetField))
               oiReturnStatus = -1.
        <M-1 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  icTargetFieldName (icFieldName),
                     input  icTargetField (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  icRowid (icRowid),
                     input  'QADFIN-167':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BPeriod>
    end.
    else do:
        if icTargetFieldName = "Period.PeriodStartDate":U
        then do:
            /* test on leap year(schrikkeljaar) */
            if (date("03/01/":U + string(iiPeriodYear,"9999":U)) - 1) = date("02/28/":U + string(iiPeriodYear,"9999":U))
            then assign vlError = if (itEndDate - date(icTargetField)) > 365
                                  then true
                                  else false.
            else assign vlError = if (itEndDate - date(icTargetField)) > 366
                                  then true
                                  else false.
            if vlError
            then do:
                assign vcMessage      = trim(substitute(#T-5'The time between start and end date cannot be more than one year (start date = &1, end date = &2).':255(3084)T-5#,icTargetField,string(itEndDate)))
                       oiReturnStatus = -1.
                <M-2 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  icTargetFieldName (icFieldName),
                     input  icTargetField (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  icRowid (icRowid),
                     input  'QADFIN-176':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BPeriod>
            end.
        end.
    end.