project QadFinancials > class BConsolid > method CheckPreviousPeriod
Description
Check if previous period was consolidated. Called on UI before calling the CreateConsolidation method.
Parameters
| icSourceCompanyCodeList | input | character | chr(2) seperated list of source company codes that need to consolidated. |
| iiFromPeriodYear | input | integer | From year to consolidate |
| iiFromPeriodPeriod | input | integer | From Period to consolidate |
| iiToPeriodYear | input | integer | To Year to consolidate |
| iiToPeriodPeriod | input | integer | To Period to consolidate |
| icTargetLayerType | input | character | Target Layer Type Code (Transient/Management/Official) |
| icSourceLayerType | input | character | Source Layer Type Code (Management/Official) |
| tConsolidLayerDefault | input | temp-table | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program6/bconsolid.p)
/* =============================================================================== */
/* If the previous period in the target entity was not consolidated yet, we check */
/* if there are postings in the source entity for that period */
/* If there are, we raise a warning in case the target layer <> OFFICIAL */
/* (In case the target layer = OFFICIAL, an error will be raised in */
/* ValidateComponent method.) */
/* =============================================================================== */
assign oiReturnStatus = -98
viSourceFromPeriod = 0
viSourceFromYear = 0.
if icTargetLayerType <> {&CONSOLIDTARGETLAYERTYPE-OFFICIAL}
then do viCompanyCnt = num-entries(icSourceCompanyCodeList, chr(2)) to 1 by -1:
<Q-85 run CompanyPrim (all) (Read) (NoCache)
(input 0, (LookupCompanyId)
input entry(viCompanyCnt, icSourceCompanyCodeList, chr(2)), (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
find tqCompanyPrim where
tqCompanyPrim.tcCompanyCode = entry(viCompanyCnt, icSourceCompanyCodeList, chr(2))
no-lock no-error.
if not available tqCompanyPrim
then do:
assign oiReturnStatus = -1
vcMessage = trim(substitute(#T-86'The specified entity code &1 is invalid.':255(64116)t-86#, entry(viCompanyCnt, icSourceCompanyCodeList, chr(2)), "CHARACTER" )).
<M-87 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-6973':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BConsolid>
return.
end.
else assign viSourceCompanyId = tqCompanyPrim.tiCompany_ID.
/* =============================================== */
/* Consolidation Layer Record should not yet exist */
/* =============================================== */
for each tConsolidLayerDefault:
/* ============================================================== */
/* Get the period before the selected period in the target entity */
/* ============================================================== */
<Q-76 run PeriodPrevPeriodByYearPeriod (last) (Read) (NoCache)
(input viCompanyId, (CompanyId)
input iiFromPeriodYear, (PeriodYear)
input iiFromPeriodPeriod, (PeriodPeriod)
output dataset tqPeriodPrevPeriodByYearPeriod) in BPeriod >
find last tqPeriodPrevPeriodByYearPeriod
no-lock no-error.
if available tqPeriodPrevPeriodByYearPeriod
then do:
<Q-91 run ConsolidLayerBySourceCyLayer (all) (Read) (NoCache)
(input entry(viCompanyCnt, icSourceCompanyCodeList, chr(2)), (SourceCompanyCode)
input icSourceLayerType, (SourceLayerType)
input icTargetLayerType, (TargetLayerType)
input tConsolidLayerDefault.tcLayerCode, (TargetLayerCode)
input viCompanyId, (CompanyId)
output dataset tqConsolidLayerBySourceCyLayer) in BConsolid>
if not can-find(first tqConsolidLayerBySourceCyLayer where
tqConsolidLayerBySourceCyLayer.tcSourceCompanyCode = entry(viCompanyCnt, icSourceCompanyCodeList, chr(2)) and
tqConsolidLayerBySourceCyLayer.tcConsolidSourceLayerTypCode = icSourceLayerType and
tqConsolidLayerBySourceCyLayer.tcConsolidTargetLayerTypCode = icTargetLayerType and
tqConsolidLayerBySourceCyLayer.tcLayerCode = tConsolidLayerDefault.tcLayerCode and
tqConsolidLayerBySourceCyLayer.tiConsolidCompany_ID = viCompanyId and
tqConsolidLayerBySourceCyLayer.tiToPeriodYearPeriod = tqPeriodPrevPeriodByYearPeriod.tiPeriodYearPeriod)
then do:
/* =========================================================================== */
/* Get the period in the source entity which are mapped to the selected period */
/* =========================================================================== */
<Q-11 run ConsolidPeriodXrefByPeriod (all) (Read) (NoCache)
(input viSourceCompanyId, (CompanyId)
input viCompanyId, (ConsolidCompanyID)
input vcCompanyCode, (ConsolidCompanyCode)
input ?, (SourceYear)
input ?, (SourcePeriod)
input iiFromPeriodYear, (TargetYear)
input iiFromPeriodPeriod, (TargetPeriod)
output dataset tqConsolidPeriodXrefByPeriod) in BConsolidPeriodXref>
/* ============================================================== */
/* The selected companies should be X-reffed (ConsolidPeriodXref) */
/* ============================================================== */
find first tqConsolidPeriodXrefByPeriod where
tqConsolidPeriodXrefByPeriod.tiCompany_ID = viSourceCompanyId and
tqConsolidPeriodXrefByPeriod.tiConsolidationCompany_ID = viCompanyId and
tqConsolidPeriodXrefByPeriod.tiConsolidPeriodYear = iiFromPeriodYear and
tqConsolidPeriodXrefByPeriod.tiConsolidPeriodPeriod = iiFromPeriodPeriod
no-error.
if available tqConsolidPeriodXrefByPeriod
then do:
assign viSourceFromPeriod = tqConsolidPeriodXrefByPeriod.tiPeriodPeriod
viSourceFromYear = tqConsolidPeriodXrefByPeriod.tiPeriodYear.
/* Check if there were postings before this period */
<Q-77 assign vlFcQueryRecordsAvailable = PostingHistByCyLayerBeforeYP (NoCache)
(input tqCompanyPrim.tiCompany_ID, (CompanyId)
input tConsolidLayerDefault.tcLayerCode, (LayerCode)
input (viSourceFromYear * 100) + viSourceFromPeriod, (BeforeYearPeriod)) in BPostingHist>
/* In case at least 1 was found, a warning is raised */
if vlFcQueryRecordsAvailable <> false
then do:
assign vcMessage = trim(substitute(#T-82'The previous GL period (&1/&2) has not yet been consolidated.':200(1320)t-82#, trim(string(tqPeriodPrevPeriodByYearPeriod.tiPeriodYear)), trim(string(tqPeriodPrevPeriodByYearPeriod.tiPeriodPeriod)) )).
assign oiReturnStatus = 1.
<M-83 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'W':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QadFin-6971':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BConsolid>
end. /* if vlFcQueryRecordsAvailable <> false */
end. /* if available tqConsolidPeriodXrefByPeriod */
end. /* if not can-find(first tqConsolidLayerBySourceCyLayer */
end. /* if available tqPeriodPrevPeriodByYearPeriod */
end. /* for each tConsolidLayerDefault where */
end. /* do viCompanyCnt = num-entries(icSourceCompanyCodeList, chr(2), "CHARACTER) to 1 by -1: */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.