Description
Validations before the ancestor code (Target Codes need to be validated manually, because they might use a different domain then the current one)
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bcoacrossref.p)
assign oiReturnStatus = -98
viLocalReturnStatus = 0.
/* ============= */
/* Start Queries */
/* ============= */
<Q-24 run GLByCode (Start) in BGL>
<Q-25 run DivisionPrim (Start) in BDivision >
<Q-26 run CostCentrePrim (Start) in BCostCentre >
<Q-23 run ProjectPrim (Start) in BProject >
/* ======================================= */
/* Manually fill read-only RKBFs (Targets) */
/* ======================================= */
for each t_sCOACrossRef where
t_sCOACrossRef.tc_Status <> "D":U:
if t_sCOACrossRef.tc_Status = "C":U
then do:
find t_iCOACrossRef where
t_iCOACrossRef.tc_Rowid = t_sCOACrossRef.tc_Rowid
no-error.
if not available t_iCOACrossRef
then next.
end. /* if t_sCOACrossRef.tc_Status = "C":U */
/* =========================================== */
/* Retrieve the default company for the domain */
/* =========================================== */
<Q-1 run CompanyByCompanyCodeDomainCode (all) (Read) (NoCache)
(input 0, (CompanyId)
input '':U, (CompanyCode)
input t_sCOACrossRef.tcTargetDomainCode, (DomainCode)
input 0, (DomainId)
input ?, (CompanyIsActive)
output dataset tqCompanyByCompanyCodeDomainCode) in BCompany>
find first tqCompanyByCompanyCodeDomainCode where
tqCompanyByCompanyCodeDomainCode.tcDomainCode = t_sCOACrossRef.tcTargetDomainCode
no-error.
if not available tqCompanyByCompanyCodeDomainCode
then next. /* error will be caught by ancestor code */
/* =================== */
/* AltCOAStruct Code */
/* =================== */
if (t_sCOACrossRef.tc_Status = "N":U or
t_sCOACrossRef.tc_Status = "C":U) and
(t_sCOACrossRef.tcAltCOAStructCode = ? or
t_sCOACrossRef.tcAltCOAStructCode = '':U)
then assign t_sCOACrossRef.AltCOAStruct_ID = ?.
if (t_sCOACrossRef.tcAltCOAStructCode <> ? and
t_sCOACrossRef.tcAltCOAStructCode <> '':U) and
(t_sCOACrossRef.tc_Status = "N":U or
(t_sCOACrossRef.tc_Status = "C":U and
(t_sCOACrossRef.tcAltCOAStructCode <> t_iCOACrossRef.tcAltCOAStructCode or
t_sCOACrossRef.AltCOAStruct_ID = 0 or
t_sCOACrossRef.AltCOAStruct_ID = ?)))
then do:
<Q-45 run AltCOAStructPrim (all) (Read) (NoCache)
(input ?, (AltCOAStructId)
input t_sCOACrossRef.tcAltCOAStructCode, (AltCOAStructCode)
output dataset tqAltCOAStructPrim) in BAltCOAStruct >
find first tqAltCOAStructPrim where
tqAltCOAStructPrim.tcAltCOAStructCode = t_sCOACrossRef.tcAltCOAStructCode
no-error.
if not available tqAltCOAStructPrim
then do:
assign vcMessage = trim(substitute(#T-47'Could not find target Alternate COA Struct Code (&1).':255(999890242)T-47#, trim(t_sCOACrossRef.tcAltCOAStructCode) )) + chr(10) +
trim(substitute(#T-48'Cross Reference Code: &1.':255(999890142)T-48#, trim(t_sCOACrossRef.COACrossRefCode) ))
viLocalReturnStatus = -1.
<M-46 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCOACrossRef.tcAltCOAStructCode':U (icFieldName),
input t_sCOACrossRef.tcAltCOAStructCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCOACrossRef.tc_Rowid (icRowid),
input 'QadFin-9131':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
end. /* if not available tqProjectPrim */
else assign t_sCOACrossRef.AltCOAStruct_ID = tqAltCOAStructPrim.tiAltCOAStruct_ID.
end.
for each t_sCOACrossRefDet where
t_sCOACrossRefDet.tc_ParentRowid = t_sCOACrossRef.tc_Rowid and
t_sCOACrossRefDet.tc_Status <> "D":U:
if t_sCOACrossRefDet.tc_Status = "C":U
then do:
find t_iCOACrossRefDet where
t_iCOACrossRefDet.tc_Rowid = t_sCOACrossRefDet.tc_Rowid
no-error.
if not available t_iCOACrossRefDet
then next.
end. /* if t_sCOACrossRefDet.tc_Status = "C":U */
/* ========================================= */
/* Clear ID fields when codes are not filled */
/* ========================================= */
if (t_sCOACrossRefDet.tc_Status = "N":U or
t_sCOACrossRefDet.tc_Status = "C":U)
then do:
if t_sCOACrossRefDet.tcTargetGLCode = ? or
t_sCOACrossRefDet.tcTargetGLCode = '':U
then assign t_sCOACrossRefDet.TargetGL_ID = ?.
if t_sCOACrossRefDet.tcTargetDivisionCode = ? or
t_sCOACrossRefDet.tcTargetDivisionCode = '':U
then assign t_sCOACrossRefDet.TargetDivision_ID = ?.
if t_sCOACrossRefDet.tcTargetCostCentreCode = ? or
t_sCOACrossRefDet.tcTargetCostCentreCode = '':U
then assign t_sCOACrossRefDet.TargetCostCentre_ID = ?.
if t_sCOACrossRefDet.tcTargetProjectCode = ? or
t_sCOACrossRefDet.tcTargetProjectCode = '':U
then assign t_sCOACrossRefDet.TargetProject_ID = ?.
if t_sCOACrossRefDet.tcTargetAltCOAStructDetCode = ? or
t_sCOACrossRefDet.tcTargetAltCOAStructDetCode = '':U
then assign t_sCOACrossRefDet.TargetAltCOAStructDet_ID = ?.
end. /* if (t_sCOACrossRefDet.tc_Status = "N":U or */
/* ============== */
/* Target GL Code */
/* ============== */
if (t_sCOACrossRefDet.tcTargetGLCode <> ? and
t_sCOACrossRefDet.tcTargetGLCode <> '':U) and
(t_sCOACrossRefDet.tc_Status = "N":U or
(t_sCOACrossRefDet.tc_Status = "C":U and
(t_sCOACrossRefDet.tcTargetGLCode <> t_iCOACrossRefDet.tcTargetGLCode or
t_sCOACrossRefDet.TargetGL_ID = 0 or
t_sCOACrossRefDet.TargetGL_ID = ?)))
then do:
<Q-2 run GLByCode (all) (Read) (NoCache)
(input tqCompanyByCompanyCodeDomainCode.tiCompany_ID, (CompanyId)
input t_sCOACrossRefDet.tcTargetGLCode, (GLCode)
output dataset tqGLByCode) in BGL>
find first tqGLByCode no-error.
if not available tqGLByCode
then do:
assign vcMessage = trim(substitute(#T-4'Could not find target GL Account (&1).':255(71493)T-4#, trim(t_sCOACrossRefDet.tcTargetGLCode) )) + chr(10) +
trim(substitute(#T-31'Cross Reference Code: &1.':255(999890142)T-31#, trim(t_sCOACrossRef.COACrossRefCode) ))
viLocalReturnStatus = -1.
<M-3 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCOACrossRefDet.tcTargetGLCode':U (icFieldName),
input t_sCOACrossRefDet.tcTargetGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCOACrossRefDet.tc_Rowid (icRowid),
input 'QadFin-8730':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
end. /* if not available tqGLByCode */
else if tqGLByCode.tcGLSystemTypeCode = {&GLSYSTEMTYPE-RESULTCURRENTYEAR} or tqGLByCode.tcGLSystemTypeCode = {&GLSYSTEMTYPE-RESULTPREVIOUSYEAR}
then do:
assign vcMessage = trim(substitute(#T-92'You cannot use a GL Account of system type &1 or &2 as the target GL Account.':200(561598466)T-92#,
{&GLSYSTEMTYPE-RESULTCURRENTYEAR-TR},{&GLSYSTEMTYPE-RESULTPREVIOUSYEAR-TR}))
viLocalReturnStatus = -1.
<M-18 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCOACrossRefDet.tcTargetGLCode':U (icFieldName),
input t_sCOACrossRefDet.tcTargetGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCOACrossRefDet.tc_Rowid (icRowid),
input 'qadfin-487837':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
end.
else do:
<Q-88 run FRWChartByCTACode (all) (Read) (NoCache)
(input t_sCOACrossRefDet.tcTargetGLCode, (CTACode)
output dataset tqFRWChartByCTACode) in BFRWChart>
find first tqFRWChartByCTACode no-error.
if available tqFRWChartByCTACode
then do:
assign vcMessage = trim(substitute(#T-94'CTA Account in chart &1 cannot be used as the target GL Account.':200(700359055)T-94#, tqFRWChartByCTACode.tcFRWChartCode))
viLocalReturnStatus = -1.
<M-73 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCOACrossRefDet.tcTargetGLCode':U (icFieldName),
input t_sCOACrossRefDet.tcTargetGLCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCOACrossRefDet.tc_Rowid (icRowid),
input 'qadfin-380946':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
end.
else assign t_sCOACrossRefDet.TargetGL_ID = tqGLByCode.tiGL_ID.
end.
end. /* if t_sCOACrossRefDet.tcTargetGLCode <> ? and */
/* ==================== */
/* Target Division Code */
/* ==================== */
if (t_sCOACrossRefDet.tcTargetDivisionCode <> ? and
t_sCOACrossRefDet.tcTargetDivisionCode <> '':U) and (t_sCOACrossRefDet.tc_Status = "N":U or
(t_sCOACrossRefDet.tc_Status = "C":U and
(t_sCOACrossRefDet.tcTargetDivisionCode <> t_iCOACrossRefDet.tcTargetDivisionCode or
t_sCOACrossRefDet.TargetDivision_ID = 0 or
t_sCOACrossRefDet.TargetDivision_ID = ?)))
then do:
<Q-20 run DivisionPrim (all) (Read) (NoCache)
(input tqCompanyByCompanyCodeDomainCode.tiCompany_ID, (CompanyId)
input 0, (DivisionID)
input t_sCOACrossRefDet.tcTargetDivisionCode, (DivisionCode)
output dataset tqDivisionPrim) in BDivision >
find tqDivisionPrim where
tqDivisionPrim.tcDivisionCode = t_sCOACrossRefDet.tcTargetDivisionCode
no-error.
if not available tqDivisionPrim
then do:
assign vcMessage = trim(substitute(#T-7'Could not find target Sub-Account (&1).':255(71494)T-7#, trim(t_sCOACrossRefDet.tcTargetDivisionCode) )) + chr(10) +
trim(substitute(#T-32'Cross Reference Code: &1.':255(999890142)T-32#, trim(t_sCOACrossRef.COACrossRefCode) ))
viLocalReturnStatus = -1.
<M-6 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCOACrossRefDet.tcTargetDivisionCode':U (icFieldName),
input t_sCOACrossRefDet.tcTargetDivisionCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCOACrossRefDet.tc_Rowid (icRowid),
input 'QadFin-8731':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
end. /* if not available tqDivisionPrim */
else assign t_sCOACrossRefDet.TargetDivision_ID = tqDivisionPrim.tiDivision_ID.
end. /* if t_sCOACrossRefDet.tcTargetDivisionCode <> ? and */
/* ====================== */
/* Target CostCentre Code */
/* ====================== */
if (t_sCOACrossRefDet.tcTargetCostCentreCode <> ? and
t_sCOACrossRefDet.tcTargetCostCentreCode <> '':U) and
(t_sCOACrossRefDet.tc_Status = "N":U or
(t_sCOACrossRefDet.tc_Status = "C":U and
(t_sCOACrossRefDet.tcTargetCostCentreCode <> t_iCOACrossRefDet.tcTargetCostCentreCode or
t_sCOACrossRefDet.TargetCostCentre_ID = 0 or
t_sCOACrossRefDet.TargetCostCentre_ID = ?)))
then do:
<Q-21 run CostCentrePrim (all) (Read) (NoCache)
(input tqCompanyByCompanyCodeDomainCode.tiCompany_ID, (CompanyId)
input 0, (CostCentreID)
input t_sCOACrossRefDet.tcTargetCostCentreCode, (CostCentreCode)
output dataset tqCostCentrePrim) in BCostCentre >
find tqCostCentrePrim where
tqCostCentrePrim.tcCostCentreCode = t_sCOACrossRefDet.tcTargetCostCentreCode
no-error.
if not available tqCostCentrePrim
then do:
assign vcMessage = trim(substitute(#T-10'Could not find target Cost Center (&1).':255(71495)T-10#, trim(t_sCOACrossRefDet.tcTargetCostCentreCode) )) + chr(10) +
trim(substitute(#T-33'Cross Reference Code: &1.':255(999890142)T-33#, trim(t_sCOACrossRef.COACrossRefCode) ))
viLocalReturnStatus = -1.
<M-9 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCOACrossRefDet.tcTargetCostCentreCode':U (icFieldName),
input t_sCOACrossRefDet.tcTargetCostCentreCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCOACrossRefDet.tc_Rowid (icRowid),
input 'QadFin-8732':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
end. /* if not available tqCostCentrePrim */
else assign t_sCOACrossRefDet.TargetCostCentre_ID = tqCostCentrePrim.tiCostCentre_ID.
end. /* if t_sCOACrossRefDet.tcTargetCostCentreCode <> ? and */
/* =================== */
/* Target Project Code */
/* =================== */
if (t_sCOACrossRefDet.tcTargetProjectCode <> ? and
t_sCOACrossRefDet.tcTargetProjectCode <> '':U) and
(t_sCOACrossRefDet.tc_Status = "N":U or
(t_sCOACrossRefDet.tc_Status = "C":U and
(t_sCOACrossRefDet.tcTargetProjectCode <> t_iCOACrossRefDet.tcTargetProjectCode or
t_sCOACrossRefDet.TargetProject_ID = 0 or
t_sCOACrossRefDet.TargetProject_ID = ?)))
then do:
<Q-22 run ProjectPrim (all) (Read) (NoCache)
(input tqCompanyByCompanyCodeDomainCode.tiCompany_ID, (CompanyId)
input 0, (ProjectID)
input t_sCOACrossRefDet.tcTargetProjectCode, (ProjectCode)
output dataset tqProjectPrim) in BProject >
find tqProjectPrim where
tqProjectPrim.tcProjectCode = t_sCOACrossRefDet.tcTargetProjectCode
no-error.
if not available tqProjectPrim
then do:
assign vcMessage = trim(substitute(#T-13'Could not find target Project (&1).':255(71496)T-13#, trim(t_sCOACrossRefDet.tcTargetProjectCode) )) + chr(10) +
trim(substitute(#T-34'Cross Reference Code: &1.':255(999890142)T-34#, trim(t_sCOACrossRef.COACrossRefCode) ))
viLocalReturnStatus = -1.
<M-12 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCOACrossRefDet.tcTargetProjectCode':U (icFieldName),
input t_sCOACrossRefDet.tcTargetProjectCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCOACrossRefDet.tc_Rowid (icRowid),
input 'QadFin-8733':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
end. /* if not available tqProjectPrim */
else assign t_sCOACrossRefDet.TargetProject_ID = tqProjectPrim.tiProject_ID.
end. /* if t_sCOACrossRefDet.tcTargetProjectCode <> ? and */
/* =================== */
/* Target Alternate COA Detail Code */
/* =================== */
if (t_sCOACrossRefDet.tcTargetAltCOAStructDetCode <> ? and
t_sCOACrossRefDet.tcTargetAltCOAStructDetCode <> '':U) and
(t_sCOACrossRefDet.tc_Status = "N":U or
(t_sCOACrossRefDet.tc_Status = "C":U and
(t_sCOACrossRefDet.tcTargetAltCOAStructDetCode <> t_iCOACrossRefDet.tcTargetAltCOAStructDetCode or
t_sCOACrossRefDet.TargetAltCOAStructDet_ID = 0 or
t_sCOACrossRefDet.TargetAltCOAStructDet_ID = ?)))
then do:
<Q-44 run AltCOAStructDetPrim (all) (Read) (NoCache)
(input ?, (AltCOAStructDetId)
input t_sCOACrossRefDet.tcTargetAltCOAStructDetCode, (AltCOAStructDetCode)
input t_sCOACrossRef.tcAltCOAStructCode, (AltCOAStructCode)
output dataset tqAltCOAStructDetPrim) in BAltCOAStruct >
find first tqAltCOAStructDetPrim where
tqAltCOAStructDetPrim.tcAltCOAStructDetCode = t_sCOACrossRefDet.tcTargetAltCOAStructDetCode
no-error.
if not available tqAltCOAStructDetPrim
then do:
assign vcMessage = trim(substitute(#T-42'Could not find target alternate COA struct Code (&1).':255(999890243)T-42#, trim(t_sCOACrossRefDet.tcTargetAltCOAStructDetCode) )) + chr(10) +
trim(substitute(#T-43'Cross Reference Code: &1.':255(999890142)T-43#, trim(t_sCOACrossRef.COACrossRefCode) ))
viLocalReturnStatus = -1.
<M-41 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input 'tCOACrossRefDet.tcTargetAltCOAStructDetCode':U (icFieldName),
input t_sCOACrossRefDet.tcTargetAltCOAStructDetCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sCOACrossRefDet.tc_Rowid (icRowid),
input 'QadFin-8973':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BCOACrossRef>
end. /* if not available tqProjectPrim */
else do:
assign t_sCOACrossRefDet.TargetAltCOAStructDet_ID = tqAltCOAStructDetPrim.tiAltCOAStructDet_ID.
end.
end. /* if t_sCOACrossRefDet.tcTargetProjectCode <> ? and */
end. /* for each t_sCOACrossRefDet where */
end. /* for each t_sCOACrossRef where */
/* ============= */
/* Stop Queries */
/* ============= */
<Q-27 run GLByCode (Stop) in BGL>
<Q-28 run DivisionPrim (Stop) in BDivision >
<Q-29 run CostCentrePrim (Stop) in BCostCentre >
<Q-30 run ProjectPrim (Stop) in BProject >
assign oiReturnStatus = viLocalReturnStatus.