project QadFinancials > class BBudget > method BudgetWBSUpdateSAFChilds
Description
This submethod of BudgetWBSUpdate and BudgetWBSUpdateFDSLink will update the SafStructure properties all underlaying records in case the safstructure is changed.
The modified records can be found in table tNewMBudgetWBS; the main caller should empty this table before calling this method.
Note: be carefull when updating this method as this is a RECURSIVE method.
Parameters
icBudgetTcRowid | input | character | BudgetTcRowid |
iiParentBudgetWBSID | input | integer | ParentBudgetWBSID |
icSafStructureCode | input | character | SafStructureCode |
iiSafStructureLevel | input | integer | SafStrureLevel |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bbudget.p)
/* ========================================================================================= */
/* If the SafStructureCode has been changed for a SAF-node then we call this method that */
/* updates SafStructureCode and SafConceptCode for the underlaying nodes and reset fields */
/* BudgetWBSFDSFromCode, BudgetWBSFDSToCode, BudgetWBSFDSCode, BudgetWBSFDSList and */
/* BudgetWBSFDSDefault. We will also return the updated records to the caller of this method */
/* ========================================================================================= */
/* ============================================================================= */
/* Get the SafConcept of the correct level out of the SafStructure for SAF-nodes */
/* ============================================================================= */
assign vcUpdRecordSafConceptCode = "":U
viUpdRecordSafConceptID = 0
vcUpdRecordSafStructureCode = "":U
viUpdRecordSafStructureID = 0.
if can-find (first bBudgetWBS where
bBudgetWBS.tc_ParentRowid = icBudgetTcRowid and
bBudgetWBS.ParentBudgetWBS_ID = iiParentBudgetWBSID and
bBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-SAF} and
bBudgetWBS.tc_Status <> "D":U)
then do :
<Q-4 run SafConceptCodeByLine (all) (Read) (NoCache)
(input ?, (SafStructure_ID)
input iiSafStructureLevel, (SafStructureLineNumber)
input icSafStructureCode, (SafStructureCode)
output dataset tqSafConceptCodeByLine) in BSafStructure >
find first tqSafConceptCodeByLine where
tqSafConceptCodeByLine.tcSafStructureCode = icSafStructureCode and
tqSafConceptCodeByLine.tiSafStructureLineNumber = iiSafStructureLevel
no-lock no-error.
if not available tqSafConceptCodeByLine
then do :
assign oiReturnStatus = -3
vcMessage = trim(substitute(#T-6'The system cannot determine the SAF concept number &2 for the SAF structure ID &1 passed for the WBS topic.':255(604)t-6#,string(icSafStructureCode),string(iiSafStructureLevel))).
<M-5 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'QADFIN-1134':U (icFcMsgNumber),
input '' (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
Return.
end. /* if not av. tqSafConceptCodeByLine */
assign vcUpdRecordSafConceptCode = tqSafConceptCodeByLine.tcSafConceptCode
viUpdRecordSafConceptID = tqSafConceptCodeByLine.tiSafConcept_ID
vcUpdRecordSafStructureCode = tqSafConceptCodeByLine.tcSafStructureCode
viUpdRecordSafStructureID = tqSafConceptCodeByLine.tiSafStructure_ID.
end. /* if can-find */
/* ================================= */
/* Go through all childs */
/* ================================= */
for each bBudgetWBS where
bBudgetWBS.tc_ParentRowid = icBudgetTcRowid and
bBudgetWBS.ParentBudgetWBS_ID = iiParentBudgetWBSID and
bBudgetWBS.tc_Status <> "D":U:
/* ==================================================== */
/* Actions for type SAF (eliminate TOTALS in this part) */
/* ==================================================== */
if bBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-SAF} and
vcUpdRecordSafConceptCode <> "":U and
viUpdRecordSafConceptID <> 0 and
vcUpdRecordSafStructureCode <> "":U and
viUpdRecordSafStructureID <> 0
then do :
/* ============================================================================= */
/* Check for a changed SafStructure of SafConcept */
/* If changes, then clear the dependant field and create a tNewMBudgetWBS record */
/* ============================================================================= */
if bBudgetWBS.tcSafConceptCode <> vcUpdRecordSafConceptCode or
bBudgetWBS.SafConcept_ID <> viUpdRecordSafConceptID or
bBudgetWBS.tcSafStructureCode <> vcUpdRecordSafStructureCode or
bBudgetWBS.SafStructure_ID <> viUpdRecordSafStructureID
then do :
assign bBudgetWBS.tc_Status = (if bBudgetWBS.tc_Status = "":U then "C":U else bBudgetWBS.tc_Status)
bBudgetWBS.tcSafConceptCode = vcUpdRecordSafConceptCode
bBudgetWBS.SafConcept_ID = viUpdRecordSafConceptID
bBudgetWBS.tcSafStructureCode = vcUpdRecordSafStructureCode
bBudgetWBS.SafStructure_ID = viUpdRecordSafStructureID
bBudgetWBS.BudgetWBSFDSCode = "":U
bBudgetWBS.BudgetWBSFDSFromCode = "":U
bBudgetWBS.BudgetWBSFDSToCode = "":U
bBudgetWBS.BudgetWBSFDSList = "":U
bBudgetWBS.BudgetWBSFDSDefault = "":U.
create tNewMBudgetWBS.
buffer-copy bBudgetWBS except BudgetWBSSeq to tNewMBudgetWBS.
end. /* if bBudgetWBS.tcSafConceptCode <> vcUpdRecordSafConceptCode or */
end. /* if bBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-SAF} and */
/* ================================== */
/* Recursively call this method again */
/* ================================== */
<M-1 run BudgetWBSUpdateSAFChilds (input icBudgetTcRowid (icBudgetTcRowid),
input bBudgetWBS.BudgetWBS_ID (iiParentBudgetWBSID),
input icSafStructureCode (icSafStructureCode),
input (if bBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-SAF} then iiSafStructureLevel + 1 else iisafStructureLevel) (iiSafStructureLevel),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
end. /* for each */