project QadFinancials > class BBudget > method CheckBudgetFDSWBS

Description

This method is an instance-less method that will check the use of the FDS elements in the WBS structure


Parameters


icFDSTypeinputcharacterFDSType
iiNewFDSIDinputintegerFDSID
icNewFDSCodeinputcharacterNewFDSCode (can be gl, division, project, costcentre or budgetgroup code)
iiOldFDSIDinputintegerOldFDSID
icOldFDSCodeinputcharacterOldFDSCode
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCostCentre.ValidateComponent
method BDivision.ValidateComponent
method BGL.ValDisabledFields
method BProject.ValidateComponent
method BSaf.ValidateComponent


program code (program9/bbudget.p)

/* this is an instance-less method ,because these method is only used for validation     */
/* the code fields contain the codes of gl/div/cc/prj/saf                                */
/* the id contains the id of the budgetgroupcode used on the maintance of previous codes */

/* ================================================================================ */
/* We will only treat Operational budgets, and don't take the company into account  */
/* ================================================================================ */
<Q-18 run BudgetByBudgetIDCodeStatus (all) (Read) (NoCache)
          (input 0, (BudgetID)
           input ?, (BudgetCode)
           input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus)
           input 0, (CompanyId)
           input ?, (ProjectCode)
           input ?, (CostCentreCode)
           input ?, (BudgetIsCheckActualOnLine)
           input ?, (BudgetIsCheckCommitOnLine)
           input ?, (BudgetIsAutoRollUp)
           input ?, (ProjectID)
           input ?, (CostCentreID)
           input ?, (BudgetType)
           output dataset tqBudgetByBudgetIDCodeStatus) in BBudget >

assign vcBudgetCode = "":U.

/* first check if the code field isn't changed , when it isn't all FDStypes must be read */
if icOldFDSCode = icNewFDSCode
then assign icFDSType = "":U.

for each tqBudgetByBudgetIDCodeStatus:
    /* We first check if the FDSType is used in the budget, check BudgetFDS */
    /* if it isn't we take the next budget */
    
    <Q-19 run BudgetFDSByBudgetIDType (all) (Read) (NoCache)
          (input tqBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID)
           input icFDSType, (BudgetFDSType)
           input ?, (BudgetFDSID)
           output dataset tqBudgetFDSByBudgetIDType) in BBudget >
    if not can-find(first tqBudgetFDSByBudgetIDType)
    then next.

    for each tqBudgetFDSByBudgetIDType:
        /* We will check BudgetWBS with the information of BudgetFDS only these with the correct FDSType */
        <Q-20 run BudgetWBSByAll (all) (Read) (NoCache)
          (input tqBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID)
           input 0, (BudgetWBSID)
           input ?, (BudgetWBSCode)
           input 0, (ParentBudgetWBSID)
           input ?, (BudgetFDSType)
           input 0, (SafStructureID)
           input 0, (SafConceptID)
           input tqBudgetFDSByBudgetIDType.tiBudgetFDS_ID, (BudgetFDSID)
           output dataset tqBudgetWBSByAll) in BBudget >

        for each tqBudgetWBSByAll:
            /* the actual compare */
            /* code */
            if icFDSType <> "":U
            then do:
                if tqBudgetWBSByAll.tcBudgetWBSFDSCode <> "":U and
                   tqBudgetWBSByAll.tcBudgetWBSFDSCode <> ?
                then do:
                    if index(tqBudgetWBSByAll.tcBudgetWBSFDSCode,"*":U) <> 0
                    then do:
                        /* Matches WBS Code with "*" */
                        if icOldFDSCode matches tqBudgetWBSByAll.tcBudgetWBSFDSCode or
                           icNewFDSCode matches tqBudgetWBSByAll.tcBudgetWBSFDSCode
                        then assign vcBudgetCode = vcBudgetCode + tqBudgetByBudgetIDCodeStatus.tcBudgetCode + ",":u.
                    end.
                    else do:
                        /* equals no "*" */ 
                        if icOldFDSCode = tqBudgetWBSByAll.tcBudgetWBSFDSCode or 
                           icNewFDSCode = tqBudgetWBSByAll.tcBudgetWBSFDSCode
                        then assign vcBudgetCode = vcBudgetCode + tqBudgetByBudgetIDCodeStatus.tcBudgetCode + ",":u.
                    end.
                end. /* code */
                /* code range */
                else do:
                    if tqBudgetWBSByAll.tcBudgetWBSFDSFromCode <> "":U and 
                       tqBudgetWBSByAll.tcBudgetWBSFDSFromCode <> ?    and 
                       tqBudgetWBSByAll.tcBudgetWBSFDSToCode   <> "":U and 
                       tqBudgetWBSByAll.tcBudgetWBSFDSToCode   <> ?    
                    then do: 
                        if (tqBudgetWBSByAll.tcBudgetWBSFDSFromCode >= icOldFDSCode and
                            tqBudgetWBSByAll.tcBudgetWBSFDSToCode   <= icOldFDSCode)      or
                           (tqBudgetWBSByAll.tcBudgetWBSFDSFromCode >= icNewFDSCode and
                            tqBudgetWBSByAll.tcBudgetWBSFDSToCode   <= icNewFDSCode)
                        then assign vcBudgetCode = vcBudgetCode + tqBudgetByBudgetIDCodeStatus.tcBudgetCode + ",":u.
                    end.
                    /* code list */
                    else do:
                        if tqBudgetWBSByAll.tcBudgetWBSFDSList <> "":U and 
                           tqBudgetWBSByAll.tcBudgetWBSFDSList <> ?   
                        then do:
                            if lookup(icOldFDSCode,tqBudgetWBSByAll.tcBudgetWBSFDSList) <> 0 or
                               lookup(icNewFDSCode,tqBudgetWBSByAll.tcBudgetWBSFDSList) <> 0
                            then assign vcBudgetCode = vcBudgetCode + tqBudgetByBudgetIDCodeStatus.tcBudgetCode + ",":u.
                        end.
                    end. /* code list */
                end. /* code range */
            end. /* if icFDSType <> "":U */
            
            /* if still no hit than check the budgetgroupcode */
            if vcBudgetCode = "":U
            then do:
                /* BudgetGroup (BudgetGroupID)    */
                if tqBudgetWBSByAll.tiBudgetGroup_ID <> 0
                then do:
                    if iiOldFDSID <> iiNewFDSID and
                       (tqBudgetWBSByAll.tiBudgetGroup_ID = iiOldFDSID or
                        tqBudgetWBSByAll.tiBudgetGroup_ID = iiNewFDSID)
                    then assign vcBudgetCode = vcBudgetCode + tqBudgetByBudgetIDCodeStatus.tcBudgetCode + ",":u.
                end.  /* tqBudgetWBSByAll.tiBudgetGroup_ID <> 0 */
            end. /* budget group */
        end. /* fe tqBudgetWBSByAll  */
    end. /* fe tqBudgetFDSByBudgetIDType */
end. /* fe tqBudgetByBudgetIDCodeStatus  */

/* check if w've had a hit */
if num-entries(vcBudgetCode) - 1 > 0
then do:
    case icFDSType:
        when {&BUDGETFDSTYPE-GL}         then assign vcFDSTypeTrans = {&BUDGETFDSTYPE-GL-TR}.
        when {&BUDGETFDSTYPE-DIVISION}   then assign vcFDSTypeTrans = {&BUDGETFDSTYPE-DIVISION-TR}.
        when {&BUDGETFDSTYPE-PROJECT}    then assign vcFDSTypeTrans = {&BUDGETFDSTYPE-PROJECT-TR}.
        when {&BUDGETFDSTYPE-COSTCENTRE} then assign vcFDSTypeTrans = {&BUDGETFDSTYPE-COSTCENTRE-TR}.
        when {&BUDGETFDSTYPE-SAF}        then assign vcFDSTypeTrans = {&BUDGETFDSTYPE-SAF-TR}.
        otherwise                             assign vcFDSTypeTrans = #T-27'Budget Group':30(565)t-27#.
    end case.

    assign vcMessage  = (if icFDSType <> "":U
                         then trim(substitute(#T-28'COA type &1: &2 has been updated to &3 and has been used in budgets (&4).':255(566)T-28#,
                                              vcFDSTypeTrans,
                                              icOldFDSCode,
                                              icNewFDSCode,
                                              vcBudgetCode)) + chr(10) +
                              trim(#T-29'As this may lead to inconsistent budget figures, you might need to rebuild the budget.':255(567)T-29#)
                         else trim(substitute(#T-30'The budget group code has been updated and has been used in budgets (&1).':255(568)T-30#,
                                              vcBudgetCode)) + chr(10) +
                              trim(#T-31'As this may lead to inconsistent budget figures, you might need to rebuild the budget.':255(567)T-31#))
           oiReturnStatus = 1.
    <M-26 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'W':U (icType),
                     input  4 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-1938':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>

end.