Description
AdditonalUpdatesDelete; Submethod of AdditionalUpdates
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bqbudgetcommitment.p)
/* ================================================================ */
/* Set Return-status = Default-error */
/* ================================================================ */
assign oiReturnStatus = -98.
/* ===================================================================== */
/* ToDo: */
/* For every tQBudgetLinkCommit (temporarely records) that gets deleted, */
/* a QBudgetLinkCommit record will be created and a related QBudgetLink */
/* record will be updated. These QBudgetLinkCommit records are the */
/* permanent link between the po-line and the budget (using QBudgetLink) */
/* ===================================================================== */
/* ===================== */
/* Empty the temp-tables */
/* ===================== */
empty temp-table tBudgetCheckInfoQBC.
empty temp-table tBudgetCheckInfoWBSQBC.
empty temp-table tNewQBudgetLinkCommit.
empty temp-table tNewBudgetLinkCommitFromBQ.
/* ======================================= */
/* Go through all deleted instance records */
/* ======================================= */
for each tQBudgetLinkCommit where
tQBudgetLinkCommit.tc_Status = "D":U no-lock :
create tBudgetCheckInfoQBC.
assign viBudgetCheckInfoIDCounter = viBudgetCheckInfoIDCounter + 1
tBudgetCheckInfoQBC.tiBudgetCheckInfoID = viBudgetCheckInfoIDCounter
tBudgetCheckInfoQBC.tcParentTcRowid = string(rowid(tQBudgetLinkCommit))
tBudgetCheckInfoQBC.tiCompanyId = tQBudgetLinkCommit.Company_ID
tBudgetCheckInfoQBC.tcCallerReference = tQBudgetLinkCommit.BudgetLinkCommitInfo
tBudgetCheckInfoQBC.tiBudgetID = tQBudgetLinkCommit.Budget_ID
tBudgetCheckInfoQBC.tiBudgetWBSID = tQBudgetLinkCommit.BudgetWBS_ID
tBudgetCheckInfoQBC.ttDate = tQBudgetLinkCommit.BudgetLinkCommitDate
tBudgetCheckInfoQBC.tiCurrencyID = tQBudgetLinkCommit.Currency_ID
tBudgetCheckInfoQBC.tiUnitID = tQBudgetLinkCommit.Unit_ID
tBudgetCheckInfoQBC.tcDivisionCode = tQBudgetLinkCommit.BudgetLinkCommitDivCode
tBudgetCheckInfoQBC.tcGLCode = tQBudgetLinkCommit.BudgetLinkCommitGLCode
tBudgetCheckInfoQBC.tiGLID = 0
tBudgetCheckInfoQBC.tlGLIsWithBudget = true
tBudgetCheckInfoQBC.tcCostCentreCode = tQBudgetLinkCommit.BudgetLinkCommitCCCode
tBudgetCheckInfoQBC.tiCostCentreID = 0
tBudgetCheckInfoQBC.tcProjectCode = tQBudgetLinkCommit.BudgetLinkCommitPrjCode
tBudgetCheckInfoQBC.tiProjectID = 0
tBudgetCheckInfoQBC.tdAmountTC = tQBudgetLinkCommit.BudgetLinkCommitTC
tBudgetCheckInfoQBC.tdQTY = tQBudgetLinkCommit.BudgetLinkCommitQTY
tBudgetCheckInfoQBC.tcSafStructureCode = tQBudgetLinkCommit.BudgetLinkCommitSafStruct
tBudgetCheckInfoQBC.tcSafConcept1Code = tQBudgetLinkCommit.BudgetLinkCommitSaf1Concpt
tBudgetCheckInfoQBC.tcSafConcept2Code = tQBudgetLinkCommit.BudgetLinkCommitSaf2Concpt
tBudgetCheckInfoQBC.tcSafConcept3Code = tQBudgetLinkCommit.BudgetLinkCommitSaf3Concpt
tBudgetCheckInfoQBC.tcSafConcept4Code = tQBudgetLinkCommit.BudgetLinkCommitSaf4Concpt
tBudgetCheckInfoQBC.tcSafConcept5Code = tQBudgetLinkCommit.BudgetLinkCommitSaf5Concpt
tBudgetCheckInfoQBC.tcSaf1Code = tQBudgetLinkCommit.BudgetLinkCommitSaf1Code
tBudgetCheckInfoQBC.tcSaf2Code = tQBudgetLinkCommit.BudgetLinkCommitSaf2Code
tBudgetCheckInfoQBC.tcSaf3Code = tQBudgetLinkCommit.BudgetLinkCommitSaf3Code
tBudgetCheckInfoQBC.tcSaf4Code = tQBudgetLinkCommit.BudgetLinkCommitSaf4Code
tBudgetCheckInfoQBC.tcSaf5Code = tQBudgetLinkCommit.BudgetLinkCommitSaf5Code.
/* ================================================ */
/* Resolve the SafStructureID and the SafConceptIDs */
/* ================================================ */
if tBudgetCheckInfoQBC.tcSafStructureCode <> ? and
tBudgetCheckInfoQBC.tcSafStructureCode <> "":U
then SAFRESOLVINGBLOCK : do :
<Q-3 run SafConceptCodeByLine (all) (Read) (NoCache)
(input ?, (SafStructure_ID)
input ?, (SafStructureLineNumber)
input tBudgetCheckInfoQBC.tcSafStructureCode, (SafStructureCode)
output dataset tqSafConceptCodeByLine) in BSafStructure >
find first tqSafConceptCodeByLine no-lock no-error.
if not available tqSafConceptCodeByLine
then do :
assign vhFcComponent = ?
vcMessage = trim(substitute(#T-22'The system cannot find the ID based on the SAF structure code (&1).':200(3452)t-22#,trim(tBudgetCheckInfoQBC.tcSafStructureCode))).
<M-4 run CreateCorruption
(input 'QBudgetLinkCommit':U (icTableName),
input string(tQBudgetLinkCommit.QBudgetLinkCommit_ID) (icKey),
input vcMessage (icDescription),
input ? (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
<M-5 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tQBudgetLinkCommit.BudgetLinkCommitSafStruct':U (icFieldName),
input tQBudgetLinkCommit.BudgetLinkCommitSafStruct (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tQBudgetLinkCommit.tc_Rowid (icRowid),
input 'QADFIN-1822':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQBudgetCommitment>
assign viLocalReturnStatus = -3.
Leave SAFRESOLVINGBLOCK.
end. /* if not available tqSafConceptCodeByLine */
assign tBudgetCheckInfoQBC.tiSafStructureID = tqSafConceptCodeByLine.tiSafStructure_ID.
if tBudgetCheckInfoQBC.tcSafConcept1Code <> ? and
tBudgetCheckInfoQBC.tcSafConcept1Code <> "":U
then do :
find first tqSafConceptCodeByLine where
tqSafConceptCodeByLine.tiSafStructureLineNumber = 1
no-lock no-error.
if not available tqSafConceptCodeByLine
then do :
assign vhFcComponent = ?
vcMessage = trim(substitute(#T-23'SAF concept &1 (&2) was expected, but was not found in the SAF structure (&3).':200(3453)T-23#,trim(string(1)),trim(tBudgetCheckInfoQBC.tcSafConcept1Code),trim(tBudgetCheckInfoQBC.tcSafStructureCode))).
<M-6 run CreateCorruption
(input 'QBudgetLinkCommit':U (icTableName),
input string(tQBudgetLinkCommit.QBudgetLinkCommit_ID) (icKey),
input vcMessage (icDescription),
input ? (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
<M-7 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tQBudgetLinkCommit.BudgetLinkCommitSafStruct':U (icFieldName),
input tQBudgetLinkCommit.BudgetLinkCommitSafStruct (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tQBudgetLinkCommit.tc_Rowid (icRowid),
input 'QADFIN-1823':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQBudgetCommitment>
assign viLocalReturnStatus = -3.
Leave SAFRESOLVINGBLOCK.
end. /* if not available tqSafConceptCodeByLine */
assign tBudgetCheckInfoQBC.tiSafConcept1ID = tqSafConceptCodeByLine.tiSafConcept_ID.
end. /* if tBudgetCheckInfoQBC.tcSafConcept1Code <> ? and */
if tBudgetCheckInfoQBC.tcSafConcept2Code <> ? and
tBudgetCheckInfoQBC.tcSafConcept2Code <> "":U
then do :
find first tqSafConceptCodeByLine where
tqSafConceptCodeByLine.tiSafStructureLineNumber = 2
no-lock no-error.
if not available tqSafConceptCodeByLine
then do :
assign vhFcComponent = ?
vcMessage = trim(substitute(#T-24'SAF concept &1 (&2) was expected, but was not found in the SAF structure (&3).':200(3453)T-24#,trim(string(2)),trim(tBudgetCheckInfoQBC.tcSafConcept2Code),trim(tBudgetCheckInfoQBC.tcSafStructureCode))).
<M-8 run CreateCorruption
(input 'QBudgetLinkCommit':U (icTableName),
input string(tQBudgetLinkCommit.QBudgetLinkCommit_ID) (icKey),
input vcMessage (icDescription),
input ? (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
<M-9 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tQBudgetLinkCommit.BudgetLinkCommitSafStruct':U (icFieldName),
input tQBudgetLinkCommit.BudgetLinkCommitSafStruct (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tQBudgetLinkCommit.tc_Rowid (icRowid),
input 'QADFIN-1824':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQBudgetCommitment>
assign viLocalReturnStatus = -3.
Leave SAFRESOLVINGBLOCK.
end. /* if not available tqSafConceptCodeByLine */
assign tBudgetCheckInfoQBC.tiSafConcept2ID = tqSafConceptCodeByLine.tiSafConcept_ID.
end. /* if tBudgetCheckInfoQBC.tcSafConcept2Code <> ? and */
if tBudgetCheckInfoQBC.tcSafConcept3Code <> ? and
tBudgetCheckInfoQBC.tcSafConcept3Code <> "":U
then do :
find first tqSafConceptCodeByLine where
tqSafConceptCodeByLine.tiSafStructureLineNumber = 3
no-lock no-error.
if not available tqSafConceptCodeByLine
then do :
assign vhFcComponent = ?
vcMessage = trim(substitute(#T-25'SAF concept &1 (&2) was expected, but was not found in the SAF structure (&3).':200(3453)T-25#,trim(string(3)),trim(tBudgetCheckInfoQBC.tcSafConcept3Code),trim(tBudgetCheckInfoQBC.tcSafStructureCode))).
<M-10 run CreateCorruption
(input 'QBudgetLinkCommit':U (icTableName),
input string(tQBudgetLinkCommit.QBudgetLinkCommit_ID) (icKey),
input vcMessage (icDescription),
input ? (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
<M-11 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tQBudgetLinkCommit.BudgetLinkCommitSafStruct':U (icFieldName),
input tQBudgetLinkCommit.BudgetLinkCommitSafStruct (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tQBudgetLinkCommit.tc_Rowid (icRowid),
input 'QADFIN-1819':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQBudgetCommitment>
assign viLocalReturnStatus = -3.
Leave SAFRESOLVINGBLOCK.
end. /* if not available tqSafConceptCodeByLine */
assign tBudgetCheckInfoQBC.tiSafConcept3ID = tqSafConceptCodeByLine.tiSafConcept_ID.
end. /* if tBudgetCheckInfoQBC.tcSafConcept3Code <> ? and */
if tBudgetCheckInfoQBC.tcSafConcept4Code <> ? and
tBudgetCheckInfoQBC.tcSafConcept4Code <> "":U
then do :
find first tqSafConceptCodeByLine where
tqSafConceptCodeByLine.tiSafStructureLineNumber = 4
no-lock no-error.
if not available tqSafConceptCodeByLine
then do :
assign vhFcComponent = ?
vcMessage = trim(substitute(#T-26'SAF concept &1 (&2) was expected, but was not found in the SAF structure (&3).':200(3453)T-26#,trim(string(4)),trim(tBudgetCheckInfoQBC.tcSafConcept4Code),trim(tBudgetCheckInfoQBC.tcSafStructureCode))).
<M-12 run CreateCorruption
(input 'QBudgetLinkCommit':U (icTableName),
input string(tQBudgetLinkCommit.QBudgetLinkCommit_ID) (icKey),
input vcMessage (icDescription),
input ? (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
<M-13 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tQBudgetLinkCommit.BudgetLinkCommitSafStruct':U (icFieldName),
input tQBudgetLinkCommit.BudgetLinkCommitSafStruct (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tQBudgetLinkCommit.tc_Rowid (icRowid),
input 'QADFIN-1820':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQBudgetCommitment>
assign viLocalReturnStatus = -3.
Leave SAFRESOLVINGBLOCK.
end. /* if not available tqSafConceptCodeByLine */
assign tBudgetCheckInfoQBC.tiSafConcept4ID = tqSafConceptCodeByLine.tiSafConcept_ID.
end. /* if tBudgetCheckInfoQBC.tcSafConcept4Code <> ? and */
if tBudgetCheckInfoQBC.tcSafConcept5Code <> ? and
tBudgetCheckInfoQBC.tcSafConcept5Code <> "":U
then do :
find first tqSafConceptCodeByLine where
tqSafConceptCodeByLine.tiSafStructureLineNumber = 5
no-lock no-error.
if not available tqSafConceptCodeByLine
then do :
assign vhFcComponent = ?
vcMessage = trim(substitute(#T-27'SAF concept &1 (&2) was expected, but was not found in the SAF structure (&3).':200(3453)T-27#,trim(string(5)),trim(tBudgetCheckInfoQBC.tcSafConcept5Code),trim(tBudgetCheckInfoQBC.tcSafStructureCode))).
<M-14 run CreateCorruption
(input 'QBudgetLinkCommit':U (icTableName),
input string(tQBudgetLinkCommit.QBudgetLinkCommit_ID) (icKey),
input vcMessage (icDescription),
input ? (ilSkipMessage),
output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
<M-15 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tQBudgetLinkCommit.BudgetLinkCommitSafStruct':U (icFieldName),
input tQBudgetLinkCommit.BudgetLinkCommitSafStruct (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tQBudgetLinkCommit.tc_Rowid (icRowid),
input 'QADFIN-1821':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BQBudgetCommitment>
assign viLocalReturnStatus = -3.
Leave SAFRESOLVINGBLOCK.
end. /* if not available tqSafConceptCodeByLine */
assign tBudgetCheckInfoQBC.tiSafConcept5ID = tqSafConceptCodeByLine.tiSafConcept_ID.
end. /* if tBudgetCheckInfoQBC.tcSafConcept5Code <> ? and */
end. /* if tBudgetCheckInfoQBC.tcSafStructureCode <> ? and */
end. /* for each */
/* ================ */
/* Check for errors */
/* ================ */
if viLocalReturnStatus <> 0
then do :
assign oiReturnStatus = viLocalReturnStatus.
if oiReturnStatus < 0 then return.
end. /* if viLocalReturnStatus <> 0 */
/* ================================================================ */
/* Call an instance-less method in BBudget that will return a table */
/* with the BudgetWBS-nodes that match the deleted instance records */
/* Create tNewBudgetLinkCommitFromBQ-records based on the output */
/* ================================================================ */
assign vhFcComponent = ?.
<M-16 run BudgetCheckInfoResolve (input tBudgetCheckInfoQBC (tBudgetCheckInfo),
input ? (ilOnlyHandleCommitOnlineBudgets),
input ? (ilOnlyHandleActualOnlineBudgets),
input false (ilCalledFromBudgetCheck),
output tBudgetCheckInfoWBSQBC (tBudgetCheckInfoWBS),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
if viFcReturnSuper <> 0
then do :
assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end. /* if viFcReturnSuper <> 0 */
/* ======================================================================== */
/* No further processing needed if these are no BudgetLinkCommits to update */
/* ======================================================================== */
if not can-find (first tBudgetCheckInfoWBSQBC)
then do :
assign oiReturnStatus = 0.
return.
end. /* if not can-find (first tBudgetCheckInfoWBSQBA) */
<M-20 run AdditionalUpdatesDeleteSub (output viFcReturnSuper (oiReturnStatus)) in BQBudgetCommitment>
if viFcReturnSuper <> 0
then do :
assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0 then return.
end. /* if viFcReturnSuper <> 0 */
/* ================================================================ */
/* Call a method in BBudgetLinkCommit that will create new records */
/* ================================================================ */
if viBBudgetLinkCommitBQBudComID = 0 or viBBudgetLinkCommitBQBudComID = ?
then do:
/* StartOpen instance */
<I-17 {bFcStartAndOpenInstance
&ADD-TO-TRANSACTION = "true"
&CLASS = "BBudgetLinkCommitment"}>
end. /* viBBudgetLinkCommitBQBudComID = 0 or viBBudgetLinkCommitBQBudComID = ? */
else do:
/* Open instance */
<I-18 {bFcOpenInstance
&CLASS = "BBudgetLinkCommitment"}>
end. /* not if viBBudgetLinkCommitBQBudComID = 0 or viBBudgetLinkCommitBQBudComID = ? */
/* api call */
<M-21 run ApiCreateBudgetLinkCommit (input tNewBudgetLinkCommitFromBQ (tNewBudgetLinkCommit),
output viFcReturnSuper (oiReturnStatus)) in BBudgetLinkCommitment>
/* Close instance*/
<I-19 {bFcCloseInstance
&CLASS = "BBudgetLinkCommitment"}>
if viLocalReturnStatus <> 0
then do :
assign oiReturnStatus = viLocalReturnStatus.
if oiReturnStatus < 0 then return.
end. /* if viLocalReturnStatus <> 0 */
/* ================================================================ */
/* Set Return-status = OK */
/* ================================================================ */
if oiReturnStatus = -98
then assign oiReturnStatus = 0.