project QadFinancials > class BConsolid > method CreateConsolidation
Description
Method to create consolidation postings. This will be based on the consolidation cycle.
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)
/* ============================= */
/* Validate the input parameters */
/* ============================= */
assign vcMessage = '':U.
/* No empty SourceCompanyList */
if icSourceCompanyCodeList = '':U or icSourceCompanyCodeList = ?
then do:
assign vcMessage = trim(#T-34'You must select at least one source entity for consolidation.':200(1325)t-34#)
oiReturnStatus = -1.
<M-2 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-2263':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BConsolid>
end.
/* From - To period should be filled */
if iiFromPeriodYear = 0 or iiFromPeriodYear = ? or
iiFromPeriodPeriod = 0 or iiFromPeriodPeriod = ?
then do:
assign vcMessage = trim(#T-35'You must define the starting GL period for consolidation.':200(1326)T-35#)
oiReturnStatus = -1.
<M-44 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-8938':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BConsolid>
end.
if iiToPeriodYear = 0 or iiToPeriodYear = ? or
iiToPeriodPeriod = 0 or iiToPeriodPeriod = ?
then do:
assign vcMessage = trim(#T-36'You must define the ending GL period for consolidation.':200(1327)T-36#)
oiReturnStatus = -1.
<M-3 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-2264':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BConsolid>
end.
if (iiFromPeriodYear = 0 or iiFromPeriodYear = ?) and
(iiFromPeriodPeriod = 0 or iiFromPeriodPeriod = ?)
then do:
/* Check if selected periods exist */
<Q-11 assign vlFcQueryRecordsAvailable = PeriodPrim (NoCache)
(input viCompanyId, (CompanyId)
input 0, (PeriodId)
input iiFromPeriodYear, (PeriodYear)
input iiFromPeriodPeriod, (PeriodPeriod)) in BPeriod >
if vlFcQueryRecordsAvailable = false
then do:
assign vcMessage = trim(substitute(#T-37'The Starting GL period (&1/&2) specified is not defined in the system.':200(1328)t-37#, trim(string(iiFromPeriodYear)), trim(string(iiFromPeriodPeriod)) ))
oiReturnStatus = -1.
<M-12 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-2265':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BConsolid>
end.
end.
if (iiToPeriodYear = 0 or iiToPeriodYear = ?) and
(iiToPeriodPeriod = 0 or iiToPeriodPeriod = ?)
then do:
<Q-13 assign vlFcQueryRecordsAvailable = PeriodPrim (NoCache)
(input viCompanyId, (CompanyId)
input 0, (PeriodId)
input iiToPeriodYear, (PeriodYear)
input iiToPeriodPeriod, (PeriodPeriod)) in BPeriod >
if vlFcQueryRecordsAvailable = false
then do:
assign vcMessage = trim(substitute(#T-38'The Ending GL period (&1/&2) specified is not defined in the system.':200(1329)t-38#, trim(string(iiToPeriodYear)), trim(string(iiToPeriodPeriod)) ))
oiReturnStatus = -1.
<M-14 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-2266':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BConsolid>
end.
end.
if oiReturnStatus < 0
then return.
/* ============================= */
/* Get a new number for this run */
/* ============================= */
<Q-33 run ConsolidByCompany (last) (Read) (NoCache)
(input viCompanyId, (CompanyID)
output dataset tqConsolidByCompany) in BConsolid >
find last tqConsolidByCompany no-lock no-error.
if available tqConsolidByCompany
then assign viNumber = tqConsolidByCompany.tiConsolidNumber + 1.
else assign viNumber = 1.
/* ===================================================== */
/* Process each source company as a seperate transaction */
/* ===================================================== */
do viCounter = num-entries(icSourceCompanyCodeList, chr(2)) to 1 by -1 on error undo, throw:
/* Clear Instance */
<M-18 run ClearData (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave.
/* ============================================= */
/* TRANSACTION 1: Create Initial Consolid record */
/* ============================================= */
<M-19 run AddDetailLine
(input 'Consolid':U (icTable),
input '':U (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave.
assign tConsolid.ConsolidCompany_ID = viCompanyId
tConsolid.tcSourceCompanyCode = entry(vicounter, icSourceCompanyCodeList, chr(2))
tConsolid.ConsolidDate = today
tConsolid.ConsolidStartTime = time
tConsolid.ConsolidStatus = {&CONSOLIDSTATUS-INITIAL}
tConsolid.ConsolidSourceLayerTypCode = icSourceLayerType
tConsolid.ConsolidTargetLayerTypCode = icTargetLayerType
tConsolid.tiFromPeriodYear = iiFromPeriodYear
tConsolid.tiFromPeriodPeriod = iiFromPeriodPeriod
tConsolid.tiToPeriodYear = iiToPeriodYear
tConsolid.tiToPeriodPeriod = iiToPeriodPeriod
tConsolid.ConsolidNumber = viNumber.
for each tConsolidLayerDefault:
/* ============================== */
/* Create a tConsolidLayer record */
/* ============================== */
<M-43 run AddDetailLine
(input 'ConsolidLayer':U (icTable),
input tConsolid.tc_Rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper <> 0
then do:
assign oiReturnStatus = viFcReturnSuper.
return.
end. /* if viFcReturnSuper <> 0 */
assign tConsolidLayer.tcLayerCode = tConsolidLayerDefault.tcLayerCode
tConsolidLayer.Layer_ID = tConsolidLayerDefault.Layer_ID
tConsolidLayer.tlConsolidLayerIsSelected = tConsolidLayerDefault.tlConsolidLayerIsSelected.
end.
/* Validate Component */
<M-21 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then next.
/* Additional Updates */
<M-22 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then next.
/* DataSave */
<M-23 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then next.
/* ==================================================================== */
/* TRANSACTION 2: Set Consolid record to executed (postings in add.upd) */
/* ==================================================================== */
assign viTrans2ReturnStatus = 0.
TRANSACT2BLOCK:
do:
find first tConsolid no-error.
if not available tConsolid
then do:
assign vcMessage = trim(#T-39'The consolidation record is no longer available.':200(1330)t-39#) + chr(10) +
trim(#T-40'Delete the consolidation record with the status Initial.':200(1331)T-40#)
vhFcComponent = ?
viTrans2ReturnStatus = -25.
<M-30 run CreateCorruption
(input 'Consolid':U (icTableName),
input 'ConsolidStatus':U (icKey),
input vcMessage (icDescription),
input ? (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
end.
assign tConsolid.ConsolidStatus = {&CONSOLIDSTATUS-EXECUTED}
tConsolid.tc_Status = 'C':U.
/* Validate Component */
<M-24 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign viTrans2ReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave TRANSACT2BLOCK.
/* Additional Updates */
<M-25 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign viTrans2ReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave TRANSACT2BLOCK.
/* DataSave */
<M-26 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign viTrans2ReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave TRANSACT2BLOCK.
end. /* TRANSACT2BLOCK */
if viTrans2ReturnStatus >= 0
then next.
else assign oiReturnStatus = viTrans2ReturnStatus.
/* ===================================================================== */
/* TRANSACTION 3: Remove 'Initial' Consolid record when execution failed */
/* ===================================================================== */
TRANSACT3BLOCK:
do:
find first tConsolid no-error.
if not available tConsolid
then do:
assign vcMessage = trim(#T-41'The consolidation record is no longer available.':200(1330)t-41#) + chr(10) +
trim(#T-42'Delete the consolidation record with the status Initial.':200(1331)T-42#)
vhFcComponent = ?
oiReturnStatus = -25.
<M-31 run CreateCorruption
(input 'Consolid':U (icTableName),
input 'ConsolidStatus':U (icKey),
input vcMessage (icDescription),
input ? (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
end.
assign tConsolid.ConsolidStatus = {&CONSOLIDSTATUS-INITIAL}
tConsolid.Posting_ID = 0
tConsolid.tc_Status = 'D':U.
/* Remove tConsolidPostingXref records that were not yet saved */
for each tConsolidPostingXref where
tConsolidPostingXref.tc_ParentRowid = tConsolid.tc_Rowid and
tConsolidPostingXref.tc_Status = "N":U:
delete tConsolidPostingXref.
end.
/* Validate Component */
<M-27 run ValidateBC (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave TRANSACT3BLOCK.
/* Additional Updates */
<M-28 run AdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave TRANSACT3BLOCK.
/* DataSave */
<M-29 run DataSave (output viFcReturnSuper (oiReturnStatus)) in BConsolid>
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then leave TRANSACT3BLOCK.
end. /* TRANSACT3BLOCK */
end. /* do viCounter = num-entries(icSourceCompanyCodeList, chr(2)) to 1 by -1: */