iiBudgetID | input | integer | Budget ID |
icBudgetCode | input | character | BudgetCode |
iiProjectID | input | integer | ProjectID; when a value is passed for this parameter then the parameters iiBudgetID and icBudgetCode are disgarded. The budget of the project will then be used. |
icProjectCode | input | character | ProjectCode: only applied in case ProjectID is empty |
iiCostCentreID | input | integer | CostCentreID; when a value is passed for this parameter then the parameters iiBudgetID and icBudgetCode are disgarded. The operational budget of the cost-centre will then be used. |
icCostCentreCode | input | character | CostCentreCode: only applied in case CostCentreID is not filled |
biBudgetVersionID | input-output | integer | BudgetVersionID; if this parameter is used then parameter BudgetVersionCode is disregarded |
icBudgetVersionCode | input | character | BudgetVersionCode; if parameter BudgetVersionID is used then this parameter is disregarded |
ilSkipLevelOneNodes | input | logical | SkipLevelOnNodes |
ilSkipJointOperResNodes | input | logical | SkipJointOperResNodes |
ilSkipOverheadNodes | input | logical | SkipOverheadNodes |
ilSkipDraftNodes | input | logical | SkipDraftNodes |
ilSkipPureRevenueNodes | input | logical | SkipPureRevenueNodes |
ilSkipPureCostNodes | input | logical | SkipPureCostNodes |
icRestrictedBusComponent | input | character | RestrictedBusComponent; Code of the business-component that will be used to restrict the selectable nodes. |
tViewBudgetWBS | output | temp-table | Table containing the WBS |
tViewBudgetWBSFigures | output | temp-table | Table containing the Figures of a WBS-topic |
tViewBudgetVersion | output | temp-table | Temp-table containing the budgetversions of a budget. This will only be filled in case iiBudgetVersion and BudgetVersionCode is empty. |
oiBudgetID | output | integer | Budget ID |
oiReturnStatus | output | integer | Return status of the method. |
/* ============================== */ /* Clear the instance-less output */ /* ============================== */ empty temp-table tViewBudgetWBS. empty temp-table tViewBudgetWBSFigures. empty temp-table tViewBudgetVersion. /* ======================================================= */ /* State the budget based on the project or CC when filled */ /* ======================================================= */ if iiProjectID = ? then assign iiProjectID = 0. if icProjectCode = ? then assign icProjectCode = "":U. if iiProjectID <> 0 or (icProjectCode <> "":U and icProjectCode <> ?) then do : if iiProjectID = 0 and icProjectCode <> "":U then do: <Q-36 run ProjectPrim (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input ?, (ProjectID) input icProjectCode, (ProjectCode) output dataset tqProjectPrim) in BProject > find first tqProjectPrim no-error. assign iiProjectID = if AVAILAble tqProjectPrim then tqProjectPrim.tiProject_ID else 0. end. <Q-19 run BudgetByProjectCostCentre (all) (Read) (NoCache) (input ?, (CompanyId) input ?, (CostCentreCode) input ?, (CostCentreID) input (if iiProjectID = 0 then icProjectCode else ?), (ProjectCode) input iiProjectID, (ProjectID) input ?, (RowidToSkip) input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus) output dataset tqBudgetByProjectCostCentre) in BBudget > if iiProjectID = 0 then find first tqBudgetByProjectCostCentre where tqBudgetByProjectCostCentre.tcProjectCode = icProjectCode no-lock no-error. else find first tqBudgetByProjectCostCentre where tqBudgetByProjectCostCentre.tiProject_ID = iiProjectID no-lock no-error. if available tqBudgetByProjectCostCentre then assign iiBudgetID = tqBudgetByProjectCostCentre.tiBudget_ID. else return. end. /* if iiProjectID <> 0 and */ if iiCostCentreID = ? then assign iiCostCentreID = 0. if icCostCentreCode = ? then assign icCostCentreCode = "":U. if iiCostCentreID <> 0 or (icCostCentreCode <> "":U and icCostCentreCode <> ?) then do : if iiCostCentreID = 0 and icCostCentreCode <> "":U then do: <Q-37 run CostCentrePrim (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input ?, (CostCentreID) input icCostCentreCode, (CostCentreCode) output dataset tqCostCentrePrim) in BCostCentre > find first tqCostCentrePrim no-error. assign iiCostCentreID = if available tqCostCentrePrim then tqCostCentrePrim.tiCostCentre_ID else 0. end. <Q-20 run BudgetByProjectCostCentre (all) (Read) (NoCache) (input ?, (CompanyId) input (if iiCostCentreID = 0 then icCostCentreCode else ?), (CostCentreCode) input iiCostCentreID, (CostCentreID) input ?, (ProjectCode) input ?, (ProjectID) input ?, (RowidToSkip) input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus) output dataset tqBudgetByProjectCostCentre) in BBudget > if iiCostCentreID = 0 then find first tqBudgetByProjectCostCentre where tqBudgetByProjectCostCentre.tcCostCentreCode = icCostCentreCode no-lock no-error. else find first tqBudgetByProjectCostCentre where tqBudgetByProjectCostCentre.tiCostCentre_ID = iiCostCentreID no-lock no-error. if available tqBudgetByProjectCostCentre then assign iiBudgetID = tqBudgetByProjectCostCentre.tiBudget_ID. else return. end. /* if iiCostCentreID <> 0 and */ /* =============================================== */ /* Validate input parameters // clear output table */ /* Convert the Code into the ID when needed */ /* =============================================== */ if (iiBudgetID = 0 or iiBudgetID = ?) and (icBudgetCode = "":U or icBudgetCode = ?) then do : assign oiReturnStatus = -3 vcMessage = trim(#T-33'You must enter the budget identification (ID/code) to retrieve the budget WBS information.':255(442)T-33#). <M-9 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-1247':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. if iiBudgetID = 0 or iiBudgetID = ? then do : <Q-10 run BudgetPrim (all) (Read) (NoCache) (input ?, (BudgetID) input icBudgetCode, (BudgetCode) output dataset tqBudgetPrim) in BBudget > find first tqBudgetPrim no-lock no-error. if not available tqBudgetPrim then return. assign iiBudgetID = tqBudgetPrim.tiBudget_ID. end. /* if iiBudgetID = 0 or iiBudgetID = ? */ /* =================================================================================== */ /* if no version-data is provided then call method ApiGetBudgetWBSWithFiguresVersions; */ /* This sub-method of ApiGetBudgetWBSWithFigures will return the ID of the active */ /* budget-version and a list with all versions of the budget (multiple properties) */ /* =================================================================================== */ if (biBudgetVersionID = 0 or biBudgetVersionID = ?) and (icBudgetVersionCode = "":U or icBudgetVersionCode = ?) then do : <Q-22 run BudgetVersionByBudgetIDStat (all) (Read) (NoCache) (input iiBudgetID, (BudgetID) input ?, (BudgetVersionID) input ?, (BudgetVersionIsActive) output dataset tqBudgetVersionByBudgetIDStat) in BBudget > for each tqBudgetVersionByBudgetIDStat no-lock : create tViewBudgetVersion. assign tViewBudgetVersion.tiBudgetID = iiBudgetID tViewBudgetVersion.tiBudgetVersionID = tqBudgetVersionByBudgetIDStat.tiBudgetVersion_ID tViewBudgetVersion.tiReportPeriodYear = (if tqBudgetVersionByBudgetIDStat.tiReportPeriodYear = ? then 0 else tqBudgetVersionByBudgetIDStat.tiReportPeriodYear) tViewBudgetVersion.tiReportPeriodPeriod = (if tqBudgetVersionByBudgetIDStat.tiReportPeriodPeriod = ? then 0 else tqBudgetVersionByBudgetIDStat.tiReportPeriodPeriod) tViewBudgetVersion.tcBudgetVersionCode = tqBudgetVersionByBudgetIDStat.tcBudgetVersionCode tViewBudgetVersion.tlBudgetVersionIsActive = tqBudgetVersionByBudgetIDStat.tlBudgetVersionIsActive. if tqBudgetVersionByBudgetIDStat.tlBudgetVersionIsActive = true then assign biBudgetVersionID = tqBudgetVersionByBudgetIDStat.tiBudgetVersion_ID. if vtBudgetVersionCreateDateLast = ? or vtBudgetVersionCreateDateLast < tqBudgetVersionByBudgetIDStat.ttBudgetVersionCreateDate then assign vtBudgetVersionCreateDateLast = tqBudgetVersionByBudgetIDStat.ttBudgetVersionCreateDate. end. /* for each tqBudgetVersionByBudgetIDStat no-lock */ if (biBudgetVersionID = 0 or biBudgetVersionID = ?) then do : find tqBudgetVersionByBudgetIDStat where tqBudgetVersionByBudgetIDStat.ttBudgetVersionCreateDate = vtBudgetVersionCreateDateLast no-lock no-error. if available tqBudgetVersionByBudgetIDStat then assign biBudgetVersionID = tqBudgetVersionByBudgetIDStat.tiBudgetVersion_ID. end. /* if (biBudgetVersionID = 0 or biBudgetVersionID = ?) */ end. /* if (biBudgetVersionID = 0 or biBudgetVersionID = ?) and */ /* =============================================== */ /* Validate input parameters // clear output table */ /* Convert the Code into the ID when needed */ /* =============================================== */ if (biBudgetVersionID = 0 or biBudgetVersionID = ?) and icBudgetVersionCode <> "":U and icBudgetVersionCode <> ? then do : <Q-12 run BudgetVersionPrim (all) (Read) (NoCache) (input iiBudgetID, (BudgetID) input icBudgetVersionCode, (BudgetVersionCode) input ?, (BudgetVersionID) output dataset tqBudgetVersionPrim) in BBudget > find first tqBudgetVersionPrim no-lock no-error. if not available tqBudgetVersionPrim then do : assign oiReturnStatus = -3 vcMessage = trim(substitute(#T-34'Invalid budget version code: &1.':255(628)T-34#,string(icBudgetVersionCode))). <M-13 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-1249':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if not available tqBudgetVersionPrim */ assign biBudgetVersionID = tqBudgetVersionPrim.tiBudgetVersion_ID. end. /* if biBudgetVersionID = 0 or biBudgetVersionID = ? */ if (biBudgetVersionID = 0 or biBudgetVersionID = ?) and (icBudgetVersionCode = "":U or icBudgetVersionCode = ?) then do : assign oiReturnStatus = -3 vcMessage = trim(#T-35'You must enter the budget version identification (ID/code) to retrieve the budget WBS figures.':255(629)T-35#). <M-23 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-1321':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if (biBudgetVersionID = 0 or biBudgetVersionID = ?) and */ /* ====================================================================================== */ /* Call method that fills the budgetwbs of the budget. Parameter 'ilSkipLevelOneNodes' is */ /* always assigned false because this can only be handled after all figures are retrieved */ /* ====================================================================================== */ <M-11 run ApiGetBudgetWBS (input iiBudgetID (iiBudgetID), input ? (icBudgetCode), input 0 (iiProjectID), input ? (icProjectCode), input 0 (iiCostCentreID), input ? (icCostCentreCode), input false (ilSkipLevelOneNodes), input false (ilSkipJointOperResNodes), input false (ilSkipOverheadNodes), input false (ilSkipDraftNodes), input false (ilSkipPureRevenueNodes), input false (ilSkipPureCostNodes), input icRestrictedBusComponent (icRestrictedBusComponent), input false (ilAssignBudgetWBSIsSelectable), output tViewBudgetWBS (tViewBudgetWBS), output oiBudgetID (oiBudgetID), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. if not can-find (first tViewBudgetWBS) then return. /* =============================================================================================== */ /* Call method that creates tViewBudgetWBSFigures record and that assigns the budget-figures in it */ /* =============================================================================================== */ <M-27 run ApiGetBudgetWBSWithFiguresBudgetFig (input iiBudgetID (iiBudgetID), input biBudgetVersionID (iiBudgetVersionID), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. /* ============================================================================== */ /* If ilSkipDraftNodes or ilSkipJointOperResNodes or ilSkipOverheadNodes is true, */ /* then delete some tqBudgetWBSByBudgetID-records */ /* ============================================================================== */ if ilSkipDraftNodes = true or ilSkipJointOperResNodes = true or ilSkipOverheadNodes = true then do : <M-28 run ApiGetBudgetWBSDelete (input ilSkipJointOperResNodes (ilSkipJointOperResNodes), input ilSkipOverheadNodes (ilSkipOverheadNodes), input ilSkipDraftNodes (ilSkipDraftNodes), input ilSkipPureRevenueNodes (ilSkipPureRevenueNodes), input ilSkipPureCostNodes (ilSkipPureCostNodes), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. end. /* if ilSkipDraftNodes = true or */ /* =============================================================================================== */ /* Call method that assigns the Actual/commitment-figures in tViewBudgetWBSFigures */ /* =============================================================================================== */ <M-29 run ApiGetBudgetWBSWithFiguresActualFig (input iiBudgetID (iiBudgetID), input biBudgetVersionID (iiBudgetVersionID), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. /* =============================================================================================== */ /* Call Submethod that will Rollup the Commitments and the Actuals in table tViewBudgetWBSFigures */ /* Involved fields; tdCommitCostTC, tdCommitQTY, tdActualRevenueTC, tdActualCostTC and tdActualQTY */ /* After Rolling up these fields we can assign the calculated fields: tdActualMarginTC, */ /* tdActualPercentage, tdCompletionPercentage and tdProductionTC. */ /* =============================================================================================== */ <M-30 run ApiGetBudgetWBSWithFiguresRollUp (input iiBudgetID (iiBudgetID), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. /* =========================================================================== */ /* If ilSkipLevelOneNodes = true the */ /* - Remove all nodes on FDS-level 1 */ /* - Set for the nodes on FDS-level 2 ParentBudgetWBSID = ? */ /* - Join nodes on FDS-level 2 that have the same name (just keep 1 of them */ /* but move the childs of the removed nodes into the 1 node that is kept) */ /* =========================================================================== */ if ilSkipLevelOneNodes = true then do : <M-25 run ApiGetBudgetWBSDeleteLevelOne (output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. end. /* if ilSkipLevelOneNodes = true */ /* ================================================================================ */ /* Call Submethod that will assign the calculated fields: */ /* tdActualMarginTC, tdActualPercentage, tdCompletionPercentage and tdProductionTC */ /* tdBudgetMarginTC, tdBudgetRevenueTC, tdPMMarginTC, tdPMPercentage, */ /* tdControlMarginTC, tdControlRevenueTC */ /* ================================================================================ */ <M-32 run ApiGetBudgetWBSWithFiguresCalculate (input iiBudgetID (iiBudgetID), input biBudgetVersionID (iiBudgetVersionID), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if oiReturnStatus < 0 then return. /* ========================== */ /* Clear query-table contents */ /* ========================== */ empty temp-table tqBudgetByProjectCostCentre. empty temp-table tqBudgetPrim. empty temp-table tqBudgetVersionByBudgetIDStat. empty temp-table tqBudgetVersionPrim.