tBudgetCheckInfo | input | temp-table | BudgetCheckInfo; instanceless temp-table that contains the information that is required to perform a budget-check (for cimmitments and for actuals) and that is also used to state the BudgetWBS topics that need to be update/created concerning the actual/cimmitment amounts |
ilOnlyHandleCommitOnlineBudgets | input | logical | HandleCommitments; For handling the figures (QBudgetLink) this should be set to true |
ilOnlyHandleActualOnlineBudgets | input | logical | HandleActuals For handling the figures (QBudgetLink) this should be set to true |
ilCalledFromBudgetCheck | input | logical | CalledFromBudgetCheck |
tBudgetCheckInfoWBS | output | temp-table | BudgetCheckInfoWBS; instanceless temp-table that contains the WBS-information based upon another table (BudgetCheckInfo) that is used to perform a budget-check (for commitments and for actuals) and that is also used to state the BudgetWBS topics that need to be update/created concerning the actual/cimmitment amounts |
oiReturnStatus | output | integer | Return status of the method. |
/* ========================= */ /* Set default Return Status */ /* ========================= */ assign oiReturnStatus = -98. /* ================================ */ /* Empty output temp-table */ /* ================================ */ empty temp-table tBudgetCheckInfoWBS. /* ================================================================================= */ /* Assign the CompanyID/ProjectID/CostCentreID in the input-table based on the Codes */ /* Remove lines with a GL that is not enabled for Budgetting */ /* ================================================================================= */ <M-64 run BudgetCheckInfoResolveCyPrjCC (output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then do : assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Return. end. /* if viFcReturnSuper <> 0 */ /* ================================================================ */ /* Read all required budgets: result = tBudgetByBudgetIDCodeStatus */ /* Return in case there are no budgets read */ /* ================================================================ */ <M-61 run BudgetCheckInfoResolveReadDB (input ilOnlyHandleCommitOnlineBudgets (ilOnlyHandleCommitOnlineBudgets), input ilOnlyHandleActualOnlineBudgets (ilOnlyHandleActualOnlineBudgets), input ilCalledFromBudgetCheck (ilCalledFromBudgetCheck), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then do : assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then Return. end. /* if viFcReturnSuper <> 0 */ if not can-find (first tBudgetByBudgetIDCodeStatus) then do : assign oiReturnStatus = 0. Return. end. /* if not can-find */ /* ============= */ /* Start queries */ /* ============= */ <M-58 run BudgetCheckInfoResolveQueryStart (output viFcReturnSuper (oiReturnStatus)) in BBudget> /* ============================ */ /* Start Block */ /* Go through all input records */ /* ============================ */ MAINBLOCKBUDGETCHECKINFO: DO : for each tBudgetCheckInfo : /* ========================================================= */ /* Call a method that will convert the ID into the Code for */ /* the SafStructure and for the SafConcepts when appropriate */ /* ========================================================= */ <M-32 run BudgetCheckInfoResolveSaf (output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then do : assign viBlockReturnStatus = viFcReturnSuper. if viBlockReturnStatus < 0 then leave MAINBLOCKBUDGETCHECKINFO. end. /* if viFcReturnSuper <> 0 */ /* ==================================================================================== */ /* In case a BudgetWBS-ID was specified we just get the information for this single WBS */ /* ==================================================================================== */ if tBudgetCheckInfo.tiBudgetWBSID <> 0 and tBudgetCheckInfo.tiBudgetWBSID <> ? and not can-find (first tBudgetByBudgetIDCodeStatus where tBudgetByBudgetIDCodeStatus.tcBudgetType = {&BUDGETTYPE-GLOBAL}) then do : /* ================== */ /* Find the BudgetWBS */ /* ================== */ <Q-17 run BudgetWBSByAll (all) (Read) (NoCache) (input ?, (BudgetID) input tBudgetCheckInfo.tiBudgetWBSID, (BudgetWBSID) input ?, (BudgetWBSCode) input ?, (ParentBudgetWBSID) input ?, (BudgetFDSType) input ?, (SafStructureID) input ?, (SafConceptID) input ?, (BudgetFDSID) output dataset tqBudgetWBSByAll) in BBudget > find first tqBudgetWBSByAll where tqBudgetWBSByAll.tiBudgetWBS_ID = tBudgetCheckInfo.tiBudgetWBSID no-lock no-error. if not available tqBudgetWBSByAll then do : assign viBlockReturnStatus = -3 vcMessage = trim(substitute(#T-53'A budget check error occurred. The system cannot find the budget WBS ID (&1) that was passed as the basis for the budget check.':255(539)t-53#,string(tBudgetCheckInfo.tiBudgetWBSID))). <M-18 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-1631':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> leave MAINBLOCKBUDGETCHECKINFO. end. /* if not available tqBudgetWBSByAll */ /* ============================================ */ /* Find the Budget, Period, Version and Company */ /* ============================================ */ find tBudgetByBudgetIDCodeStatus /* only the operational ones available */ where tBudgetByBudgetIDCodeStatus.tiBudget_ID = tqBudgetWBSByAll.tiBudget_ID no-lock no-error. if not available tBudgetByBudgetIDCodeStatus then next. <Q-19 assign vlFcQueryRecordsAvailable = BudgetCompanyByBudgetID (Cache) (input tBudgetCheckInfo.tiCompanyId, (CompanyId) input tBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID)) in BBudget > if vlFcQueryRecordsAvailable = false then next. <Q-20 run BudgetPeriodByBudgetIDDate (all) (Read) (Cache) (input tBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID) input ?, (BudgetPeriodID) input tBudgetCheckInfo.ttDate, (EnclosedDate) output dataset tqBudgetPeriodByBudgetIDDate) in BBudget > find first tqBudgetPeriodByBudgetIDDate no-lock no-error. if not available tqBudgetPeriodByBudgetIDDate then next. <Q-21 run BudgetVersionByBudgetIDStat (all) (Read) (Cache) (input tBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID) input ?, (BudgetVersionID) input true, (BudgetVersionIsActive) output dataset tqBudgetVersionByBudgetIDStat) in BBudget > find first tqBudgetVersionByBudgetIDStat no-lock no-error. if not available tqBudgetVersionByBudgetIDStat then next. /* =================================================================== */ /* Create the output temp-table record for the tBudgetCheckInfo record */ /* =================================================================== */ <M-65 run BudgetCheckInfoResolveOutput (output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then do : assign viBlockReturnStatus = viFcReturnSuper. if viBlockReturnStatus < 0 then leave MAINBLOCKBUDGETCHECKINFO. end. /* if viFcReturnSuper <> 0 */ /* ================================================================================================ */ /* Do not execute the other code for a tBudgetCheckInfo and continue with the next tBudgetCheckInfo */ /* ================================================================================================ */ next. end. /* if tBudgetCheckInfo.tiBudgetWBSID <> 0 and */ /* ================================== */ /* Go through all operational budgets */ /* ================================== */ for each tBudgetByBudgetIDCodeStatus no-lock by tBudgetByBudgetIDCodeStatus.tiBudget_ID : CHECKSINGLEBUDGETCBLOCK : DO : /* ======================================================== */ /* In case the Budget is specified, only handle that budget */ /* ======================================================== */ if tBudgetCheckInfo.tiBudgetID <> 0 and tBudgetCheckInfo.tiBudgetID <> ? and tBudgetCheckInfo.tiBudgetID <> tBudgetByBudgetIDCodeStatus.tiBudget_ID then next. /* ===================================================================== */ /* Empty the temp-table that holds the info for a single budgetCheckInfo */ /* ===================================================================== */ empty temp-table tBudgetCheckInfoWBSOneBudget. /* ================================================================ */ /* Skip project-budgets (or CC-Budgets) for another project (or CC) */ /* ================================================================ */ if tBudgetByBudgetIDCodeStatus.tiProject_ID <> ? and tBudgetByBudgetIDCodeStatus.tiProject_ID <> 0 and tBudgetByBudgetIDCodeStatus.tiProject_ID <> tBudgetCheckInfo.tiProjectID then Leave CHECKSINGLEBUDGETCBLOCK. if tBudgetByBudgetIDCodeStatus.tiCostCentre_ID <> ? and tBudgetByBudgetIDCodeStatus.tiCostCentre_ID <> 0 and tBudgetByBudgetIDCodeStatus.tiCostCentre_ID <> tBudgetCheckInfo.tiCostCentreID then Leave CHECKSINGLEBUDGETCBLOCK. /* =============================================== */ /* Check if the budget is appointed to the company */ /* =============================================== */ <Q-2 run BudgetCompanyByBudgetID (all) (Read) (Cache) (input tBudgetCheckInfo.tiCompanyId, (CompanyId) input tBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID) output dataset tqBudgetCompanyByBudgetID) in BBudget > find first tqBudgetCompanyByBudgetID no-lock no-error. if not available tqBudgetCompanyByBudgetID then do : /* =============================================================== */ /* If no company is found based on the input-cy and it concerns a */ /* project-budget then an error is raised (same for CostCentres) */ /* =============================================================== */ if ilCalledFromBudgetCheck = true and ((tBudgetByBudgetIDCodeStatus.tcProjectCode <> "":U and tBudgetByBudgetIDCodeStatus.tcProjectCode <> ? and tBudgetByBudgetIDCodeStatus.tcProjectCode = tBudgetCheckInfo.tcProjectCode) or (tBudgetByBudgetIDCodeStatus.tcCostCentreCode <> "":U and tBudgetByBudgetIDCodeStatus.tcCostCentreCode <> ? and tBudgetByBudgetIDCodeStatus.tcCostCentreCode = tBudgetCheckInfo.tcCostCentreCode)) then do : assign viBlockReturnStatus = -1 vcMessage = trim(substitute(#T-54'The system cannot find an entity link in the budget (&1) of project / cost center (&2/&3) that was linked to the input entity (&4/&5).':255(540)t-54#,tBudgetByBudgetIDCodeStatus.tcBudgetCode,tBudgetCheckInfo.tcProjectCode,tBudgetCheckInfo.tcCostCentreCode,tBudgetCheckInfo.tcCompanyCode,string(tBudgetCheckInfo.tiCompanyId))). <M-40 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-2042':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> end. /* if ilCalledFromBudgetCheck = true and */ Leave CHECKSINGLEBUDGETCBLOCK. end. /* if not available tqBudgetCompanyByBudgetID */ /* =========================== */ /* Check for a matching period */ /* =========================== */ <Q-3 run BudgetPeriodByBudgetIDDate (all) (Read) (Cache) (input tBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID) input ?, (BudgetPeriodID) input tBudgetCheckInfo.ttDate, (EnclosedDate) output dataset tqBudgetPeriodByBudgetIDDate) in BBudget > find first tqBudgetPeriodByBudgetIDDate no-lock no-error. if not available tqBudgetPeriodByBudgetIDDate then do : /* ======================================================================= */ /* If no period is found based on the transaction-date and it concerns a */ /* project-budget then an error is raised (not applicable for CostCentres) */ /* ======================================================================= */ if ilCalledFromBudgetCheck = true and tBudgetByBudgetIDCodeStatus.tcProjectCode <> "":U and tBudgetByBudgetIDCodeStatus.tcProjectCode <> ? and tBudgetCheckInfo.tcProjectCode <> "":U and tBudgetCheckInfo.tcProjectCode <> ? and tBudgetByBudgetIDCodeStatus.tcProjectCode = tBudgetCheckInfo.tcProjectCode then do : assign viBlockReturnStatus = -1 vcMessage = trim(substitute(#T-55'The system cannot find a period in budget &1 of project &2 that contains transaction date &3.':255(541)t-55#,tBudgetByBudgetIDCodeStatus.tcBudgetCode,tBudgetCheckInfo.tcProjectCode,string(tBudgetCheckInfo.ttDate))). <M-39 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-1998':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Leave CHECKSINGLEBUDGETCBLOCK. end. /* if ilCalledFromBudgetCheck = true and */ /* ============================== */ /* No period; no further checking */ /* ============================== */ Leave CHECKSINGLEBUDGETCBLOCK. end. /* if not available tqBudgetPeriodByBudgetIDDate */ /* ================================= */ /* Check for an active BudgetVersion */ /* ================================= */ <Q-4 run BudgetVersionByBudgetIDStat (all) (Read) (Cache) (input tBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID) input ?, (BudgetVersionID) input true, (BudgetVersionIsActive) output dataset tqBudgetVersionByBudgetIDStat) in BBudget > find first tqBudgetVersionByBudgetIDStat no-lock no-error. if not available tqBudgetVersionByBudgetIDStat then Leave CHECKSINGLEBUDGETCBLOCK. /* =========================================================== */ /* Get all FDSes of the Budget and Go through them */ /* Read all WBSes of the Budget and use them in the submethods */ /* =========================================================== */ assign viSafDepth = 0 viFDSDepth = 0. <Q-5 run BudgetFDSByBudgetIDType (all) (Read) (Cache) (input tBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID) input ?, (BudgetFDSType) input ?, (BudgetFDSID) output dataset tqBudgetFDSByBudgetIDType) in BBudget > if not can-find (first tBudgetWBSByAll where tBudgetWBSByAll.tiBudget_ID = tBudgetByBudgetIDCodeStatus.tiBudget_ID) then do : <Q-66 run BudgetWBSByAll (all) (Read) (NoCache) (input tBudgetByBudgetIDCodeStatus.tiBudget_ID, (BudgetID) input ?, (BudgetWBSID) input ?, (BudgetWBSCode) input ?, (ParentBudgetWBSID) input ?, (BudgetFDSType) input ?, (SafStructureID) input ?, (SafConceptID) input ?, (BudgetFDSID) output dataset tqBudgetWBSByAll) in BBudget > empty temp-table tBudgetWBSByAll. for each tqBudgetWBSByAll : create tBudgetWBSByAll. buffer-copy tqBudgetWBSByAll to tBudgetWBSByAll. end. /* or each tqBudgetWBSByAll */ empty temp-table tqBudgetWBSByAll. end. /* if not can-find */ for each tqBudgetFDSByBudgetIDType by tqBudgetFDSByBudgetIDType.tiBudgetFDSSeq : /* ======================================================================== */ /* Call a submethod that will return a set of WBS-records (tBudgetCheckWBS) */ /* that fit the FDSType, FDSSeq, ... and the FDS-value from the input */ /* ======================================================================== */ if tqBudgetFDSByBudgetIDType.tcBudgetFDSType = {&BUDGETFDSTYPE-SAF} then assign viSafDepth = viSafDepth + 1. assign viFDSDepth = viFDSDepth + 1. /* ===================================================================== */ /* Empty the temp-table that holds the info for a single budget-FDS */ /* Call a sub-methods that will create tBudgetCheckInfoWBSTemp-records */ /* Copy the temp-table that holds the info for a single budget-FDS into */ /* the temp-table that holds the info for a single budgetCheckInfo */ /* ===================================================================== */ empty temp-table tBudgetCheckInfoWBSTemp. assign vlBudgetWBSByAllNotfound = true. <M-14 run BudgetCheckInfoResolveReadWBS (input viSafDepth (iiSafDepth), output vlBudgetWBSByAllNotfound (olBudgetWBSByAllNotFound), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then do : assign viBlockReturnStatus = viFcReturnSuper. if viBlockReturnStatus < 0 then leave MAINBLOCKBUDGETCHECKINFO. end. /* if viFcReturnSuper <> 0 */ if viFDSDepth <> 1 and vlBudgetWBSByAllNotfound then leave. empty temp-table tBudgetCheckInfoWBSOneBudget. for each tBudgetCheckInfoWBSTemp : create tBudgetCheckInfoWBSOneBudget. buffer-copy tBudgetCheckInfoWBSTemp to tBudgetCheckInfoWBSOneBudget. end. /* or each tBudgetCheckInfoWBSTemp */ /* ================================================================= */ /* Leave this budget in case we have no matching WBS-records anymore */ /* ================================================================= */ if not can-find (first tBudgetCheckInfoWBSOneBudget) then next. /* Updated on 2005 may 19 by KriLae, old-code: Leave CHECKSINGLEBUDGETCBLOCK. */ end. /* for each tqBudgetFDSByBudgetIDType */ /* ===================================================================== */ /* Copy the temp-table that holds the info for a single budgetCheckInfo */ /* into the temp-table that holds the overall wbs-information. */ /* ===================================================================== */ for each tBudgetCheckInfoWBSOneBudget : create tBudgetCheckInfoWBS. buffer-copy tBudgetCheckInfoWBSOneBudget to tBudgetCheckInfoWBS. end. /* for each tBudgetCheckInfoWBSOneBudget */ /* ======================================== */ /* Error in case (same for CC) */ /* - the input contains a project */ /* - we are wroking on a project-budget */ /* - this method is called from BudgetCheck */ /* ======================================== */ if ilCalledFromBudgetCheck = true and tBudgetByBudgetIDCodeStatus.tcProjectCode <> "":U and tBudgetByBudgetIDCodeStatus.tcProjectCode <> ? and tBudgetCheckInfo.tcProjectCode <> "":U and tBudgetCheckInfo.tcProjectCode <> ? and tBudgetByBudgetIDCodeStatus.tcProjectCode = tBudgetCheckInfo.tcProjectCode and not can-find (first tBudgetCheckInfoWBSOneBudget) then do : assign viBlockReturnStatus = -1 vcMessage = trim(substitute(#T-56'The system cannot find a WBS entry in budget &1 of project &2 that matches the input values.':255(542)t-56#,tBudgetByBudgetIDCodeStatus.tcBudgetCode,tBudgetCheckInfo.tcProjectCode)). <M-37 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-1984':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Leave CHECKSINGLEBUDGETCBLOCK. end. /* if ilCalledFromBudgetCheck = true */ if ilCalledFromBudgetCheck = true and tBudgetByBudgetIDCodeStatus.tcCostCentreCode <> "":U and tBudgetByBudgetIDCodeStatus.tcCostCentreCode <> ? and tBudgetCheckInfo.tcCostCentreCode <> "":U and tBudgetCheckInfo.tcCostCentreCode <> ? and tBudgetByBudgetIDCodeStatus.tcCostCentreCode = tBudgetCheckInfo.tcCostCentreCode and not can-find (first tBudgetCheckInfoWBSOneBudget) then do : assign viBlockReturnStatus = -1 vcMessage = trim(substitute(#T-57'The system cannot find a WBS entry in budget &1 of cost center &2 matches the input values.':255(543)t-57#,tBudgetByBudgetIDCodeStatus.tcBudgetCode,tBudgetCheckInfo.tcCostCentreCode)). <M-38 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-1997':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Leave CHECKSINGLEBUDGETCBLOCK. end. /* if ilCalledFromBudgetCheck = true */ end. /* CHECKSINGLEBUDGETCBLOCK */ end. /* for each tBudgetByBudgetIDCodeStatus */ end. /* for each tBudgetCheckInfo */ END. /* MAINBLOCKBUDGETCHECKINFO: */ /* ============= */ /* Stop queries */ /* ============= */ <M-60 run BudgetCheckInfoResolveQueryStop (output viFcReturnSuper (oiReturnStatus)) in BBudget> /* ================================= */ /* Empty temp-table used in the loop */ /* ================================= */ empty temp-table tBudgetByBudgetIDCodeStatus. empty temp-table tBudgetWBSByAll. empty temp-table tBudgetCheckInfoWBSOneBudget. empty temp-table tBudgetCheckInfoWBSTemp. /* ==================================== */ /* Return in case of errors in the loop */ /* ==================================== */ if viBlockReturnStatus <> 0 then do : assign oiReturnStatus = viBlockReturnStatus. return. end. /* if viBlockReturnStatus <> 0 */ /* =========================== */ /* Reset default Return Status */ /* =========================== */ if oiReturnStatus = -98 then assign oiReturnStatus = 0.