project QadFinancials > class TConCheck > method TechnicalValidation02PostingHist
Description
Submethod of TechnicalValidation for checking PostingHist
Parameters
iiCompanyID | input | integer | |
iiYearPeriod | input | integer | |
iiPeriodID | input | integer | |
itFromDate | input | date | |
itToDate | input | date | |
oiErrorNumbers | output | integer | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/tconcheck.p)
/* ========================================================================= */
/* This method checks the PostingHist for a given Entity/Period. */
/* Following validations are done on the full accounting key: */
/* - Movements Posting = Movements PostingHist (A) */
/* - EndBal Period-1 + Mov Period = EndBal Period (B) */
/* (for all Period>=viSelectedYearPeriod) */
/* ========================================================================= */
assign oiReturnStatus = -98.
empty temp-table ttRebuild.
DEFINE BUFFER bPostingHist FOR PostingHist.
Main_Block:
do on error undo, throw:
/* ====================================================================================== */
/* Main Loop: Go through each GL of the company */
/* ====================================================================================== */
PUT STREAM sTechOut unformatted " " skip.
PUT STREAM sTechOut unformatted vcPrefix2 + "Start Validation movements, balances of the current period." skip.
Movement_Balance:
do:
if can-find (first QPostingLine where
QPostingLine.Company_ID = iiCompanyID
AND QPostingLine.QPostingDate <= itToDate)
then do :
PUT STREAM sTechOut unformatted vcPrefix + "Validation cannot be started as there are still records in the daemon queue (QPostingLine)" skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
leave Movement_Balance.
end.
find first Company where Company.Company_id = iiCompanyID no-lock no-error.
find first Period where Period.Period_ID = iiPeriodID no-lock no-error.
if available Period
then do:
assign viPeriodYear = Period.Periodyear.
end.
else do:
leave Main_Block.
end.
for each CompanySharedSet of Company no-lock,
first SharedSet of CompanySharedSet no-lock where
Sharedset.SharedSetType = {&SHAREDSETTYPE-GL},
each GL of Sharedset
no-lock:
assign viTotal = viTotal + 1.
/* *************************************************************************** */
/* 999999 Check By company, whole peirods */
/* *************************************************************************** */
for each PostingHist OF Company no-lock where
PostingHist.GL_ID = GL.gl_ID
break by PostingHist.Company_ID
by PostingHist.Journal_ID
by PostingHist.Layer_ID
by PostingHist.GL_ID
by PostingHist.Division_ID
by PostingHist.CostCentre_ID
by PostingHist.Project_ID
by PostingHist.Currency_ID
by PostingHist.IntercoBusinessRelation_ID
by PostingHist.PostingSafCombined_ID
by PostingHist.PostingHistYearPeriodFrom:
if last-of (PostingHist.PostingSafCombined_ID) and
PostingHist.PostingHistYearPeriodTill <> 999999
then do :
assign oiErrorNumbers = oiErrorNumbers + 1.
put stream sTechOut unformatted
'ERROR '
'END-RECORD '
'>' format 'x' ' '
companycode ' * '
GL.GLCode format 'x(10)' ' * '
PostingHist.PostingHistYearPeriodFrom ' * '
PostingHist.PostingHistYearPeriodTill ' * '
' JN:' PostingHist.Journal_ID format '9999999999'
' LA:' PostingHist.Layer_ID format '9999999999'
' DI:' PostingHist.Division_ID format '9999999999'
' CC:' PostingHist.CostCentre_ID format '9999999999'
' PR:' PostingHist.Project_ID format '9999999999'
' CU:' PostingHist.Currency_ID format '9999999999'
' IC:' PostingHist.IntercoBusinessRelation_ID format '9999999999'
' SA:' PostingHist.PostingSafCombined_ID format '9999999999' ' '
'Error: 999999 record is missing.'
skip.
end. /* if last-of (PostingHist.PostingSafCombined_ID) and */
end. /* for each PostingHist OF Company no-lock where */
IF NOT CAN-FIND (FIRST PostingHist WHERE
PostingHist.Company_ID = Company.Company_ID AND
PostingHist.GL_ID = GL.GL_ID and
PostingHist.PostingHistYearPeriodFrom = iiYearPeriod) AND
NOT CAN-FIND (FIRST PostingLine WHERE
PostingLine.Company_ID = Company.Company_ID AND
PostingLine.GL_ID = GL.GL_ID and
PostingLine.PostingYearPeriod = iiYearPeriod)
THEN NEXT.
/* *************************************************************************** */
/* A: check on the movements of the current period */
/* *************************************************************************** */
empty temp-table ttJE.
/*************************************************************************************/
/* A.1. Go through all the PostingLines/PostingSaf of this Company/Period */
/*************************************************************************************/
for each PostingLine no-lock where
PostingLine.Company_ID = Company.Company_ID and
PostingLine.GL_ID = GL.GL_ID and
PostingLine.PostingYearPeriod = Period.Periodyearperiod,
first Posting of PostingLine no-lock,
first Journal of Posting no-lock :
/* Get PostingSafCombined_ID. Create PostingSafCombined and PostingSafHist when the PostingSafCombined record does not exist. */
assign viCntPostingLine = viCntPostingLine + 1
viTotal = viTotal + 1
vcGLSafIDs = ",,,,":U
vcCostCentreSafIDs = ",,,,":U
vcProjectSafIDs = ",,,,":U
vlSafUsed = false
viCostCentreSafStructureID = 0
viProjectSafStructureID = 0
viGLSafStructureID = 0.
/* Get the SAF Info */
for each PostingSaf no-lock where
PostingSaf.PostingLine_ID = PostingLine.PostingLine_ID:
assign viCntPostingSAF = viCntPostingSAF + 1
viTotal = viTotal + 1
vlSafUsed = true.
if PostingSaf.PostingSafParentType = "GL"
then assign entry(PostingSaf.PostingSafInputSequence, vcGLSafIDs) = string(PostingSaf.Saf_ID).
if PostingSaf.PostingSafParentType = "COSTCENTRE"
then assign entry(PostingSaf.PostingSafInputSequence, vcCostCentreSafIDs) = string(PostingSaf.Saf_ID).
if PostingSaf.PostingSafParentType = "PROJECT"
then assign entry(PostingSaf.PostingSafInputSequence, vcProjectSafIDs) = string(PostingSaf.Saf_ID).
if viGLSafStructureID = 0 and PostingSaf.PostingSafParentType = "GL"
then assign viGLSafStructureID = PostingSaf.SafStructure_ID.
if viCostCentreSafStructureID = 0 and PostingSaf.PostingSafParentType = "COSTCENTRE"
then assign viCostCentreSafStructureID = PostingSaf.SafStructure_ID.
if viProjectSafStructureID = 0 and PostingSaf.PostingSafParentType = "PROJECT"
then assign viProjectSafStructureID = PostingSaf.SafStructure_ID.
end. /* for each PostingSaf */
if vlSafUsed <> true
then assign viPostingSafCombined_ID = 0.
else do:
assign viPostingSafCombined_ID = 0.
find first PostingSafCombined where
PostingSafCombined.Project1Saf_ID = integer(entry(1, vcProjectSafIDs)) and
PostingSafCombined.Project2Saf_ID = integer(entry(2, vcProjectSafIDs)) and
PostingSafCombined.Project3Saf_ID = integer(entry(3, vcProjectSafIDs)) and
PostingSafCombined.Project4Saf_ID = integer(entry(4, vcProjectSafIDs)) and
PostingSafCombined.Project5Saf_ID = integer(entry(5, vcProjectSafIDs)) and
PostingSafCombined.CostCentre1Saf_ID = integer(entry(1, vcCostCentreSafIDs)) and
PostingSafCombined.CostCentre2Saf_ID = integer(entry(2, vcCostCentreSafIDs)) and
PostingSafCombined.CostCentre3Saf_ID = integer(entry(3, vcCostCentreSafIDs)) and
PostingSafCombined.CostCentre4Saf_ID = integer(entry(4, vcCostCentreSafIDs)) and
PostingSafCombined.CostCentre5Saf_ID = integer(entry(5, vcCostCentreSafIDs)) and
PostingSafCombined.GL1Saf_ID = integer(entry(1, vcGLSafIDs)) and
PostingSafCombined.GL2Saf_ID = integer(entry(2, vcGLSafIDs)) and
PostingSafCombined.GL3Saf_ID = integer(entry(3, vcGLSafIDs)) and
PostingSafCombined.GL4Saf_ID = integer(entry(4, vcGLSafIDs)) and
PostingSafCombined.GL5Saf_ID = integer(entry(5, vcGLSafIDs)) and
PostingSafCombined.ProjectSafStructure_ID = viProjectSafStructureID and
PostingSafCombined.CostCentreSafStructure_ID = viCostCentreSafStructureID and
PostingSafCombined.GLSafStructure_ID = viGLSafStructureID
no-lock no-error.
if available PostingSafCombined then
assign viPostingSafCombined_ID = PostingSafCombined.PostingSafCombined_ID.
if viPostingSafCombined_ID = 0
then do:
assign oiErrorNumbers = oiErrorNumbers + 1.
put stream sTechOut UNFORMATTED 'PostingSafCombined not found.'
skip.
next.
end.
end. /* if vlSafUsed = true */
/* Get the cached info on the total accounting key */
find ttJE where
ttJE.tcCompanyCode = Company.CompanyCode and
ttJE.tiPostingHistYearPeriodFrom = (if PostingLine.PostingYearPeriod = ? then 0 else PostingLine.PostingYearPeriod) and
ttJE.tiJournal_ID = (if Posting.Journal_ID = ? then 0 else Posting.Journal_ID) and
ttJE.tiLayer_ID = (if Journal.Layer_ID = ? then 0 else Journal.Layer_ID) and
ttJE.tiCurrency_ID = (if PostingLine.currency_Id = ? then 0 else PostingLine.currency_Id) and
ttJE.tcGLCode = GL.GLCode and
ttJE.tiProject_ID = (if PostingLine.Project_ID = ? then 0 else PostingLine.Project_ID) and
ttJE.tiCostCentre_ID = (if PostingLine.Costcentre_ID = ? then 0 else PostingLine.Costcentre_ID) and
ttJE.tiDivision_ID = (if PostingLine.Division_ID = ? then 0 else PostingLine.Division_ID) and
ttJE.tiIntercoBusinessRelation_ID = (if PostingLine.IntercoBusinessRelation_ID = ? then 0 else PostingLine.IntercoBusinessRelation_ID) and
ttJE.tiPostingSafCombined_ID = viPostingSafCombined_ID
no-error.
if not available ttJE
then do:
create ttJE.
assign
viCntttJE = viCntttJE + 1
ttJE.tcTYPE = 'LINE'
ttJE.tcCompanyCode = Company.CompanyCode
ttJE.tiPostingHistYearPeriodFrom = (if PostingLine.PostingYearPeriod = ? then 0 else PostingLine.PostingYearPeriod)
ttJE.tiJournal_ID = (if Posting.Journal_ID = ? then 0 else Posting.Journal_ID)
ttJE.tiLayer_ID = (if Journal.Layer_ID = ? then 0 else Journal.Layer_ID)
ttJE.tiCurrency_ID = (if PostingLine.currency_Id = ? then 0 else PostingLine.currency_Id)
ttJE.tcGLCode = GL.GLCode
ttJE.tiProject_ID = (if PostingLine.Project_ID = ? then 0 else PostingLine.Project_ID)
ttJE.tiCostCentre_ID = (if PostingLine.Costcentre_ID = ? then 0 else PostingLine.Costcentre_ID)
ttJE.tiDivision_ID = (if PostingLine.Division_ID = ? then 0 else PostingLine.Division_ID)
ttJE.tiIntercoBusinessRelation_ID = (if PostingLine.IntercoBusinessRelation_ID = ? then 0 else PostingLine.IntercoBusinessRelation_ID)
ttJE.tiPostingSafCombined_ID = viPostingSafCombined_ID.
end. /* if not available ttJE */
/* Keep the Movements of the Posting per accounting key */
assign ttJE.tdTotalPostingLineCreditTC = ttJE.tdTotalPostingLineCreditTC + Postingline.PostingLineCreditTC
ttJE.tdTotalPostingLineCreditLC = ttJE.tdTotalPostingLineCreditLC + Postingline.PostingLineCreditLC
ttJE.tdTotalPostingLineCreditCC = ttJE.tdTotalPostingLineCreditCC + Postingline.PostingLineCreditCC
ttJE.tdTotalPostingLineDebitTC = ttJE.tdTotalPostingLineDebitTC + Postingline.PostingLineDebitTC
ttJE.tdTotalPostingLineDebitLC = ttJE.tdTotalPostingLineDebitLC + Postingline.PostingLineDebitLC
ttJE.tdTotalPostingLineDebitCC = ttJE.tdTotalPostingLineDebitCC + Postingline.PostingLineDebitCC.
end. /* for each PostingLine */
/*************************************************************************************/
/* A.2. Go through all the History */
/*************************************************************************************/
for each PostingHist where
PostingHist.Company_ID = Company.Company_ID and
PostingHist.GL_ID = GL.GL_ID and
PostingHist.PostingHistYearPeriodFrom = Period.Periodyearperiod
no-lock:
assign viCntPostingHist = viCntPostingHist + 1
viTotal = viTotal + 1.
/* Get the cached info on the total accounting key */
find ttJE where
ttJE.tcCompanyCode = Company.CompanyCode and
ttJE.tiPostingHistYearPeriodFrom = (if PostingHist.PostingHistYearPeriodFrom = ? then 0 else PostingHist.PostingHistYearPeriodFrom) and
ttJE.tiJournal_ID = (if PostingHist.Journal_ID = ? then 0 else PostingHist.Journal_ID) and
ttJE.tiLayer_ID = (if PostingHist.Layer_ID = ? then 0 else PostingHist.Layer_ID) and
ttJE.tiCurrency_ID = (if PostingHist.currency_Id = ? then 0 else PostingHist.currency_Id) and
ttJE.tcGLCode = GL.GLCode and
ttJE.tiProject_ID = (if PostingHist.Project_ID = ? then 0 else PostingHist.Project_ID) and
ttJE.tiCostCentre_ID = (if PostingHist.Costcentre_ID = ? then 0 else PostingHist.Costcentre_ID) and
ttJE.tiDivision_ID = (if PostingHist.Division_ID = ? then 0 else PostingHist.Division_ID) and
ttJE.tiIntercoBusinessRelation_ID = (if PostingHist.IntercoBusinessRelation_ID = ? then 0 else PostingHist.IntercoBusinessRelation_ID) and
ttJE.tiPostingSafCombined_ID = PostingHist.PostingSafCombined_ID
no-error.
if available ttJE
then assign ttJE.tcTYPE = 'BOTH'.
else do:
create ttJE.
assign
viCntttJE = viCntttJE + 1
ttJE.tcTYPE = 'HIST'
ttJE.tcCompanyCode = Company.CompanyCode
ttJE.tiPostingHistYearPeriodFrom = (if PostingHist.PostingHistYearPeriodFrom = ? then 0 else PostingHist.PostingHistYearPeriodFrom)
ttJE.tiJournal_ID = (if PostingHist.Journal_ID = ? then 0 else PostingHist.Journal_ID)
ttJE.tiLayer_ID = (if PostingHist.Layer_ID = ? then 0 else PostingHist.Layer_ID)
ttJE.tiCurrency_ID = (if PostingHist.currency_Id = ? then 0 else PostingHist.currency_Id)
ttJE.tcGLCode = GL.GLCode
ttJE.tiProject_ID = (if PostingHist.Project_ID = ? then 0 else PostingHist.Project_ID)
ttJE.tiCostCentre_ID = (if PostingHist.Costcentre_ID = ? then 0 else PostingHist.Costcentre_ID)
ttJE.tiDivision_ID = (if PostingHist.Division_ID = ? then 0 else PostingHist.Division_ID)
ttJE.tiIntercoBusinessRelation_ID = (if PostingHist.IntercoBusinessRelation_ID = ? then 0 else PostingHist.IntercoBusinessRelation_ID)
ttJE.tiPostingSafCombined_ID = PostingHist.PostingSafCombined_ID.
end.
/* Keep the Movements of the PostingHist per accounting key */
assign ttJE.tdPostingHistMovemntCreditTC = ttJE.tdPostingHistMovemntCreditTC + PostingHist.PostingHistMovemntCreditTC
ttJE.tdPostingHistMovemntCreditLC = ttJE.tdPostingHistMovemntCreditLC + PostingHist.PostingHistMovemntCreditLC
ttJE.tdPostingHistMovemntCreditCC = ttJE.tdPostingHistMovemntCreditCC + PostingHist.PostingHistMovemntCreditCC
ttJE.tdPostingHistMovemntDebitTC = ttJE.tdPostingHistMovemntDebitTC + PostingHist.PostingHistMovemntDebitTC
ttJE.tdPostingHistMovemntDebitLC = ttJE.tdPostingHistMovemntDebitLC + PostingHist.PostingHistMovemntDebitLC
ttJE.tdPostingHistMovemntDebitCC = ttJE.tdPostingHistMovemntDebitCC + PostingHist.PostingHistMovemntDebitCC.
end. /* end for each PostingHist */
/*************************************************************************************/
/* A.3 See if there any differences and report it */
/*************************************************************************************/
for each ttJE where
ttJE.tdTotalPostingLineCreditTC <> ttJE.tdPostingHistMovemntCreditTC or
ttJE.tdTotalPostingLineCreditLC <> ttJE.tdPostingHistMovemntCreditLC or
ttJE.tdTotalPostingLineCreditCC <> ttJE.tdPostingHistMovemntCreditCC or
ttJE.tdTotalPostingLineDebitTC <> ttJE.tdPostingHistMovemntDebitTC or
ttJE.tdTotalPostingLineDebitLC <> ttJE.tdPostingHistMovemntDebitLC or
ttJE.tdTotalPostingLineDebitCC <> ttJE.tdPostingHistMovemntDebitCC :
/* Create indication rebuild is needed */
FIND ttRebuild WHERE
ttRebuild.tcCompanyCode = ttJE.tcCompanyCode AND
ttRebuild.tcGLCode = ttJE.tcGLCode
NO-ERROR.
IF NOT AVAILABLE ttRebuild
THEN DO:
CREATE ttREbuild.
ASSIGN ttRebuild.tcCompanyCode = ttJE.tcCompanyCode
ttRebuild.tcGLCode = ttJE.tcGLCode
ttRebuild.tiPeriodYearPeriod = ttJE.tiPostingHistYearPeriodFrom.
END.
assign oiErrorNumbers = oiErrorNumbers + 1.
put stream sTechOut unformatted
'ERROR MOVEMENT '
ttJE.tcTYPE ' * '
ttJE.tcCompanyCode ' * '
ttJE.tcGLCode format 'x(10)' ' * '
ttJE.tiPostingHistYearPeriodFrom ' * '
'JN:' ttJE.tiJournal_ID format '9999999999' ' '
'LY:' ttJE.tiLayer_ID format '9999999999' ' '
'CU:' ttJE.tiCurrency_ID format '9999999999' ' '
'PR:' ttJE.tiProject_ID format '9999999999' ' '
'CC:' ttJE.tiCostCentre_ID format '9999999999' ' '
'DI:' ttJE.tiDivision_ID format '9999999999' ' '
'IC:' ttJE.tiIntercoBusinessRelation_ID format '9999999999' ' '
'SA:' ttJE.tiPostingSafCombined_ID format '9999999999' ' '
ttJE.tdTotalPostingLineDebitTC <> ttJE.tdPostingHistMovemntDebitTC format 'yes/no' ' '
ttJE.tdTotalPostingLineDebitLC <> ttJE.tdPostingHistMovemntDebitLC format 'yes/no' ' '
ttJE.tdTotalPostingLineDebitCC <> ttJE.tdPostingHistMovemntDebitCC format 'yes/no' ' * '
ttJE.tdTotalPostingLineCreditTC <> ttJE.tdPostingHistMovemntCreditTC format 'yes/no' ' '
ttJE.tdTotalPostingLineCreditLC <> ttJE.tdPostingHistMovemntCreditLC format 'yes/no' ' '
ttJE.tdTotalPostingLineCreditCC <> ttJE.tdPostingHistMovemntCreditCC format 'yes/no' ' '
ttJE.tdTotalPostingLineDebitTC ' ' ttJE.tdPostingHistMovemntDebitTC ' * '
ttJE.tdTotalPostingLineDebitLC ' ' ttJE.tdPostingHistMovemntDebitLC ' * '
ttJE.tdTotalPostingLineDebitCC ' ' ttJE.tdPostingHistMovemntDebitCC ' * '
ttJE.tdTotalPostingLineCreditTC ' ' ttJE.tdPostingHistMovemntCreditTC ' * '
ttJE.tdTotalPostingLineCreditLC ' ' ttJE.tdPostingHistMovemntCreditLC ' * '
ttJE.tdTotalPostingLineCreditCC ' ' ttJE.tdPostingHistMovemntCreditCC ' * '
skip.
end. /* A.3 for each ttJE*/
/* ****************************************************************************/
/* B: check on the balance fields of the current period */
/* *************************************************************************** */
IF NOT CAN-FIND (FIRST ttRebuild WHERE
ttRebuild.tcCompanyCode = Company.CompanyCode AND
ttRebuild.tcGLCode = GL.GLCode)
THEN Do:
foreach_block:
for each PostingHist OF Company no-lock where
PostingHist.GL_ID = GL.gl_ID and
PostingHist.PostingHistYearPeriodFrom >= iiYearPeriod
break by PostingHist.Company_ID
by PostingHist.Journal_ID
by PostingHist.Layer_ID
by PostingHist.GL_ID
by PostingHist.Division_ID
by PostingHist.CostCentre_ID
by PostingHist.Project_ID
by PostingHist.Currency_ID
by PostingHist.IntercoBusinessRelation_ID
by PostingHist.PostingSafCombined_ID
by PostingHist.PostingHistYearPeriodFrom:
assign viPostingHisT = viPostingHisT + 1.
/* ======================================================== */
/* Initialize when a new combination is started */
/* ======================================================== */
if first-of (PostingHist.PostingSafCombined_ID)
then do:
assign vcNewCombination = ">"
vlSkipCombination = NO.
if iiYearPeriod <> 0
then do:
find last bPostingHist WHERE
bPostingHist.Company_ID = PostingHist.Company_ID and
bPostingHist.GL_ID = PostingHist.GL_ID and
bPostingHist.Journal_ID = PostingHist.Journal_ID and
bPostingHist.Layer_ID = PostingHist.Layer_ID and
bPostingHist.Currency_ID = PostingHist.Currency_ID and
bPostingHist.Division_ID = PostingHist.Division_ID and
bPostingHist.Project_ID = PostingHist.Project_ID and
bPostingHist.CostCentre_ID = PostingHist.CostCentre_ID and
bPostingHist.IntercoBusinessRelation_ID = PostingHist.IntercoBusinessRelation_ID and
bPostingHist.PostingSafCombined_ID = PostingHist.PostingSafCombined_ID and
bPostingHist.PostingHistYearPeriodFrom < PostingHist.PostingHistYearPeriodFrom
no-lock no-error.
end.
/* Get the Balance and YTD amounts fro the previous period */
if iiYearPeriod = 0 or not available bPostingHist
then assign vdPostingHistBalanceDebitCC = 0
vdPostingHistBalanceDebitLC = 0
vdPostingHistBalanceDebitTC = 0
vdPostingHistBalanceCreditCC = 0
vdPostingHistBalanceCreditLC = 0
vdPostingHistBalanceCreditTC = 0
vdPostingHistYTDDebitCC = 0
vdPostingHistYTDDebitLC = 0
vdPostingHistYTDDebitTC = 0
vdPostingHistYTDCreditCC = 0
vdPostingHistYTDCreditLC = 0
vdPostingHistYTDCreditTC = 0
vdPostingHistYearPeriodFromPREV = 0
vdPostingHistYearPeriodTillPREV = 0
vdPostingHistYearFromPREV = 0.
else assign vdPostingHistBalanceDebitCC = bPostingHist.PostingHistBalanceDebitCC
vdPostingHistBalanceDebitLC = bPostingHist.PostingHistBalanceDebitLC
vdPostingHistBalanceDebitTC = bPostingHist.PostingHistBalanceDebitTC
vdPostingHistBalanceCreditCC = bPostingHist.PostingHistBalanceCreditCC
vdPostingHistBalanceCreditLC = bPostingHist.PostingHistBalanceCreditLC
vdPostingHistBalanceCreditTC = bPostingHist.PostingHistBalanceCreditTC
vdPostingHistYTDDebitCC = bPostingHist.PostingHistYTDDebitCC
vdPostingHistYTDDebitLC = bPostingHist.PostingHistYTDDebitLC
vdPostingHistYTDDebitTC = bPostingHist.PostingHistYTDDebitTC
vdPostingHistYTDCreditCC = bPostingHist.PostingHistYTDCreditCC
vdPostingHistYTDCreditLC = bPostingHist.PostingHistYTDCreditLC
vdPostingHistYTDCreditTC = bPostingHist.PostingHistYTDCreditTC
vdPostingHistYearPeriodFromPREV = bPostingHist.PostingHistYearPeriodFrom
vdPostingHistYearPeriodTillPREV = bPostingHist.PostingHistYearPeriodTill
vdPostingHistYearFromPREV = trunc(bPostingHist.PostingHistYearPeriodFrom / 100, 0).
end. /* first-of */
IF vlSkipCombination
THEN NEXT.
if trunc (PostingHist.PostingHistYearPeriodFrom / 100,0) <> vdPostingHistYearFromPREV
then assign vdPostingHistYTDDebitTC = 0
vdPostingHistYTDDebitLC = 0
vdPostingHistYTDdebitCC = 0
vdPostingHistYTDCreditTC = 0
vdPostingHistYTDCreditLC = 0
vdPostingHistYTDCreditCC = 0.
/* ======================================================== */
/* Recalculate the Balances */
/* ======================================================== */
assign vdPostingHistBalanceDebitTC = vdPostingHistBalanceDebitTC + PostingHist.PostingHistmovemntDebitTC
vdPostingHistBalanceDebitLC = vdPostingHistBalanceDebitLC + PostingHist.PostingHistmovemntDebitLC
vdPostingHistBalanceDebitCC = vdPostingHistBalanceDebitCC + PostingHist.PostingHistmovemntDebitCC
vdPostingHistBalanceCreditTC = vdPostingHistBalanceCreditTC + PostingHist.PostingHistmovemntCreditTC
vdPostingHistBalanceCreditLC = vdPostingHistBalanceCreditLC + PostingHist.PostingHistmovemntCreditLC
vdPostingHistBalanceCreditCC = vdPostingHistBalanceCreditCC + PostingHist.PostingHistmovemntCreditCC.
assign vdPostingHistYTDDebitTC = vdPostingHistYTDDebitTC + PostingHist.PostingHistmovemntDebitTC
vdPostingHistYTDDebitLC = vdPostingHistYTDDebitLC + PostingHist.PostingHistmovemntDebitLC
vdPostingHistYTDDebitCC = vdPostingHistYTDDebitCC + PostingHist.PostingHistmovemntDebitCC
vdPostingHistYTDCreditTC = vdPostingHistYTDCreditTC + PostingHist.PostingHistmovemntCreditTC
vdPostingHistYTDCreditLC = vdPostingHistYTDCreditLC + PostingHist.PostingHistmovemntCreditLC
vdPostingHistYTDCreditCC = vdPostingHistYTDCreditCC + PostingHist.PostingHistmovemntCreditCC.
/* ======================================================== */
/* Check if the Balance is OK */
/* ======================================================== */
ASSIGN vlBalanceIncorrect = vdPostingHistBalanceDebitTC <> PostingHist.PostingHistBalanceDebitTC or
vdPostingHistBalanceDebitLC <> PostingHist.PostingHistBalanceDebitLC or
vdPostingHistBalanceDebitCC <> PostingHist.PostingHistBalanceDebitCC or
vdPostingHistBalanceCreditTC <> PostingHist.PostingHistBalanceCreditTC or
vdPostingHistBalanceCreditLC <> PostingHist.PostingHistBalanceCreditLC or
vdPostingHistBalanceCreditCC <> PostingHist.PostingHistBalanceCreditCC
vlYTDIncorrect = vdPostingHistYTDDebitTC <> PostingHist.PostingHistYTDDebitTC or
vdPostingHistYTDDebitLC <> PostingHist.PostingHistYTDDebitLC or
vdPostingHistYTDDebitCC <> PostingHist.PostingHistYTDDebitCC or
vdPostingHistYTDCreditTC <> PostingHist.PostingHistYTDCreditTC or
vdPostingHistYTDCreditLC <> PostingHist.PostingHistYTDCreditLC or
vdPostingHistYTDCreditCC <> PostingHist.PostingHistYTDCreditCC.
if vlBalanceIncorrect OR vlYTDIncorrect
then do :
find journal of PostingHist no-lock no-error.
FIND ttRebuild WHERE
ttRebuild.tcCompanyCode = Company.CompanyCode AND
ttRebuild.tcGLCode = GL.GLCode
no-lock NO-ERROR.
IF NOT AVAILABLE ttRebuild
THEN DO:
CREATE ttREbuild.
ASSIGN ttRebuild.tcCompanyCode = Company.CompanyCode
ttRebuild.tcGLCode = GL.GLCode
ttRebuild.tiPeriodYearPeriod = vdPostingHistYearPeriodFromPREV.
END.
ASSIGN vlSkipCombination = YES.
assign oiErrorNumbers = oiErrorNumbers + 1.
put stream sTechOut unformatted
'ERROR '
'BALANCE '
vcNewCombination format 'x' ' '
companycode ' * '
GL.GLCode format 'x(10)' ' * '
PostingHist.PostingHistYearPeriodFrom ' * '
PostingHist.PostingHistYearPeriodTill ' * '
' JN:' PostingHist.Journal_ID format '9999999999'
' LA:' PostingHist.Layer_ID format '9999999999'
' DI:' PostingHist.Division_ID format '9999999999'
' CC:' PostingHist.CostCentre_ID format '9999999999'
' PR:' PostingHist.Project_ID format '9999999999'
' CU:' PostingHist.Currency_ID format '9999999999'
' IC:' PostingHist.IntercoBusinessRelation_ID format '9999999999'
' SA:' PostingHist.PostingSafCombined_ID format '9999999999' ' '
'Error in Balance fields '
vlBalanceIncorrect ' ' vlYTDIncorrect ' '
skip.
if vcNewCombination <> '' then assign vcNewCombination = ''.
end. /* if vlBalanceIncorrect OR vlYTDIncorrect */
/* ======================================================== */
/* Check if the Period has no holes */
/* ======================================================== */
if vdPostingHistYearPeriodTillPREV <> 0 and PostingHist.PostingHistYearPeriodFrom <> vdPostingHistYearPeriodTillPREV + 1
then do :
find journal of PostingHist no-lock no-error.
FIND ttRebuild WHERE
ttRebuild.tcCompanyCode = Company.CompanyCode AND
ttRebuild.tcGLCode = GL.GLCode
no-lock NO-ERROR.
IF NOT AVAILABLE ttRebuild
THEN DO:
CREATE ttREbuild.
ASSIGN ttRebuild.tcCompanyCode = Company.CompanyCode
ttRebuild.tcGLCode = GL.GLCode
ttRebuild.tiPeriodYearPeriod = vdPostingHistYearPeriodFromPREV.
END.
ASSIGN vlSkipCombination = YES.
assign oiErrorNumbers = oiErrorNumbers + 1.
put stream sTechOut unformatted
'ERROR '
'PERIOD '
vcNewCombination format 'x' ' '
companycode ' * '
GL.GLCode format 'x(10)' ' * '
PostingHist.PostingHistYearPeriodFrom ' * '
PostingHist.PostingHistYearPeriodTill ' * '
' JN:' PostingHist.Journal_ID format '9999999999'
' LA:' PostingHist.Layer_ID format '9999999999'
' DI:' PostingHist.Division_ID format '9999999999'
' CC:' PostingHist.CostCentre_ID format '9999999999'
' PR:' PostingHist.Project_ID format '9999999999'
' CU:' PostingHist.Currency_ID format '9999999999'
' IC:' PostingHist.IntercoBusinessRelation_ID format '9999999999'
' SA:' PostingHist.PostingSafCombined_ID format '9999999999' ' '
'Error: Period not in sequence.' ' ' vdPostingHistYearPeriodTillPREV
skip.
if vcNewCombination <> ''
then assign vcNewCombination = ''.
end.
/* ======================================================== */
/* Check if the Last records has 999999 as till period */
/* ======================================================== */
if last-of (PostingHist.PostingSafCombined_ID) and
PostingHist.PostingHistYearPeriodTill <> 999999
then do :
FIND ttRebuild WHERE
ttRebuild.tcCompanyCode = Company.CompanyCode AND
ttRebuild.tcGLCode = GL.GLCode
NO-LOCK NO-ERROR.
IF NOT AVAILABLE ttRebuild
THEN DO:
CREATE ttRebuild.
ASSIGN ttRebuild.tcCompanyCode = Company.CompanyCode
ttRebuild.tcGLCode = GL.GLCode
ttRebuild.tiPeriodYearPeriod = vdPostingHistYearPeriodFromPREV.
END.
ASSIGN vlSkipCombination = YES.
/* Move the 999999 check to top of this mehtod
put stream sTechOut unformatted
'ERROR '
'END-RECORD '
vcNewCombination format 'x' ' '
companycode ' * '
GL.GLCode format 'x(10)' ' * '
PostingHist.PostingHistYearPeriodFrom ' * '
PostingHist.PostingHistYearPeriodTill ' * '
' JN:' PostingHist.Journal_ID format '9999999999'
' LA:' PostingHist.Layer_ID format '9999999999'
' DI:' PostingHist.Division_ID format '9999999999'
' CC:' PostingHist.CostCentre_ID format '9999999999'
' PR:' PostingHist.Project_ID format '9999999999'
' CU:' PostingHist.Currency_ID format '9999999999'
' IC:' PostingHist.IntercoBusinessRelation_ID format '9999999999'
' SA:' PostingHist.PostingSafCombined_ID format '9999999999' ' '
'Error: 999999 record is missing.'
skip. */
if vcNewCombination <> '' then assign vcNewCombination = ''.
end.
assign vdPostingHistYearPeriodFromPREV = PostingHist.PostingHistYearPeriodFrom
vdPostingHistYearPeriodTillPREV = PostingHist.PostingHistYearPeriodTill
vdPostingHistYearFromPREV = trunc(vdPostingHistYearPeriodFromPREV / 100, 0).
end. /* for each PostingHist */
end. /* NOT CAN FIND ttRebuild */
end. /* for each company */
end. /* Movement_Balance:do: */
PUT STREAM sTechOut unformatted vcPrefix2 + "END Validation of movements, balances of the current period." skip.
/**********************************************************************************/
/* IPR_GL_Check_Year_Balances */
/**********************************************************************************/
PUT STREAM sTechOut unformatted " " skip.
PUT STREAM sTechOut unformatted vcPrefix2 + "Start Validation of GL Balances by Year" skip.
IPR_GL_Check_Year_Balances:
do:
for each Company no-lock where company.company_id = iiCompanyID:
for each Period of Company no-lock
where Period.PeriodYear >= viPeriodYear
break by Period.PeriodYear:
if first-of(Period.PeriodYear)
then do:
assign vdTotalLC = 0
vdTotalCC = 0.
end.
for each PostingHist of Company where
PostingHist.PostingHistYearPeriodFrom = Period.PeriodYearPeriod
NO-LOCK:
assign vdTotalLC = vdTotalLC + PostingHist.postinghistmovemntDebitLC - PostingHist.postinghistmovemntCreditLC
vdTotalCC = vdTotalCC + PostingHist.postinghistmovemntDebitCC - PostingHist.postinghistmovemntCreditCC.
end.
if last-of(Period.PeriodYear)
then do:
if vdTotalLC <> 0
then do:
PUT STREAM sTechOut unformatted vcPrefix + "Company; " + CompanyCode + " PeriodYear: " + string(Period.PeriodYear) + " TotalLC: " + string(vdTotalLC, "->,>>>,>>>,>>9.99") skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
if vdTotalCC <> 0
then do:
PUT STREAM sTechOut unformatted vcPrefix + "Company; " + CompanyCode + " PeriodYear: " + string(Period.PeriodYear) + " TotalCC: " + string(vdTotalCC, "->,>>>,>>>,>>9.99") skip.
assign oiErrorNumbers = oiErrorNumbers + 1.
end.
end.
end. /* for each Period */
end. /* for each Company */
end. /* IPR_GL_Check_Year_Balances */
PUT STREAM sTechOut unformatted vcPrefix2 + "END Validation of GL Balances by Year" skip.
end. /* Main_Block */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.