project QadFinancials > class BPeriod > method GetPeriodsOfRange

Description

This method returns the periods which covers the input criteria. Input can be from/till date or from/till period.


Parameters


itFromDateinputdateFrom Date
itTillDateinputdateTill Date
iiFromYearPeriodinputintegerFrom Year Period
iiTillYearPeriodinputintegerTill Year Period
iiCompany_IDinputintegerCompany_ID
tSelectedPeriodsoutputtemp-tableTemptable like period, used to store all selected period.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAnalyticalReport.CostCentreTransDet
method BAnalyticalReport.CostCentreTransSumm
method BAnalyticalReport.CostCentreTransSummCompPer
method BAnalyticalReport.ProjectTransDet
method BAnalyticalReport.SafOnlyTransDet
method BAnalyticalReport.SafOnlyTransSumm
method BAnalyticalReport.SafOnlyTransSummCompPer
method BAPMatchingReport.InvoiceMatching
method BGLReport.CBGLReport
method BGLReport.GLAccountSheet
method BGLReport.MirrorAccountingTr
method BGLReport.SubLedgeReport
method BGLReport.Transactions_DIV
method BGLReport.Transactions_GL
method BGLReport.Transactions_IC
method BGLReport.Transactions_JRNL


program code (program6/bperiod.p)

/* ===================================================================================== */
/* This method returns all the periods covering the YearPeriodFrom/Till or DateFrom/Till */
/* - in case a YearPeriodFrom/Till is supplied all periods in this range are returned    */
/* - in case a DateFrom/Till is supplied, the sytem returns all periods                  */
/*      - the period covering the DateFrom                                               */
/*      - the period covering the DateTill                                               */
/*      - the periods in between                                                         */
/* ===================================================================================== */
if oiReturnStatus = 0 
then assign oiReturnStatus = -98.

empty temp-table tSelectedPeriods.

/* Check the input parameters */
if iiFromYearPeriod = ? then assign iiFromYearPeriod = 0.
if iiTillYearPeriod = ? then assign iiTillYearPeriod = 0.
if iiCompany_ID = ?     then assign iiCompany_ID = 0.

if iiCompany_ID <> 0 and 
   (iiFromYearPeriod <> 0 or iiTillYearPeriod <> 0 or itFromDate <> ? or itTillDate <> ?)
then do :

    /* ============================================ */
    /* Get the periods based on YearPeriodFrom/Till */
    /* ============================================ */
    if iiFromYearPeriod <> 0 or iiTillYearPeriod <> 0
    then do :    
         if iiFromYearPeriod <= iiTillYearPeriod
         then do :
             <Q-1 run GetPeriodsOfPeriodRange (all) (Read) (NoCache)
                (input iiCompany_ID, (CompanyId)
                 input iiFromYearPeriod, (YearPeriodFrom)
                 input iiTillYearPeriod, (YearPeriodTill)
                 output dataset tqGetPeriodsOfPeriodRange) in BPeriod >
        
             for each tqGetPeriodsOfPeriodRange :             
                 create tSelectedPeriods.
                 buffer-copy tqGetPeriodsOfPeriodRange to tSelectedPeriods.
    
            end. /* for each */
        end.    
    end.
    else
    /* ====================================== */
    /* Get the periods based on DateFrom/Till */
    /* ====================================== */
    if itFromDate <> ? or itTillDate <> ?
    then do :
        if itFromDate <= itTillDate
        then do :
    
            <Q-2 run GetPeriodsOfDateRange (all) (Read) (NoCache)
               (input iiCompany_ID, (CompanyId)
                input itTillDate, (ToDate)
                input itFromDate, (FromDate)
                output dataset tqGetPeriodsOfDateRange) in BPeriod >
        
             for each tqGetPeriodsOfDateRange:        
                 create tSelectedPeriods.
                 buffer-copy tqGetPeriodsOfDateRange to tSelectedPeriods.
            end. /* for each  */

        end. /* if itFromDate <= itTillDate */
    end.
end.

if oiReturnStatus = -98 
then assign oiReturnStatus = 0.