iiBudgetWBSID | input | integer | BudgetWBSID |
icGlCode | input | character | GLCode |
icDivisionCode | input | character | Sub-Account Code |
icCostCentreCode | input | character | CostCentreCode |
icProjectCode | input | character | ProjectCode |
iiSafStructID | input | integer | SafStructID |
iiSafConcept1ID | input | integer | SafConcept1ID |
iiSafConcept2ID | input | integer | SafConcept2ID |
iiSafConcept3ID | input | integer | SafConcept3ID |
iiSafConcept4ID | input | integer | SafConcept4ID |
iiSafConcept5ID | input | integer | SafConcept5ID |
icSaf1Code | input | character | Saf1Code |
icSaf2Code | input | character | Saf2Code |
icSaf3Code | input | character | Saf3Code |
icSaf4Code | input | character | Saf4Code |
icSaf5Code | input | character | Saf5Code |
icRestrictedBusComponentCode | input | character | RestrictedBusComponentCode; Code of the business-component that will be used to restrict the selectable nodes. Only used in case RestrictedBusComponentID is not filled |
iiRestrictedBusComponentID | input | integer | RestrictedBusComponentID; ID of the business-component that will be used to restrict the selectable nodes. |
oiReturnStatus | output | integer | Return status of the method. |
assign viErrorStatus = 0 oiReturnStatus = -98. /* check the input parameters, is safconcept is filled safcode must be filled to */ if iiRestrictedBusComponentID = ? then assign iiRestrictedBusComponentID = 0. if icRestrictedBusComponentCode = ? then assign icRestrictedBusComponentCode = "":U. if icCostCentreCode = ? then assign icCostCentreCode = "":U. if icProjectCode = ? then assign icProjectCode = "":U. if (iiSafConcept1ID <> 0 and iiSafConcept1ID <> ? and (icSaf1Code = "":U or icSaf1Code = ?)) or (iiSafConcept2ID <> 0 and iiSafConcept2ID <> ? and (icSaf2Code = "":U or icSaf2Code = ?)) or (iiSafConcept3ID <> 0 and iiSafConcept3ID <> ? and (icSaf3Code = "":U or icSaf3Code = ?)) or (iiSafConcept4ID <> 0 and iiSafConcept4ID <> ? and (icSaf4Code = "":U or icSaf4Code = ?)) or (iiSafConcept5ID <> 0 and iiSafConcept5ID <> ? and (icSaf5Code = "":U or icSaf5Code = ?)) or (icSaf1Code <> "":U and icSaf1Code <> ? and (iiSafConcept1ID = 0 or iiSafConcept1ID = ?)) or (icSaf2Code <> "":U and icSaf2Code <> ? and (iiSafConcept2ID = 0 or iiSafConcept2ID = ?)) or (icSaf3Code <> "":U and icSaf3Code <> ? and (iiSafConcept3ID = 0 or iiSafConcept3ID = ?)) or (icSaf4Code <> "":U and icSaf4Code <> ? and (iiSafConcept4ID = 0 or iiSafConcept4ID = ?)) or (icSaf5Code <> "":U and icSaf5Code <> ? and (iiSafConcept5ID = 0 or iiSafConcept5ID = ?)) or iiBudgetWBSID = 0 or iiBudgetWBSID = ? then do: assign oiReturnStatus = -1 vcMessage = trim(#T-19'The COA fields cannot be checked for this budget WBS.':200(674)t-19#). <M-11 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-2123':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> return. end. /* get the deepest level of the saf usage */ if icSaf5Code <> "":U and icSaf5Code <> ? then assign viCounter = 5. else if icSaf4Code <> "":U and icSaf4Code <> ? then assign viCounter = 4. else if icSaf3Code <> "":U and icSaf3Code <> ? then assign viCounter = 3. else if icSaf2Code <> "":U and icSaf2Code <> ? then assign viCounter = 2. else if icSaf1Code <> "":U and icSaf1Code <> ? then assign viCounter = 1. else assign viCounter = 0. /* Start queries */ <Q-16 run BudgetWBSByAll (Start) in BBudget > /* Only check the FDS elements in his own tree, and only up */ assign vlDeepestBudgetWBSNode = true. do while iiBudgetWBSId <> 0 and iiBudgetWBSId <> ? and viErrorStatus >= 0 and (oiReturnStatus >= 0 or oiReturnStatus = -98) : /* find the WBS, the first time it's the lowest wbs code , depending on input param */ /* all the other times the WBSID is filled with the wbsid of the parent */ <Q-2 run BudgetWBSByAll (all) (Read) (NoCache) (input ?, (BudgetID) input iiBudgetWBSID, (BudgetWBSID) input '':U, (BudgetWBSCode) input ?, (ParentBudgetWBSID) input '':U, (BudgetFDSType) input ?, (SafStructureID) input ?, (SafConceptID) input ?, (BudgetFDSID) output dataset tqBudgetWBSByAll) in BBudget > find first tqBudgetWBSByAll no-lock no-error. if not available tqBudgetWBSByAll then do: assign oiReturnStatus = -1 vcMessage = trim(#T-20'Internal error: the budget WBS is missing.':200(675)t-20#) + chr(10) + trim(substitute('BudgetWBSID: &1':U, iiBudgetWBSID)). <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-2124':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> leave. end. /* Check the BusComponent for the deepest wbs-node in case a value was passed for it */ if vlDeepestBudgetWBSNode = true and (iiRestrictedBusComponentID <> 0 or icRestrictedBusComponentCode <> "":U) then do: if iiRestrictedBusComponentID = 0 then do : <Q-15 run BusComponentByLabelCodeID (all) (Read) (NoCache) (input ?, (BusComponentID) input icRestrictedBusComponentCode, (BusComponentCode) input ?, (BusComponentLabel) output dataset tqBusComponentByLabelCodeID) in BBusinessComponent > find first tqBusComponentByLabelCodeID where tqBusComponentByLabelCodeID.tcBusComponentCode = icRestrictedBusComponentCode no-lock no-error. if available tqBusComponentByLabelCodeID then assign iiRestrictedBusComponentID = tqBusComponentByLabelCodeID.tiBusComponent_ID. end. /* if iiRestrictedBusComponentID = 0 */ <Q-13 run BudgetWBSBusComponentByIDs (all) (Read) (NoCache) (input ?, (BudgetID) input tqBudgetWBSByAll.tiBudgetWBS_ID, (BudgetWBSID) input ?, (BusComponentID) output dataset tqBudgetWBSBusComponentByIDs) in BBudget > if can-find (first tqBudgetWBSBusComponentByIDs where tqBudgetWBSBusComponentByIDs.tiBudgetWBS_ID = tqBudgetWBSByAll.tiBudgetWBS_ID) and not can-find (tqBudgetWBSBusComponentByIDs where tqBudgetWBSBusComponentByIDs.tiBudgetWBS_ID = tqBudgetWBSByAll.tiBudgetWBS_ID and tqBudgetWBSBusComponentByIDs.tiBusComponent_ID = iiRestrictedBusComponentID) then do: assign oiReturnStatus = -1 vcMessage = trim(substitute(#T-21'The budget WBS node (&1) was restricted to a limited set of classes, but no class for the current transaction was included.':255(676)T-21#,tqBudgetWBSByAll.tcBudgetWBSCode)) + chr(10) + trim(substitute(#T-22'Budget WBS ID: &1.':255(677)T-22#,string(tqBudgetWBSByAll.tiBudgetWBS_ID))) + chr(10) + trim(substitute(#T-23'Component ID/code: &1/&2.':255(678)T-23#,string(iiRestrictedBusComponentID),icRestrictedBusComponentCode)). <M-14 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-2298':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> leave. end. /* if can-find */ end. /* if vlDeepestBudgetWBSNode = true and */ /* Hold settings for the next cycle */ assign iiBudgetWBSId = tqBudgetWBSByAll.tiParentBudgetWBS_ID vlDeepestBudgetWBSNode = false. /* the actual check on blanco's and the global assign of the specific code to fds code*/ case tqBudgetWBSByAll.tcBudgetFDSType: when {&BUDGETFDSTYPE-GL} then do: if icGlCode = "":U or icGlCode = ? then assign viErrorStatus = -2. else assign vcFDSCode = icGlCode. end. when {&BUDGETFDSTYPE-DIVISION} then do: if icDivisionCode = "":U or icDivisionCode = ? then assign viErrorStatus = -3. else assign vcFDSCode = icDivisionCode. end. when {&BUDGETFDSTYPE-PROJECT} then do: if icProjectCode = "":U then assign viErrorStatus = -4. else assign vcFDSCode = icProjectCode. end. when {&BUDGETFDSTYPE-COSTCENTRE} then do: if icCostCentreCode = "":U then assign viErrorStatus = -5. else assign vcFDSCode = icCostCentreCode. end. when {&BUDGETFDSTYPE-SAF} then do: if iiSafStructID <> tqBudgetWBSByAll.tiSafStructure_ID then assign viErrorStatus = -6. /**** !!!!!!!!!! pay attention to check if we use the correct saf for test, start from bottom note and lowest saf !!!!!!! */ if (viCounter = 5 and iiSafConcept5ID <> tqBudgetWBSByAll.tiSafConcept_ID) then assign viErrorStatus = -75. else if (viCounter = 4 and iiSafConcept4ID <> tqBudgetWBSByAll.tiSafConcept_ID) then assign viErrorStatus = -74. else if (viCounter = 3 and iiSafConcept3ID <> tqBudgetWBSByAll.tiSafConcept_ID) then assign viErrorStatus = -73. else if (viCounter = 2 and iiSafConcept2ID <> tqBudgetWBSByAll.tiSafConcept_ID) then assign viErrorStatus = -72. else if (viCounter = 1 and iiSafConcept1ID <> tqBudgetWBSByAll.tiSafConcept_ID) then assign viErrorStatus = -71. if viCounter = 5 and (icSaf5Code = "":U or icSaf5Code = ?) then assign viErrorStatus = -85. else if viCounter = 4 and (icSaf4Code = "":U or icSaf4Code = ?) then assign viErrorStatus = -84. else if viCounter = 3 and (icSaf3Code = "":U or icSaf3Code = ?) then assign viErrorStatus = -83. else if viCounter = 2 and (icSaf2Code = "":U or icSaf2Code = ?) then assign viErrorStatus = -82. else if viCounter = 1 and (icSaf1Code = "":U or icSaf1Code = ?) then assign viErrorStatus = -81. if viErrorStatus = 0 then do: if viCounter = 5 then assign vcFDSCode = icSaf5Code viSafConceptID = iiSafConcept5ID. else if viCounter = 4 then assign vcFDSCode = icSaf4Code viSafConceptID = iiSafConcept4ID. else if viCounter = 3 then assign vcFDSCode = icSaf3Code viSafConceptID = iiSafConcept3ID. else if viCounter = 2 then assign vcFDSCode = icSaf2Code viSafConceptID = iiSafConcept2ID. else if viCounter = 1 then assign vcFDSCode = icSaf1Code viSafConceptID = iiSafConcept1ID. else assign vcFDSCode = "":U viSafConceptID = 0. end. /* oiret = o */ end. /* FDS type SAF */ end case. if viErrorStatus < 0 then leave. /* ============================================================================================ */ /* check the WBSCode with the inputparamter (option code, from-to, list. Pay attention with "*" */ /* ============================================================================================ */ assign vlFDSStatus = false. if tqBudgetWBSByAll.tcBudgetWBSFDSCode <> "":U and tqBudgetWBSByAll.tcBudgetWBSFDSCode <> ? then do: if index(tqBudgetWBSByAll.tcBudgetWBSFDSCode,"*":U) <> 0 then do: /* Matches WBS Code with "*" */ if vcFDSCode matches tqBudgetWBSByAll.tcBudgetWBSFDSCode then assign vlFDSStatus = true. end. else do: /* equals no "*" */ if vcFDSCode = tqBudgetWBSByAll.tcBudgetWBSFDSCode then assign vlFDSStatus = true. 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 >= vcFDSCode and tqBudgetWBSByAll.tcBudgetWBSFDSToCode <= vcFDSCode) then assign vlFDSStatus = true. end. /* code list */ else do: if tqBudgetWBSByAll.tcBudgetWBSFDSList <> "":U and tqBudgetWBSByAll.tcBudgetWBSFDSList <> ? then do: if lookup(vcFDSCode,tqBudgetWBSByAll.tcBudgetWBSFDSList) <> 0 then assign vlFDSStatus = true. end. else do: /* check the budgetgroup with the correct type */ case tqBudgetWBSByAll.tcBudgetFDSType: when {&BUDGETFDSTYPE-SAF} then do: /* take care, take the correct safconcept !!!!! */ <Q-3 run SafBySSOthers (all) (Read) (NoCache) (input ?, (FromSafCode) input ?, (ToSafCode) input ?, (SafConceptCode) input viSafConceptID, (SafConceptID) input ?, (MatchingSafCode) input ?, (SafCode) input tqBudgetWBSByAll.tiBudgetGroup_ID, (BudgetGroupID) output dataset tqSafBySSOthers) in BSaf > find first tqSafBySSOthers no-error. if available tqSafBySSOthers then assign vlFDSStatus = true. end. /* SAF */ when {&BUDGETFDSTYPE-GL} then do: <Q-4 run GLBySSOthers (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input ?, (FromGLCode) input ?, (ToGLCode) input ?, (GLSharedSetID) input ?, (MatchingGLCode) input vcFDSCode, (GLCode) input tqBudgetWBSByAll.tiBudgetGroup_ID, (BudgetGroupID) output dataset tqGLBySSOthers) in BGL > find first tqGLBySSOthers no-error. if available tqGLBySSOthers then assign vlFDSStatus = true. end. /* GL */ when {&BUDGETFDSTYPE-DIVISION} then do: <Q-5 run DivisionBySSOthers (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input ?, (DivisionSharedSetID) input ?, (FromDivisionCode) input ?, (ToDivisionCode) input ?, (MatchingDivisionCode) input vcFDSCode, (DivisionCode) input tqBudgetWBSByAll.tiBudgetGroup_ID, (BudgetGroupID) output dataset tqDivisionBySSOthers) in BDivision > find first tqDivisionBySSOthers no-error. if available tqDivisionBySSOthers then assign vlFDSStatus = true. end. /* Div */ when {&BUDGETFDSTYPE-PROJECT} then do: <Q-6 run ProjectBySSOthers (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input ?, (ProjectSharedSetID) input ?, (FromProjectCode) input ?, (ToProjectCode) input ?, (MatchingProjectCode) input vcFDSCode, (ProjectCode) input tqBudgetWBSByAll.tiBudgetGroup_ID, (BudgetGroupID) output dataset tqProjectBySSOthers) in BProject > find first tqProjectBySSOthers no-error. if available tqProjectBySSOthers then assign vlFDSStatus = true. end. /* Proj */ when {&BUDGETFDSTYPE-COSTCENTRE} then do: <Q-7 run CostCentreBySSOthers (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input ?, (CostCentreSharedSetID) input ?, (FromCostCentreCode) input ?, (ToCostCentreCode) input ?, (MatchingCostCentreCode) input vcFDSCode, (CostCentreCode) input tqBudgetWBSByAll.tiBudgetGroup_ID, (BudgetGroupID) output dataset tqCostCentreBySSOthers) in BCostCentre > find first tqCostCentreBySSOthers no-error. if available tqCostCentreBySSOthers then assign vlFDSStatus = true. end. /* CC */ end case. end. end. /* code list */ end. /* code range */ if vlFDSStatus = false then do: case tqBudgetWBSByAll.tcBudgetFDSType: when {&BUDGETFDSTYPE-GL} then assign viErrorStatus = -2. when {&BUDGETFDSTYPE-DIVISION} then assign viErrorStatus = -3. when {&BUDGETFDSTYPE-PROJECT} then assign viErrorStatus = -4. when {&BUDGETFDSTYPE-COSTCENTRE} then assign viErrorStatus = -5. when {&BUDGETFDSTYPE-SAF} then do: if viCounter = 1 then assign viErrorStatus = -81. if viCounter = 2 then assign viErrorStatus = -82. if viCounter = 3 then assign viErrorStatus = -83. if viCounter = 4 then assign viErrorStatus = -84. if viCounter = 5 then assign viErrorStatus = -85. end. end case. end. if tqBudgetWBSByAll.tcBudgetFDSType = {&BUDGETFDSTYPE-SAF} then assign viCounter = viCounter - 1. end. /*do while parent filled */ /* Check for major errors in the loop */ if oiReturnStatus < 0 and oiReturnStatus <> -98 then return. if icCostCentreCode <> "":U then do: <Q-45 run CostCentrePrim (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input ?, (CostCentreID) input icCostCentreCode, (CostCentreCode) output dataset tqCostCentrePrim) in BCostCentre > find first tqCostCentrePrim no-error. assign viCostCentreID = if available tqCostCentrePrim then tqCostCentrePrim.tiCostCentre_ID else 0. end. if icProjectCode <> "":U then do: <Q-46 run ProjectPrim (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input ?, (ProjectID) input icProjectCode, (ProjectCode) output dataset tqProjectPrim) in BProject > find first tqProjectPrim no-error. assign viProjectID = if available tqProjectPrim then tqProjectPrim.tiProject_ID else 0. end. /* check project / costcentre for project/costcentre budgets */ <Q-12 run BudgetByProjectCostCentre (all) (Read) (NoCache) (input viCompanyId, (CompanyId) input if viCostCentreID = 0 or viCostCentreID = ? then icCostCentreCode else '':U, (CostCentreCode) input viCostCentreID, (CostCentreID) input if viProjectID = 0 or viProjectID = ? then icProjectCode else '':U, (ProjectCode) input viProjectID, (ProjectID) input ?, (RowidToSkip) input ?, (BudgetStatus) output dataset tqBudgetByProjectCostCentre) in BBudget > find first tqBudgetByProjectCostCentre no-lock no-error. if available tqBudgetByProjectCostCentre then do: if tqBudgetByProjectCostCentre.tcProjectCode <> "":U and tqBudgetByProjectCostCentre.tcProjectCode <> ? and tqBudgetByProjectCostCentre.tcProjectCode <> icProjectCode then assign viErrorStatus = -40. if tqBudgetByProjectCostCentre.tcCostCentreCode <> "":U and tqBudgetByProjectCostCentre.tcCostCentreCode <> ? and tqBudgetByProjectCostCentre.tcCostCentreCode <> icCostCentreCode then assign viErrorStatus = -50. end. if viErrorStatus < -1 then do: case viErrorStatus: when -2 then assign vcFDSType = #T-24'GL':3(679)T-24#. when -3 then assign vcFDSType = #T-25'Sub-Account':16(680)T-25#. when -4 then assign vcFDSType = #T-26'Project':9(681)t-26#. when -5 then assign vcFDSType = #T-27'Cost Center':19(682)T-27#. when -6 then assign vcFDSType = #T-28'SAF Structure':15(683)T-28#. when -40 then assign vcFDSType = #T-29'Project':9(681)t-29#. when -50 then assign vcFDSType = #T-30'Cost Center':19(682)T-30#. when -71 then assign vcFDSType = #T-31'SAF Concept 1':15(684)T-31#. when -72 then assign vcFDSType = #T-32'SAF Concept 2':15(685)T-32#. when -73 then assign vcFDSType = #T-33'SAF Concept 3':15(686)T-33#. when -74 then assign vcFDSType = #T-34'SAF Concept 4':15(687)T-34#. when -75 then assign vcFDSType = #T-35'SAF Concept 5':15(688)T-35#. when -81 then assign vcFDSType = #T-36'SAF Code 1':10(689)T-36#. when -82 then assign vcFDSType = #T-37'SAF Code 2':10(690)T-37#. when -83 then assign vcFDSType = #T-38'SAF Code 3':10(691)T-38#. when -84 then assign vcFDSType = #T-39'SAF Code 4':10(692)T-39#. when -85 then assign vcFDSType = #T-40'SAF Code 5':10(693)T-40#. end case. assign vcMessage = trim(substitute(#T-41'The &1 does not match the COA of WBS code &2.':255(694)T-41#,trim(vcFDSType),trim((if available tqBudgetWBSByAll then tqBudgetWBSByAll.tcBudgetWBSCode else "?":U)))). if available tqBudgetWBSByAll and ((viErrorStatus > -5 and viErrorStatus < -2 ) or (viErrorStatus > -85 and viErrorStatus < -80)) then if tqBudgetWBSByAll.tcBudgetWBSFDSFromCode <> "":U and tqBudgetWBSByAll.tcBudgetWBSFDSFromCode <> ? and tqBudgetWBSByAll.tcBudgetWBSFDSToCode <> ? then assign vcMessage = vcMessage + chr(10) + trim(substitute(#T-42'Valid range: &1 - &2.':255(695)T-42#,tqBudgetWBSByAll.tcBudgetWBSFDSFromCode,tqBudgetWBSByAll.tcBudgetWBSFDSToCode)). else if tqBudgetWBSByAll.tcBudgetWBSFDSList <> "":U and tqBudgetWBSByAll.tcBudgetWBSFDSList <> ? then assign vcMessage = vcMessage + chr(10) + trim(substitute(#T-43'Valid list: &1.':255(696)T-43#,tqBudgetWBSByAll.tcBudgetWBSFDSList)). else if tqBudgetWBSByAll.tcBudgetWBSFDSCode <> "":U and tqBudgetWBSByAll.tcBudgetWBSFDSCode <> ? then assign vcMessage = vcMessage + chr(10) + trim(substitute(#T-44'Valid code(s): &1.':255(697)T-44#,tqBudgetWBSByAll.tcBudgetWBSFDSCode)). <M-8 run SetMessage (input vcMessage (icMessage), input '':U (icArguments), input '':U (icFieldName), input '':U (icFieldValue), input 'E':U (icType), input 3 (iiSeverity), input ? (icRowid), input 'QADFIN-2120':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> assign oiReturnStatus = -1. end. /* Stop queries */ <Q-18 run BudgetWBSByAll (Stop) in BBudget > empty temp-table tqBudgetByProjectCostCentre. empty temp-table tqBudgetWBSByAll. /* Set ReturnStatus = OK */ if oiReturnStatus = -98 then assign oiReturnStatus = 0.