project QadFinancials > class BBudget > method BudgetWBSDelete

Description

This method will remove a single budgetWBS-record and all its descendants (set ts_status = D) and all related BudgetVersionFigure records. This is done based on the input information.
It will also return temp-tables that contain the records that are marked for deletion.


Parameters


icBudgetTcRowidinputcharacterBudgetTcRowid
icBudgetWBSTcRowidinputcharacterBudgetWBSTcRowid
tNewBudgetWBSoutputtemp-tableTemp-table containing the BudgetWBS-records wherefor the status has been set to "D":U.
tNewBudgetVersionFigureoutputtemp-tableTemp-table containing the BudgetVersionFigure-records wherefor the status has been set to "D":U.
tNewBudgetVersionGLFigoutputtemp-tableTemp-table containing the BudgetVersionGLFig-records wherefor the status has been set to "D":U.
tNewBudgetWBSBusComponentoutputtemp-tableTemp-table containing the BudgetWBSBusComp-records wherefor the status has been set to "D":U
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program6/bbudget.p)

/* ========================================================================== */
    /* Validate input parameters                                                  */
    /* ========================================================================== */
    if icBudgetTcRowid = ? then assign icBudgetTcRowid = "":U.
    if icBudgetWBSTcRowid = ? then assign icBudgetWBSTcRowid = "":U.
    if icBudgetTcRowid = "":U 
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-9'You must enter the budget identification (row ID) to delete budget topics.':255(672)t-9#).
        <M-3 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-482':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if icBudgetTcRowid  = ?  */
    else do :
        find tBudget where 
             tBudget.tc_Rowid   = icBudgetTcRowid and 
             tBudget.tc_Status <> "D":U
             no-lock no-error.
        if not available tBudget
        then do :
            assign oiReturnStatus = -3
                   vcMessage      = trim(substitute(#T-10'Cannot find the budget based on its row ID (&1).':255(448)t-10#,string(icBudgetTcRowid))).
            <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-484':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if not available tBudget */
    end. /* not if icBudgetTcRowid  = ? */
    if icBudgetWBSTcRowid = "":U 
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-11'You must enter the budget topic identification (row ID) to delete budget topics.':255(673)t-11#).
        <M-4 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-483':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if icBudgetWBSTcRowid = "":U */
    else do :
        find tBudgetWBS where 
             tBudgetWBS.tc_ParentRowid  = tBudget.tc_Rowid   and 
             tBudgetWBS.tc_Rowid        = icBudgetWBSTcRowid and 
             tBudgetWBS.tc_Status      <> "D":U
             no-lock no-error.
        if not available tBudgetWBS
        then do :
            assign oiReturnStatus = -3
                   vcMessage      = trim(substitute(#T-12'Cannot find the current budget WBS topic based on its row ID &1.':255(450)t-12#,string(icBudgetWBSTcRowid))).
            <M-6 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-485':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if not available tBudgetWBS */
    end. /* if icBudgetWBSTcRowid = "":U */
    
    /* ==================================================== */
    /* No action allowed if the budget is not yet validated */
    /* ==================================================== */
    if tBudget.BudgetStatus = {&BUDGETSTATUS-INITIAL}
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-13'You must validate the budget structure before maintaining the WBS.':255(451)t-13#).
        <M-8 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-495':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* tBudget.BudgetStatus = {&BUDGETSTATUS-INITIAL} */
    
    /* ========================================================================== */
    /* Reset the output temp-table                                                */
    /* ========================================================================== */
    empty temp-table tNewBudgetWBS.
    empty temp-table tNewBudgetVersionFigure.
    empty temp-table tNewBudgetVersionGLFig.
    empty temp-table tNewBudgetWBSBusComponent.
    
    /* ==================================================================== */
    /* Mark the corresponding VersionFigure-records for deletion            */
    /* Mark the corresponding VersionGLFig-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-7 run BudgetWBSDeleteChilds (input  tBudget.tc_Rowid (icBudgetTcRowid), 
                                input  viBudgetWBSID (iiBudgetWBSID), 
                                output viFcReturnSuper (oiReturnStatus)) in BBudget>
    if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
    if oiReturnStatus < 0 then return.