project QadFinancials > class BPeriod > method CheckPeriodExistence

Description

Check if the combination of year and period does exist in the instance


Parameters


iiCompanyIdinputintegerCompany id
iiPeriodYearinputintegerYear of the period
iiPeriodPeriodinputintegerPeriod of the Period
olDoesExistoutputlogicalThe period does exist or not in the instance
oiPeriod_IDoutputintegerPeriod_ID
oiPeriodMark_IDoutputintegerPeriodMark_ID
otStartDateoutputdateStart Date.
otEndDateoutputdateEnd Date.
ocPeriodTypeCodeoutputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.AddPostingHeader
method BPosting.ValidateComponentPost
method BPosting.ValidateComponentPostPosting2
method BPosting.ValidateComponentPreAssignPosting1


program code (program3/bperiod.p)

/* ====================== */
    /* replace unknown values */
    /* ====================== */
    if iiCompanyId = ? then assign iiCompanyId = 0.
    if iiPeriodYear = ? then assign iiPeriodYear = 0.
    if iiPeriodPeriod = ? then assign iiPeriodPeriod = 0.

    /* ============================================ */
    /* if the year is zero, no record will be found */
    /* ============================================ */
    if iiPeriodYear = 0
    then do:
        assign olDoesExist = false.
        return.
    end.
    
    /* ================================================== */
    /* search the combination of year, period and company */
    /* ================================================== */
    find first tPeriod where
               tPeriod.Company_ID   =  iiCompanyId    and
               tPeriod.PeriodYear   =  iiPeriodYear   and
               tPeriod.PeriodPeriod =  iiPeriodPeriod and
               tPeriod.tc_status    <> "D":U
               no-error.            
    assign olDoesExist      = if available tPeriod
                              then true
                              else false
           oiPeriod_ID      = if available tPeriod
                              then tPeriod.Period_ID
                              else ?
           oiPeriodMark_ID  = if available tPeriod
                              then tPeriod.PeriodMark_ID
                              else ?
           otStartDate      = if available tPeriod
                              then tPeriod.PeriodStartDate
                              else ?
           otEndDate        = if available tPeriod
                              then tPeriod.PeriodEndDate
                              else ?
           ocPeriodTypeCode = if available tPeriod
                              then tPeriod.PeriodTypeCode
                              else "":U
           .