project QadFinancials > class BRecurringEntry > method GetNextPeriod

Description

Get Next Period


Parameters


iiPeriodIDinputintegerPeriod ID
iiPeriodYearinputintegerYear
iiPeriodPeriodinputintegerGL Period
oiPeriodIDoutputintegerNext Period ID
oiPeriodYearoutputintegerYear of next Period
oiPeriodPeriodoutputintegerPeriod of next Period
otPeriodStartDateoutputdateStart Date of next period
otPeriodEndDateoutputdateEnd date of next Period
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BRecurringEntry.ApiPostRecEntryCommit
method BRecurringEntry.GenerateCalendar


program code (program6/brecurringentry.p)

assign oiPeriodID        = 0
       oiPeriodYear      = 0
       oiPeriodPeriod    = 0
       otPeriodStartDate = ?
       otPeriodEndDate   = ?.

<Q-1 run PeriodByYearPeriod (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input iiPeriodYear, (PeriodYear)
           input iiPeriodPeriod, (PeriodPeriod)
           input iiPeriodID, (PeriodId)
           output dataset tqPeriodByYearPeriod) in BPeriod >
find tqPeriodByYearPeriod 
     no-lock no-error.
if not available tqPeriodByYearPeriod
then do:
    assign vcMessageRE    = trim(#T-5'The current GL period is not available.':150(3510)T-5#) + chr(10) + 
                            trim(substitute(#T-15'There is no period with field &1 equal to &2.':255(59826)t-15#,trim(#T-16'Period year':255(59820)t-16#),string(iiPeriodYear))) + chr(10) + 
                            trim(substitute(#T-17'There is no period with field &1 equal to &2.':255(59826)t-17#,trim(#T-18'Period-period':255(59819)T-18#),string(iiPeriodPeriod))) + chr(10) + 
                            trim(substitute(#T-11'There is no period with field &1 equal to &2.':255(59826)t-11#,trim(#T-12'Period ID':255(59821)t-12#),string(iiPeriodID))) + chr(10) + 
                            trim(substitute(#T-13'There is no period with field &1 equal to &2.':255(59826)t-13#,trim(#T-14'Company ID':255(59822)t-14#),string(viCompanyId)))
                            
           oiReturnStatus = -1.
    <M-4 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-993':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>    
    return.
end.
else 
    if tqPeriodByYearPeriod.tcPeriodTypeCode <> {&PERIODTYPECODE-NORMAL}
    then do :
        assign vcMessageRE    = trim(substitute(#T-21'The period (&1/&2) must be of type &3 and not of type &4.':255(59827)t-21#,trim(string(tqPeriodByYearPeriod.tiPeriodYear)),trim(string(tqPeriodByYearPeriod.tiPeriodPeriod)),trim({&PERIODTYPECODE-NORMAL-TR}),trim(tqPeriodByYearPeriod.tcPeriodTypeCode)))
               oiReturnStatus = -1.
        <M-19 run SetMessage (input  vcMessageRE (icMessage),
                         input  '':U (icArguments),
                         input  '':U (icFieldName),
                         input  '':U (icFieldValue),
                         input  'E':U (icType),
                         input  3 (iiSeverity),
                         input  '':U (icRowid),
                         input  'QadFin-6107':U (icFcMsgNumber),
                         input  '' (icFcExplanation),
                         input  '' (icFcIdentification),
                         input  '' (icFcContext),
                         output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>    
        return.
    end. /* if tqPeriodByYearPeriod.tcPeriodTypeCode <> {&PERIODTYPECODE-NORMAL} */

<Q-2 run PeriodNextPeriodByYearPeriod (first) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input tqPeriodByYearPeriod.tiPeriodYear, (PeriodYear)
           input tqPeriodByYearPeriod.tiPeriodPeriod, (PeriodPeriod)
           output dataset tqPeriodNextPeriodByYearPeriod) in BPeriod >
find first tqPeriodNextPeriodByYearPeriod no-lock no-error.
if not available tqPeriodNextPeriodByYearPeriod
then do:
    assign vcMessageRE    = trim(substitute(#T-6'There is no subsequent GL period available for GL period &1/&2.':150(3511)T-6#, tqPeriodByYearPeriod.tiPeriodYear, tqPeriodByYearPeriod.tiPeriodPeriod ))
           oiReturnStatus = -1.
    <M-3 run SetMessage (input  vcMessageRE (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-984':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>    
    Return.
end.
assign oiPeriodID        = tqPeriodNextPeriodByYearPeriod.tiPeriod_ID
       oiPeriodYear      = tqPeriodNextPeriodByYearPeriod.tiPeriodYear
       oiPeriodPeriod    = tqPeriodNextPeriodByYearPeriod.tiPeriodPeriod
       otPeriodStartDate = tqPeriodNextPeriodByYearPeriod.ttPeriodStartDate
       otPeriodEndDate   = tqPeriodNextPeriodByYearPeriod.ttPeriodEndDate.