project QadFinancials > class BBudget > method BudgetWBSDeleteChilds
Description
This recursive method will remove all child records for a BudgetWBS-record (and its tBudgetVersionFigures)
Parameters
icBudgetTcRowid | input | character | BudgetTcRowid |
iiBudgetWBSID | input | integer | BudgetWBSID |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program6/bbudget.p)
/* ========================= */
/* Set default return status */
/* ========================= */
assign oiReturnStatus = -98.
/* ================================================================================= */
/* Go through all child of the node, marks these childs as deleted, mark all linked */
/* BudgetVersionFigures as deleted and run this method recusively for each of these */
/* childs. Note that for every reocrd that gets marked as deleted, we will also */
/* create a similar record in the output temp-tables */
/* ================================================================================= */
for each tBudgetWBS where
tBudgetWBS.tc_ParentRowid = icBudgetTcRowid and
tBudgetWBS.ParentBudgetWBS_ID = iiBudgetWBSID and
tBudgetWBS.tc_Status <> "D":U:
/* ==================================================================== */
/* Mark the corresponding VersionFigure-records for deletion */
/* Create a corresponding output record an mark it for deletion as well */
/* ==================================================================== */
for each tBudgetVersion where
tBudgetVersion.tc_ParentRowid = tBudget.tc_Rowid and
tBudgetVersion.tc_Status <> "D":U :
for each tBudgetVersionFig where
tBudgetVersionFig.tc_ParentRowid = tBudgetVersion.tc_Rowid and
tBudgetVersionFig.BudgetWBS_ID = tBudgetWBS.BudgetWBS_ID and
tBudgetVersionFig.tc_Status <> "D":U :
if tBudgetVersionFig.tc_Status <> "N":U
then do :
assign tBudgetVersionFig.tc_Status = "D":U.
create tNewBudgetVersionFigure.
buffer-copy tBudgetVersionFig to tNewBudgetVersionFigure.
end. /* if tBudgetVersionFig.tc_Status <> "N":U */
else delete tBudgetVersionFig.
end. /* for each tBudgetVersionFig where */
for each tBudgetVersionGLFig where
tBudgetVersionGLFig.tc_ParentRowid = tBudgetVersion.tc_Rowid and
tBudgetVersionGLFig.BudgetWBS_ID = tBudgetWBS.BudgetWBS_ID and
tBudgetVersionGLFig.tc_Status <> "D":U :
if tBudgetVersionGLFig.tc_Status <> "N":U
then do :
assign tBudgetVersionGLFig.tc_Status = "D":U.
create tNewBudgetVersionGLFig.
buffer-copy tBudgetVersionGLFig to tNewBudgetVersionGLFig.
end. /* if tBudgetVersionGLFig.tc_Status <> N */
else delete tBudgetVersionGLFig.
end. /* for each tBudgetVersionFig where */
end. /* for each tBudgetVersion, each tBudgetVersionFig of tBudgetVersion */
/* ============================================================ */
/* Mark the BudgetWBS-record for deletetion and create a */
/* corresponding output record an mark it for deletion as well */
/* ============================================================ */
assign viBudgetWBSID = tBudgetWBS.BudgetWBS_ID.
if tBudgetWBS.tc_Status <> "N":U
then do :
assign tBudgetWBS.tc_Status = "D":U.
create tNewBudgetWBS.
buffer-copy tBudgetWBS except BudgetWBSSeq to tNewBudgetWBS.
end.
else delete tBudgetWBS.
/* ====================================================================================== */
/* Call a recursive method that removes all child records (and its tBudgetVersionFigs) */
/* ====================================================================================== */
<M-1 run BudgetWBSDeleteChilds (input icBudgetTcRowid (icBudgetTcRowid),
input viBudgetWBSID (iiBudgetWBSID),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
if viFcReturnSuper <> 0
then do :
assign oiReturnStatus = viFcReturnSuper.
if oiReturnStatus < 0 then return.
end. /* if viFcReturnSuper <> 0 */
end. /* for each tBudgetWBS where */
/* ========================= */
/* Set return status = OK */
/* ========================= */
assign oiReturnStatus = 0.