project QadFinancials > class BFRWChart > method ValidateComponentAllCOACrossRef
Description
Validation for COA Cross Reference
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bfrwchart.p)
/* ====================================================================================== *
* Method : ValidateComponentAllCOACrossRef *
* Description : This method validates COA Cross Ref *
* ====================================================================================== */
/*************************************/
/* Validations on coa cross ref */
/*************************************/
empty temp-table tCOACrossRefForSave.
MAIN_BLOCK:
do on error undo, throw:
for each tChartCOACrossRef:
assign viCOACrossRefID = tChartCOACrossRef.tiCOACrossRefId.
if tChartCOACrossRef.tcSharedSetType <> {&COACROSSREFTYPE-COMBINED}
then do:
if tChartCOACrossRef.tiTargetSharedSetId <> 0
then do:
if trim(tChartCOACrossRef.tcCOACrossRefCode) = "":U or tChartCOACrossRef.tcCOACrossRefCode = ?
then do:
assign vcMessage = trim(#T-92'COA Cross Reference is mandatory.':100(981471749)T-92#)
oiReturnStatus = -1.
<M-43 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-945351':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end. /* if trim(tChartCOACrossRef.tcCOACrossRefCode) = "":U or tChartCOACrossRef.tcCOACrossRefCode = ? */
end. /* if tChartCOACrossRef.tiTargetSharedSetId <> 0 */
else assign tChartCOACrossRef.tcCOACrossRefCode = "":U.
if tChartCOACrossRef.tcCOACrossRefCode <> ? and trim(tChartCOACrossRef.tcCOACrossRefCode) <> "":U and tChartCOACrossRef.tcCOACrossRefCode <> {&COACROSSREFCODE-NOTNEEDED}
then do:
<Q-3 run COACrossRefByAll (all) (Read) (NoCache)
(input ?, (COACrossRefID)
input ?, (SourceDomainID)
input ?, (TargetDomainID)
input ?, (AltCOAStructID)
input tChartCOACrossRef.tcCOACrossRefCode, (COACrossRefCode)
input ?, (COACrossRefType)
input ?, (COACrossRefIsActive)
input ?, (SourceDomainCode)
input ?, (TargetDomainCode)
input ?, (AltCOAStructCode)
output dataset tqCOACrossRefByAll) in BCOACrossRef>
assign viCounter = 0.
for each tqCOACrossRefByAll:
viCounter = viCounter + 1.
end.
if viCounter > 1
then do:
assign vcMessage = trim(#T-61'COA Cross-ref is already created in multi source-target domains.':150(750161820)T-61#)
oiReturnStatus = -1.
<M-6 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-256961':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end. /* if viCounter > 1 */
if viCounter = 1
then do:
for first tqCOACrossRefByAll:
<Q-91 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input tqCOACrossRefByAll.tiSourceDomain_ID, (DomainID)
input ?, (SharedSetID)
input ?, (SharedSetCode)
input tChartCOACrossRef.tcSharedSetType, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain>
find first tqDomainByDomainSharedSet no-error.
if available tqDomainByDomainSharedSet and
tqDomainByDomainSharedSet.tiSharedSet_ID <> tChartCOACrossRef.tiSourceSharedSetId
then do:
assign vcMessage = trim(substitute(#T-7'COA Cross Reference is used in Domain &1 with other Shared Sets.':150(456119615)T-7#, tqDomainByDomainSharedSet.tcDomainCode))
oiReturnStatus = -1.
<M-63 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-698200':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end.
<Q-41 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input tqCOACrossRefByAll.tiTargetDomain_ID, (DomainID)
input ?, (SharedSetID)
input ?, (SharedSetCode)
input tChartCOACrossRef.tcSharedSetType, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain>
find first tqDomainByDomainSharedSet no-error.
if available tqDomainByDomainSharedSet and
tqDomainByDomainSharedSet.tiSharedSet_ID <> tChartCOACrossRef.tiTargetSharedSetId
then do:
assign vcMessage = trim(substitute(#T-26'COA Cross Reference is used in Domain &1 with other Shared Sets.':150(456119615)T-26#, tqDomainByDomainSharedSet.tcDomainCode))
oiReturnStatus = -1.
<M-45 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-959716':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end.
end.
assign tChartCOACrossRef.tiCOACrossRefId = tqCOACrossRefByAll.tiCOACrossRef_ID.
end. /* if viCounter = 1 */
assign vlReturnOK = yes.
for each tFRWXref where tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode and
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-SEPERATE} and
tFRWXref.tcFRWCrossRefCOAType = tChartCOACrossRef.tcSharedSetType:
case tFRWXref.tcFRWCrossRefCOAType:
when {&SHAREDSETTYPE-GL} then
assign viSourceSharedSetId = tFRWXref.tiSourceGLSharedSet_ID
viTargetSharedSetId = tFRWXref.tiTargetGLSharedSet_ID.
when {&SHAREDSETTYPE-DIVISION} then
assign viSourceSharedSetId = tFRWXRef.tiSourceDivSharedSet_ID
viTargetSharedSetId = tFRWXref.tiTargetDivSharedSet_ID.
when {&SHAREDSETTYPE-COSTCENTRE} then
assign viSourceSharedSetId = tFRWXref.tiSourceCCSharedSet_ID
viTargetSharedSetId = tFRWXref.tiTargetCCSharedSet_ID.
when {&SHAREDSETTYPE-PROJECT} then
assign viSourceSharedSetId = tFRWXref.tiSourcePrjSharedSet_ID
viTargetSharedSetId = tFRWXref.tiTargetPrjSharedSet_ID.
end case.
if viSourceSharedSetId <> tChartCOACrossRef.tiSourceSharedSetId or
viTargetSharedSetId <> tChartCOACrossRef.tiTargetSharedSetId then assign vlReturnOK = no.
end. /* for each tFRWXref */
if not vlReturnOK
then do:
assign vcMessage = trim(#T-66'COA Cross-ref is already created in multi source-target domains.':150(750161820)T-66#)
oiReturnStatus = -1.
<M-1 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-804198':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end. /* if not vlReturnOK */
find first tFRWXref where tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode and
tFRWXref.tcFRWCrossRefCOAType <> tChartCOACrossRef.tcSharedSetType no-error.
if available tFRWXref
then do:
<M-71 run GetSharedSetTypeTranslation
(input tFRWXRef.tcFRWCrossRefCOAType (icUntranslatedSharedSetType),
output vcTranslatedSharedSetType (ocTranslatedSharedSetType),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
assign vcMessage = trim(substitute(#T-777'COA Cross Reference is already used for another COA type &1.':150(261710702)T-777#, vcTranslatedSharedSetType))
oiReturnStatus = -1.
<M-247 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input vcTranslatedSharedSetType (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-400177':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end.
case tChartCOACrossRef.tcSharedSetType:
when {&SHAREDSETTYPE-GL}
then do:
find first tFRWXref where tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode and
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-SEPERATE} and
tFRWXref.tcFRWCrossRefCOAType = tChartCOACrossRef.tcSharedSetType and
tFRWXref.tiSourceGLSharedSet_ID = tChartCOACrossRef.tiSourceSharedSetId and
tFRWXref.tiTargetGLSharedSet_ID = tChartCOACrossRef.tiTargetSharedSetId no-error.
if not available tFRWXref
then do:
create tFRWXref.
assign tFRWXref.tiFRWCrossRef_ID = next-value(ObjectNumber)
tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-SEPERATE}
tFRWXref.tcFRWCrossRefCOAType = tChartCOACrossRef.tcSharedSetType
tFRWXref.tiSourceGLSharedSet_ID = tChartCOACrossRef.tiSourceSharedSetId
tFRWXref.tiTargetGLSharedSet_ID = tChartCOACrossRef.tiTargetSharedSetId.
end.
end.
when {&SHAREDSETTYPE-DIVISION}
then do:
find first tFRWXref where tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode and
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-SEPERATE} and
tFRWXref.tcFRWCrossRefCOAType = tChartCOACrossRef.tcSharedSetType and
tFRWXref.tiSourceDivSharedSet_ID = tChartCOACrossRef.tiSourceSharedSetId and
tFRWXref.tiTargetDivSharedSet_ID = tChartCOACrossRef.tiTargetSharedSetId no-error.
if not available tFRWXref
then do:
create tFRWXref.
assign tFRWXref.tiFRWCrossRef_ID = next-value(ObjectNumber)
tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-SEPERATE}
tFRWXref.tcFRWCrossRefCOAType = tChartCOACrossRef.tcSharedSetType
tFRWXref.tiSourceDivSharedSet_ID = tChartCOACrossRef.tiSourceSharedSetId
tFRWXref.tiTargetDivSharedSet_ID = tChartCOACrossRef.tiTargetSharedSetId.
end.
end.
when {&SHAREDSETTYPE-COSTCENTRE}
then do:
find first tFRWXref where tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode and
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-SEPERATE} and
tFRWXref.tcFRWCrossRefCOAType = tChartCOACrossRef.tcSharedSetType and
tFRWXref.tiSourceCCSharedSet_ID = tChartCOACrossRef.tiSourceSharedSetId and
tFRWXref.tiTargetCCSharedSet_ID = tChartCOACrossRef.tiTargetSharedSetId no-error.
if not available tFRWXref
then do:
create tFRWXref.
assign tFRWXref.tiFRWCrossRef_ID = next-value(ObjectNumber)
tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-SEPERATE}
tFRWXref.tcFRWCrossRefCOAType = tChartCOACrossRef.tcSharedSetType
tFRWXref.tiSourceCCSharedSet_ID = tChartCOACrossRef.tiSourceSharedSetId
tFRWXref.tiTargetCCSharedSet_ID = tChartCOACrossRef.tiTargetSharedSetId.
end.
end.
when {&SHAREDSETTYPE-PROJECT}
then do:
find first tFRWXref where tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode and
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-SEPERATE} and
tFRWXref.tcFRWCrossRefCOAType = tChartCOACrossRef.tcSharedSetType and
tFRWXref.tiSourcePrjSharedSet_ID = tChartCOACrossRef.tiSourceSharedSetId and
tFRWXref.tiTargetPrjSharedSet_ID = tChartCOACrossRef.tiTargetSharedSetId no-error.
if not available tFRWXref
then do:
create tFRWXref.
assign tFRWXref.tiFRWCrossRef_ID = next-value(ObjectNumber)
tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-SEPERATE}
tFRWXref.tcFRWCrossRefCOAType = tChartCOACrossRef.tcSharedSetType
tFRWXref.tiSourcePrjSharedSet_ID = tChartCOACrossRef.tiSourceSharedSetId
tFRWXref.tiTargetPrjSharedSet_ID = tChartCOACrossRef.tiTargetSharedSetId.
end.
end.
end case.
if viCounter = 0
then do:
assign viTargetDomainID = 0.
<Q-90 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input tChartCOACrossRef.tiTargetDomainId, (DomainID)
input tChartCOACrossRef.tiTargetSharedSetId, (SharedSetID)
input ?, (SharedSetCode)
input ?, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain>
find first tqDomainByDomainSharedSet no-error.
if available tqDomainByDomainSharedSet
then do:
if tChartCOACrossRef.tiTargetDomainId <> ? and tChartCOACrossRef.tiTargetDomainId <> 0
then assign viTargetDomainID = tChartCOACrossRef.tiTargetDomainId.
else assign viTargetDomainID = tqDomainByDomainSharedSet.tiDomain_ID.
end.
if viTargetDomainID <> 0
then do:
find first tCOACrossRefForSave where tCOACrossRefForSave.tcCOACrossRefCode = tChartCOACrossRef.tcCOACrossRefCode and
tCOACrossRefForSave.tcStatus = 'N':U no-error.
if not available tCOACrossRefForSave
then do:
create tCOACrossRefForSave.
assign tCOACrossRefForSave.tcCOACrossRefCode = tChartCOACrossRef.tcCOACrossRefCode
tCOACrossRefForSave.tcCOACrossRefDesc= tChartCOACrossRef.tcCOACrossRefCode + " generated":U
tCOACrossRefForSave.tcCOACrossRefType = {&COACROSSREFTYPE-SEPERATE}
tCOACrossRefForSave.tiSourceDomainId = tChartCOACrossRef.tiDomainID
tCOACrossRefForSave.tiTargetDomainId = viTargetDomainID
tCOACrossRefForSave.tiFRWShSetCombId = tChartCOACrossRef.tiFRWShSetCombId
tCOACrossRefForSave.tcSharedSetType = tChartCOACrossRef.tcSharedSetType
tCOACrossRefForSave.tcStatus = 'N':U.
end.
<Q-53 run DomainsPrim (first) (Read) (NoCache)
(input tCOACrossRefForSave.tiSourceDomainId, (DomainID)
input ?, (DomainCode)
output dataset tqDomainsPrim) in BDomain>
for first tqDomainsPrim:
tCOACrossRefForSave.tcSourceDomainCode = tqDomainsPrim.tcDomainCode.
end.
<Q-22 run DomainsPrim (first) (Read) (NoCache)
(input tCOACrossRefForSave.tiTargetDomainId, (DomainID)
input ?, (DomainCode)
output dataset tqDomainsPrim) in BDomain>
for first tqDomainsPrim:
tCOACrossRefForSave.tcTargetDomainCode = tqDomainsPrim.tcDomainCode.
end.
end.
assign tChartCOACrossRef.tiCOACrossRefId = 0.
end. /* if viCounter = 0 */
end. /* if tChartCOACrossRef.tcCOACrossRefCode <> ? and trim(tChartCOACrossRef.tcCOACrossRefCode) <> "":U and tChartCOACrossRef.tcCOACrossRefCode <> {&COACROSSREFCODE-NOTNEEDED} */
else do:
if tChartCOACrossRef.tiSourceSharedSetId <> tChartCOACrossRef.tiTargetSharedSetId and
tChartCOACrossRef.tiTargetSharedSetId <> 0
then do:
assign vcMessage = trim(#T-52'Not Needed is not allowed in this case.':100(135124476)T-52#) + " " +
trim(#T-35'Only allowed when source and target domain have same Shared Set.':150(535645449)T-35#)
oiReturnStatus = -1.
<M-97 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-469080':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end.
assign tChartCOACrossRef.tiCOACrossRefId = 0.
end. /* else do */
/* Delete the old COACrossRef if that is not used anymore */
if viCOACrossRefID <> 0 and
viCOACrossRefID <> tChartCOACrossRef.tiCOACrossRefId then
do:
assign vlFindAnother = yes.
/* Make sure that it is not used by another reporting domain */
if tChartCOACrossRef.tcSharedSetType = {&SHAREDSETTYPE-GL}
then do:
<Q-58 run FRWShSetCombByGLXRefId (all) (Read) (NoCache)
(input viCOACrossRefID, (GLXrefId)
output dataset tqFRWShSetCombByGLXRefId) in BFRWChart>
if not can-find(first tqFRWShSetCombByGLXRefId where tqFRWShSetCombByGLXRefId.tcFRWShSetCombFRWChartCode <> t_sFRWChart.FRWChartCode)
then assign vlFindAnother = no.
end.
if tChartCOACrossRef.tcSharedSetType = {&SHAREDSETTYPE-DIVISION}
then do:
<Q-40 run FRWShSetCombByDivXRefId (all) (Read) (NoCache)
(input viCOACrossRefID, (DivXrefId)
output dataset tqFRWShSetCombByDivXRefId) in BFRWChart>
if not can-find(first tqFRWShSetCombByDivXRefId where tqFRWShSetCombByDivXRefId.tcFRWShSetCombFRWChartCode <> t_sFRWChart.FRWChartCode)
then assign vlFindAnother = no.
end.
if tChartCOACrossRef.tcSharedSetType = {&SHAREDSETTYPE-COSTCENTRE}
then do:
<Q-83 run FRWShSetCombByCCXRefId (all) (Read) (NoCache)
(input viCOACrossRefID, (CCXrefId)
output dataset tqFRWShSetCombByCCXRefId) in BFRWChart>
if not can-find(first tqFRWShSetCombByCCXRefId where tqFRWShSetCombByCCXRefId.tcFRWShSetCombFRWChartCode <> t_sFRWChart.FRWChartCode)
then assign vlFindAnother = no.
end.
if tChartCOACrossRef.tcSharedSetType = {&SHAREDSETTYPE-PROJECT}
then do:
<Q-38 run FRWShSetCombByPrjXRefId (all) (Read) (NoCache)
(input viCOACrossRefID, (PrjXrefId)
output dataset tqFRWShSetCombByPrjXRefId) in BFRWChart>
if not can-find(first tqFRWShSetCombByPrjXRefId where tqFRWShSetCombByPrjXRefId.tcFRWShSetCombFRWChartCode <> t_sFRWChart.FRWChartCode)
then assign vlFindAnother = no.
end.
if not vlFindAnother
then do:
for each tFRWXref where tFRWXref.tiCOACrossRef_ID = viCOACrossRefID exclusive-lock:
delete tFRWXref.
end.
end. /* if not vlFindAnother */
end. /* if viCOACrossRefID <> 0 */
end. /* if tChartCOACrossRef.tcSharedSetType <> {&COACROSSREFTYPE-COMBINED} */
else do:
if trim(tChartCOACrossRef.tcCOACrossRefCode) = "":U or tChartCOACrossRef.tcCOACrossRefCode = ?
then assign tChartCOACrossRef.tiCOACrossRefId = 0.
else do:
if tChartCOACrossRef.tcCOACrossRefCode = {&COACROSSREFCODE-NOTNEEDED}
then do:
assign vcMessage = trim(#T-94'Leave this blank when the Combined COA Cross Ref is not needed.':150(132682335)T-94#)
oiReturnStatus = -1.
<M-17 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-192535':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end.
<Q-44 run COACrossRefByAll (all) (Read) (NoCache)
(input ?, (COACrossRefID)
input ?, (SourceDomainID)
input ?, (TargetDomainID)
input ?, (AltCOAStructID)
input tChartCOACrossRef.tcCOACrossRefCode, (COACrossRefCode)
input ?, (COACrossRefType)
input ?, (COACrossRefIsActive)
input ?, (SourceDomainCode)
input ?, (TargetDomainCode)
input ?, (AltCOAStructCode)
output dataset tqCOACrossRefByAll) in BCOACrossRef>
assign viCounter = 0.
for each tqCOACrossRefByAll:
viCounter = viCounter + 1.
end.
if viCounter > 1
then do:
assign vcMessage = trim(#T-29'COA Cross-ref is already created in multi source-target domains.':150(750161820)T-29#)
oiReturnStatus = -1.
<M-67 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-122444':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end. /* if viCounter > 1 */
if viCounter = 1
then do:
for first tqCOACrossRefByAll:
assign vcAllSets = "".
<Q-51 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input tqCOACrossRefByAll.tiSourceDomain_ID, (DomainID)
input ?, (SharedSetID)
input ?, (SharedSetCode)
input ?, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain>
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-GL}:
assign vcAllSets = vcAllSets + string(tqDomainByDomainSharedSet.tiSharedSet_ID,"9999999999").
end.
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-DIVISION}:
assign vcAllSets = vcAllSets + string(tqDomainByDomainSharedSet.tiSharedSet_ID,"9999999999").
end.
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-COSTCENTRE}:
assign vcAllSets = vcAllSets + string(tqDomainByDomainSharedSet.tiSharedSet_ID,"9999999999").
end.
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-PROJECT}:
assign vcAllSets = vcAllSets + string(tqDomainByDomainSharedSet.tiSharedSet_ID,"9999999999").
end.
if vcAllSets <> tChartCOACrossRef.tcAllSets
then do:
assign vcMessage = trim(substitute(#T-95'COA Cross Reference is used in Domain &1 with other Shared Sets.':150(456119615)T-95#, tqDomainByDomainSharedSet.tcDomainCode))
oiReturnStatus = -1.
<M-4 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-861682':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end.
assign vlReturnOK = yes.
<Q-31 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input tqCOACrossRefByAll.tiTargetDomain_ID, (DomainID)
input ?, (SharedSetID)
input ?, (SharedSetCode)
input ?, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain>
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-GL}:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.GLSharedSet_ID then assign vlReturnOK = no.
end.
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-DIVISION}:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.DivisionSharedSet_ID then assign vlReturnOK = no.
end.
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-COSTCENTRE}:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.CostCentreSharedSet_ID then assign vlReturnOK = no.
end.
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-PROJECT}:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.ProjectSharedSet_ID then assign vlReturnOK = no.
end.
if not vlReturnOK
then do:
assign vcMessage = trim(substitute(#T-87'COA Cross Reference is used in Domain &1 with other Shared Sets.':150(456119615)T-87#, tqDomainByDomainSharedSet.tcDomainCode)) oiReturnStatus = -1.
<M-18 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-483191':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end.
end. /* for first tqCOACrossRefByAll */
assign tChartCOACrossRef.tiCOACrossRefId = tqCOACrossRefByAll.tiCOACrossRef_ID.
end. /* if viCounter = 1 */
assign vlReturnOK = yes.
for each tFRWXref where tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode and
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-COMBINED} and
tFRWXref.tcFRWCrossRefCOAType = {&TRANSDIRECTION-ALL}:
if tFRWXref.tiSourceGLSharedSet_ID <> int(substring(tChartCOACrossRef.tcAllSets,1,10,"CHARACTER":U)) or
tFRWXref.tiTargetGLSharedSet_ID <> t_sFRWChart.GLSharedSet_ID or
tFRWXref.tiSourceDivSharedSet_ID <> int(substring(tChartCOACrossRef.tcAllSets,11,10,"CHARACTER":U)) or
tFRWXref.tiTargetDivSharedSet_ID <> t_sFRWChart.DivisionSharedSet_ID or
tFRWXref.tiSourceCCSharedSet_ID <> int(substring(tChartCOACrossRef.tcAllSets,21,10,"CHARACTER":U)) or
tFRWXref.tiTargetCCSharedSet_ID <> t_sFRWChart.CostCentreSharedSet_ID or
tFRWXref.tiSourcePrjSharedSet_ID <> int(substring(tChartCOACrossRef.tcAllSets,31,10,"CHARACTER":U)) or
tFRWXref.tiTargetPrjSharedSet_ID <> t_sFRWChart.ProjectSharedSet_ID then assign vlReturnOK = false.
end.
if not vlReturnOK
then do:
assign vcMessage = trim(#T-697'COA Cross-ref is already created in multi source-target domains.':150(750161820)T-697#)
oiReturnStatus = -1.
<M-16 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input tChartCOACrossRef.tcCOACrossRefCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-253599':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end.
find first tFRWXref where tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode and
tFRWXref.tcFRWCrossRefCOAType <> {&TRANSDIRECTION-ALL} no-error.
if available tFRWXref
then do:
<M-77 run GetSharedSetTypeTranslation
(input tFRWXRef.tcFRWCrossRefCOAType (icUntranslatedSharedSetType),
output vcTranslatedSharedSetType (ocTranslatedSharedSetType),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
assign vcMessage = trim(substitute(#T-54'COA Cross Reference is already used for another COA type &1.':150(261710702)T-54#,vcTranslatedSharedSetType))
oiReturnStatus = -1.
<M-84 run SetMessage
(input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input vcTranslatedSharedSetType (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-227434':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BFRWChart>
next.
end.
find first tFRWXref where tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode and
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-COMBINED} and
tFRWXref.tcFRWCrossRefCOAType = {&TRANSDIRECTION-ALL} and
tFRWXref.tiSourceGLSharedSet_ID = int(substring(tChartCOACrossRef.tcAllSets,1,10,"CHARACTER":U)) and
tFRWXref.tiTargetGLSharedSet_ID = t_sFRWChart.GLSharedSet_ID and
tFRWXref.tiSourceDivSharedSet_ID = int(substring(tChartCOACrossRef.tcAllSets,11,10,"CHARACTER":U)) and
tFRWXref.tiTargetDivSharedSet_ID = t_sFRWChart.DivisionSharedSet_ID and
tFRWXref.tiSourceCCSharedSet_ID = int(substring(tChartCOACrossRef.tcAllSets,21,10,"CHARACTER":U)) and
tFRWXref.tiTargetCCSharedSet_ID = t_sFRWChart.CostCentreSharedSet_ID and
tFRWXref.tiSourcePrjSharedSet_ID = int(substring(tChartCOACrossRef.tcAllSets,31,10,"CHARACTER":U)) and
tFRWXref.tiTargetPrjSharedSet_ID = t_sFRWChart.ProjectSharedSet_ID no-error.
if not available tFRWXref
then do:
create tFRWXref.
assign tFRWXref.tiFRWCrossRef_ID = next-value(ObjectNumber)
tFRWXref.tcFRWCrossRefCOACode = tChartCOACrossRef.tcCOACrossRefCode
tFRWXref.tcFRWCrossRefCode = {&COACROSSREFTYPE-COMBINED}
tFRWXref.tcFRWCrossRefCOAType = {&TRANSDIRECTION-ALL}
tFRWXref.tiSourceGLSharedSet_ID = int(substring(tChartCOACrossRef.tcAllSets,1,10,"CHARACTER":U))
tFRWXref.tiTargetGLSharedSet_ID = t_sFRWChart.GLSharedSet_ID
tFRWXref.tiSourceDivSharedSet_ID = int(substring(tChartCOACrossRef.tcAllSets,11,10,"CHARACTER":U))
tFRWXref.tiTargetDivSharedSet_ID = t_sFRWChart.DivisionSharedSet_ID
tFRWXref.tiSourceCCSharedSet_ID = int(substring(tChartCOACrossRef.tcAllSets,21,10,"CHARACTER":U))
tFRWXref.tiTargetCCSharedSet_ID = t_sFRWChart.CostCentreSharedSet_ID
tFRWXref.tiSourcePrjSharedSet_ID = int(substring(tChartCOACrossRef.tcAllSets,31,10,"CHARACTER":U))
tFRWXref.tiTargetPrjSharedSet_ID = t_sFRWChart.ProjectSharedSet_ID.
end.
if viCounter = 0
then do:
assign viTargetDomainID = 0.
if tChartCOACrossRef.tiTargetDomainId <> 0
then do:
assign vlReturnOK = yes.
<Q-82 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input viTargetDomainID, (DomainID)
input ?, (SharedSetID)
input ?, (SharedSetCode)
input ?, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain>
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-GL}:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.GLSharedSet_ID then assign vlReturnOK = no.
end.
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-DIVISION}:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.DivisionSharedSet_ID then assign vlReturnOK = no.
end.
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-COSTCENTRE}:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.CostCentreSharedSet_ID then assign vlReturnOK = no.
end.
for first tqDomainByDomainSharedSet where tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-PROJECT}:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.ProjectSharedSet_ID then assign vlReturnOK = no.
end.
if vlReturnOK then assign viTargetDomainID = tChartCOACrossRef.tiTargetDomainId.
end.
if viTargetDomainID = 0
then do:
assign viPrevBestMatch = 0.
<Q-23 run DomainByDomainSharedSet (all) (Read) (NoCache)
(input ?, (DomainID)
input ?, (SharedSetID)
input ?, (SharedSetCode)
input ?, (SharedSetType)
output dataset tqDomainByDomainSharedSet) in BDomain>
for each tqDomainByDomainSharedSet break by tqDomainByDomainSharedSet.tiDomain_ID:
if first-of(tqDomainByDomainSharedSet.tiDomain_ID) then
assign vlSharedSetsAllMatch = yes
viNumberOfMatches = 0.
if tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-GL}
then do:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.GLSharedSet_ID and
t_sFRWChart.GLSharedSet_ID <> 0 then assign vlSharedSetsAllMatch = no.
else assign viNumberOfMatches = viNumberOfMatches + 1.
end.
if tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-DIVISION}
then do:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.DivisionSharedSet_ID and
t_sFRWChart.DivisionSharedSet_ID <> 0 then assign vlSharedSetsAllMatch = no.
else assign viNumberOfMatches = viNumberOfMatches + 1.
end.
if tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-COSTCENTRE}
then do:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.CostCentreSharedSet_ID and
t_sFRWChart.CostCentreSharedSet_ID <> 0 then assign vlSharedSetsAllMatch = no.
else assign viNumberOfMatches = viNumberOfMatches + 1.
end.
if tqDomainByDomainSharedSet.tcSharedSetTypeCode = {&SHAREDSETTYPE-PROJECT}
then do:
if tqDomainByDomainSharedSet.tiSharedSet_ID <> t_sFRWChart.ProjectSharedSet_ID and
t_sFRWChart.ProjectSharedSet_ID <> 0 then assign vlSharedSetsAllMatch = no.
else assign viNumberOfMatches = viNumberOfMatches + 1.
end.
if last-of(tqDomainByDomainSharedSet.tiDomain_ID)
then do:
if vlSharedSetsAllMatch
then do:
assign viTargetDomainID = tqDomainByDomainSharedSet.tiDomain_ID.
leave.
end.
else do:
if viNumberOfMatches > viPrevBestMatch
then do:
assign viTargetDomainID = tqDomainByDomainSharedSet.tiDomain_ID
viPrevBestMatch = viNumberOfMatches.
end.
end. /* else do */
end. /* if last-of(tqDomainByDomainSharedSet.tiDomain_ID) */
end. /* for each tqDomainByDomainSharedSet */
find first tCOACrossRefForSave where tCOACrossRefForSave.tcCOACrossRefCode = tChartCOACrossRef.tcCOACrossRefCode and
tCOACrossRefForSave.tcStatus = 'N':U no-error.
if not available tCOACrossRefForSave
then do:
create tCOACrossRefForSave.
assign tCOACrossRefForSave.tcCOACrossRefCode = tChartCOACrossRef.tcCOACrossRefCode
tCOACrossRefForSave.tcCOACrossRefDesc = tChartCOACrossRef.tcCOACrossRefCode + " generated":U
tCOACrossRefForSave.tcCOACrossRefType = {&COACROSSREFTYPE-COMBINED}
tCOACrossRefForSave.tiSourceDomainId = tChartCOACrossRef.tiDomainID
tCOACrossRefForSave.tiTargetDomainId = viTargetDomainID
tCOACrossRefForSave.tiFRWShSetCombId = tChartCOACrossRef.tiFRWShSetCombId
tCOACrossRefForSave.tcSharedSetType = tChartCOACrossRef.tcSharedSetType
tCOACrossRefForSave.tcStatus = 'N':U.
end.
<Q-68 run DomainsPrim (first) (Read) (NoCache)
(input tChartCOACrossRef.tiDomainID, (DomainID)
input ?, (DomainCode)
output dataset tqDomainsPrim) in BDomain>
for first tqDomainsPrim:
tCOACrossRefForSave.tcSourceDomainCode = tqDomainsPrim.tcDomainCode.
end.
<Q-85 run DomainsPrim (first) (Read) (NoCache)
(input tChartCOACrossRef.tiTargetDomainId, (DomainID)
input ?, (DomainCode)
output dataset tqDomainsPrim) in BDomain>
for first tqDomainsPrim:
tCOACrossRefForSave.tcTargetDomainCode = tqDomainsPrim.tcDomainCode.
end.
assign tChartCOACrossRef.tiCOACrossRefId = 0.
end. /* if viTargetDomainID = 0 */
end. /* if viCounter = 0 */
/* Delete the old COACrossRef if that is not used anymore */
if viCOACrossRefID <> 0 and
viCOACrossRefID <> tChartCOACrossRef.tiCOACrossRefId
then do:
for each tFRWXref where tFRWXref.tiCOACrossRef_ID = viCOACrossRefID:
delete tFRWXref.
end. /* for each tFRWXref */
end. /* if viCOACrossRefID <> 0 */
end. /* else do */
end. /* else do */
end. /* for each tChartCOACrossRef */
end. /* MAIN_BLOCK: */