project QadFinancials > class BYearClosing > method CalculateBalanceByGLByDivDIRECT
Parameters
iiCompanyID | input | integer | |
icLayerTypeCode | input | character | |
iiYearPeriod | input | integer | |
ilIsInclDivision | input | logical | |
oiPostingHistRecordsRead | output | integer | |
icLayerCode | input | character | Input parameter: Layer Code. |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/byearclosing.p)
/* ============================================================================== */
/* This method builds up the Balances for each GL/Division for the Official Layer */
/* It queries PostingHist directly for this */
/* Input: */
/* iiCompanyID */
/* iiYearPeriod */
/* ilIsInclDivision */
/* Output */
/* tPostingHistClosing */
/* ============================================================================== */
empty temp-table tPostingHistClosing.
/* Ensure, all parameters are passed */
if iiCompanyID = ? or iiCompanyID = 0 or
icLayerTypeCode = ? or icLayerTypeCode = "":U or
iiYearPeriod = ? or iiYearPeriod = 0 or
icLayerCode = ? or icLayerCode = '':U
then do:
assign vcMessage = #T-76'Not all mandatory input parameters are populated or they have wrong value.':255(999890330)T-76#
vcContext = "iiCompanyID=&1|icLayerTypeCode=&2|iiYearPeriod=&3|icLayerCode=&4":U
vcContext = replace(vcContext, "|":U, chr(2))
vcContext = substitute(vcContext, iiCompanyID, icLayerTypeCode, iiYearPeriod, icLayerCode).
<M-35 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'S':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-827185':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input vcContext (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BYearClosing>
assign oiReturnStatus = -1.
leave.
end. /* if iiCompanyID = ? or iiCompanyID = 0 or */
for each Company no-lock where
Company.Company_ID = iiCompanyID,
each CompanySharedSet of Company no-lock,
each SharedSet of CompanySharedSet no-lock where
SharedSet.SharedSetTypeCode = {&SHAREDSETTYPE-GL},
first Layer no-lock where
Layer.LayerTypeCode = icLayerTypeCode and
Layer.LayerCode = icLayerCode ,
each GL of SharedSet no-lock :
for each PostingHist where
PostingHist.Company_ID = Company.Company_ID and
PostingHist.GL_ID = GL.GL_ID and
PostingHist.Layer_ID = Layer.Layer_ID and
PostingHist.PostingHistYearPeriodFrom <= iiYearPeriod and
PostingHist.PostingHistYearPeriodTill >= iiYearPeriod
no-lock:
assign oiPostingHistRecordsRead = oiPostingHistRecordsRead + 1.
/* Determine DivisionCode */
assign vcDivisionCode = ''.
if ilIsInclDivision = true and PostingHist.Division_ID <> 0 and PostingHist.Division_ID <> ?
then do :
find Division of PostingHist no-lock no-error.
if available Division
then assign vcDivisionCode = Division.DivisionCode.
end.
/* Cache the Balance amounts */
find tPostingHistClosing where
tPostingHistClosing.tcClosingGLCode = GL.GLCode and
tPostingHistClosing.tcClosingDivisionCode = vcDivisionCode
no-error.
if not available tPostingHistClosing
then do:
create tPostingHistClosing.
assign tPostingHistClosing.tcClosingGLCode = GL.GLCode
tPostingHistClosing.tcClosingDivisionCode = vcDivisionCode
tPostingHistClosing.tcClosingGLTypeCode = GL.GLTypeCode
tPostingHistClosing.tlClosingGLIsBalanceAcc = GL.GLIsBalanceAccount.
end. /* not available tPostingHistClosing */
assign tPostingHistClosing.tdClosingDebitLC = tPostingHistClosing.tdClosingDebitLC + PostingHist.PostingHistBalanceDebitLC
tPostingHistClosing.tdClosingCreditLC = tPostingHistClosing.tdClosingCreditLC + PostingHist.PostingHistBalanceCreditLC
tPostingHistClosing.tdClosingDebitCC = tPostingHistClosing.tdClosingDebitCC + PostingHist.PostingHistBalanceDebitCC
tPostingHistClosing.tdClosingCreditCC = tPostingHistClosing.tdClosingCreditCC + PostingHist.PostingHistBalanceCreditCC.
end. /* for each PostingHist */
end. /* for each Company */