icBudgetTcRowid | input | character | Budget; BudgetTcRowid |
icBudgetWBSTcRowid | input | character | BudgetWBSTcRowid; tc_rowid of the current node you are on |
icNewBudgetWBSCode | input | character | BudgetWBSCode; Code of the new WBS-node |
iiNewBudgetWBSLineNumber | input | integer | NewBudgetWBSLineNumber |
ilCreateChild | input | logical | CreateChild; true if the new node should be a child of the current node false if the new mode should be on the same level as the current one |
icBudgetWBSFDSCode | input | character | BudgetWBSFDSCode; optional value for field tBudgetWBSFDSCode |
icBudgetWBSFDSList | input | character | BudgetWBSFDSList; optional value for field tBudgetWBSFDSList |
tNewBudgetWBS | output | temp-table | Temp-table containing the new BudgetWBS-records |
tNewBudgetVersionFigure | output | temp-table | Temp-table containing the new BudgetVersionFigure-records |
tNewBudgetVersionGLFig | output | temp-table | Temp-table containing the new BudgetVersionGLFig-records |
icNewBudgetWBSTopicDescription | input | character | |
ilNewBudgetWBSIsPrintDesc | input | logical | |
icNewBudgetGroupCode | input | character | |
icNewAltCOAGroupCode | input | character | |
icNewBudgetWBSFDSLink | input | character | |
icNewBudgetWBSCategory | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
/* ==================================================================================================== */ /* Replace unknown values // Check existance of the tBudget record and the tBudgetWBS rec (conditional) */ /* Validation; when starting from the root-node it is not possible to create a node on the same level */ /* ==================================================================================================== */ if icBudgetWBSTcRowid = ? then assign icBudgetWBSTcRowid = "":U. if icNewBudgetWBSCode = ? or icNewBudgetWBSCode = "":U then assign icNewBudgetWBSCode = trim(#T-29'New topic':15(579)t-29#). if icBudgetTcRowid = "":U or icBudgetTcRowid = ? then do : assign oiReturnStatus = -3 vcMessage = trim(#T-30'You must enter the budget identification (row ID) for the creation of budget topics.':255(535)T-30#). <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-456':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if icBudgetTcRowid = ? or */ else do : find tBudget where tBudget.tc_Rowid = icBudgetTcRowid no-lock no-error. if not available tBudget then do : assign oiReturnStatus = -3 vcMessage = trim(substitute(#T-31'Cannot find the budget based on its row ID (&1).':255(448)t-31#,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-457':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if not available tBudget */ end. /* not if iiBudgetID = 0 or */ if icBudgetWBSTcRowid = "":U and ilCreateChild <> true then do : assign oiReturnStatus = -3 vcMessage = trim(#T-32'You cannot create a budget WBS topic on the same level as the ROOT node.':255(580)t-32#). <M-19 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-479':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if icBudgetWBSTcRowid = 0 or icBudgetWBSTcRowid = ? */ if icBudgetWBSTcRowid <> "":U then 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-33'Cannot find the current budget WBS topic based on its row ID &1.':255(450)t-33#,string(icBudgetWBSTcRowid))). <M-7 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-458':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-34'You must validate the budget structure before maintaining the WBS.':255(451)t-34#). <M-22 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-494':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if tBudget.BudgetStatus = {&BUDGETSTATUS-INITIAL} */ /* ======================================================================================================== */ /* To easy the following of this method-code we make sure that viParentBudgetWBSID and viParentBudgetWBSSeq */ /* always points to the node wherefor we want to create a child (as if ilCreateChildOfCurrentWBSID = true) */ /* When both these data-items contain a value the tBudgetWBS should also point to the parent of the new one */ /* ======================================================================================================== */ if ilCreateChild = false then do : /* Get the WBSrecord based on the input */ find bBudgetWBS where bBudgetWBS.tc_ParentRowid = tBudget.tc_Rowid and bBudgetWBS.tc_Rowid = icBudgetWBSTcRowid and bBudgetWBS.tc_Status <> "D":U no-lock no-error. /* no error-check needed; already done before this */ /* Get the parent of the WBSrecord based on the previous found WBSrecord */ find tBudgetWBS where tBudgetWBS.tc_ParentRowid = tBudget.tc_Rowid and tBudgetWBS.BudgetWBS_ID = bBudgetWBS.ParentBudgetWBS_ID and tBudgetWBS.tc_Status <> "D":U no-lock no-error. end. /* if ilCreateChild = false */ else 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 available tBudgetWBS then assign viParentBudgetWBSID = tBudgetWBS.BudgetWBS_ID vdParentBudgetWBSSeq = tBudgetWBS.BudgetWBSSeq. else assign viParentBudgetWBSID = 0 vdParentBudgetWBSSeq = 0. /* =================================================== */ /* Find out the FDS information for the new WBS-record */ /* =================================================== */ if available tBudgetWBS /* tBudgetWBS points to the parent of the new node */ then do : find tBudgetFDS where tBudgetFDS.tc_ParentRowid = tBudget.tc_Rowid and tBudgetFDS.BudgetFDSSeq = tBudgetWBS.BudgetFDSSeq + 1 and tBudgetFDS.tc_Status <> "D":U no-error. if not available tBudgetFDS then do : assign oiReturnStatus = -3 vcMessage = trim(substitute(#T-35'The system cannot create a child node for the current budget WBS topic because it is unable to find level &1 of the budget COA.':255(581)t-35#,string(tBudgetWBS.BudgetFDSSeq + 1))). <M-21 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-481':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if not available tBudgetFDS */ assign viNewRecordFDSID = tBudgetFDS.BudgetFDS_ID vcNewRecordFDSType = tBudgetFDS.BudgetFDSType viNewRecordFDSSeq = tBudgetFDS.BudgetFDSSeq. end. /* if ilCreateChildOfCurrentWBSID = true */ else do : find tBudgetFDS where tBudgetFDS.tc_ParentRowid = tBudget.tc_Rowid and tBudgetFDS.BudgetFDSSeq = 1 and tBudgetFDS.tc_Status <> "D":U no-error. if not available tBudgetFDS then do : assign oiReturnStatus = -3 vcMessage = trim(#T-36'The system cannot create a root budget WBS topic because it cannot find the first level of the budget COA.':255(582)t-36#). <M-20 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-480':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if not available tBudgetFDS */ assign viNewRecordFDSID = tBudgetFDS.BudgetFDS_ID vcNewRecordFDSType = tBudgetFDS.BudgetFDSType viNewRecordFDSSeq = tBudgetFDS.BudgetFDSSeq. end. /* not if available tBudgetWBS */ /* ========================================================================== */ /* Reset the output temp-table */ /* ========================================================================== */ empty temp-table tNewBudgetWBS. empty temp-table tNewBudgetVersionFigure. empty temp-table tNewBudgetVersionGLFig. /* ====================================================================================== */ /* Define the SafStructure and the SafConcept in case this is a SafType and it is not the */ /* highest SafLevel. If so, then the SafStructure it taken from the highest level and the */ /* concept is taken from the SafStructure level base on the level within the WBS-tree. */ /* ====================================================================================== */ if vcNewRecordFDSType = {&BUDGETFDSTYPE-SAF} and /* new node is of type SAF */ available(tBudgetWBS) and /* a parent-node exists */ (tBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-SAF} or tBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-TOTAL}) /* the parent-code is of type SAF/Total */ then SAFSETTINGSBLOCK : DO : /* Get the highest SAF-parent; at the end bBudgetWBS contains the highest saf-level */ assign viSAFCyclingBudgetWBSID = tBudgetWBS.BudgetWBS_ID viSAFCyclingBudgetWBSSAFID = 0 viSAFCyclingCounter = 1. repeat : find first bBudgetWBS where bBudgetWBS.tc_ParentRowid = tBudget.tc_Rowid and bBudgetWBS.BudgetWBS_ID = viSAFCyclingBudgetWBSID and bBudgetWBS.tc_Status <> "D":U and (bBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-SAF} or bBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-TOTAL}) no-lock no-error. if available bBudgetWBS then do : assign viSAFCyclingBudgetWBSID = bBudgetWBS.ParentBudgetWBS_ID. if bBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-SAF} then assign viSAFCyclingBudgetWBSSAFID = bBudgetWBS.BudgetWBS_ID viSAFCyclingCounter = viSAFCyclingCounter + 1. end. /* if available bBudgetWBS */ else leave. end. /* repeat */ if viSAFCyclingBudgetWBSSAFID = 0 then leave SAFSETTINGSBLOCK. find bBudgetWBS where bBudgetWBS.tc_ParentRowid = tBudget.tc_Rowid and bBudgetWBS.BudgetWBS_ID = viSAFCyclingBudgetWBSSAFID and bBudgetWBS.tc_Status <> "D":U no-lock no-error. if not available bBudgetWBS or bBudgetWBS.SafStructure_ID = 0 or bBudgetWBS.SafStructure_ID = ? then leave SAFSETTINGSBLOCK. /* Get the safstructure of the tBudgetWBS record */ <Q-12 run SafConceptCodeByLine (all) (Read) (NoCache) (input bBudgetWBS.SafStructure_ID, (SafStructure_ID) input viSAFCyclingCounter, (SafStructureLineNumber) input ?, (SafStructureCode) output dataset tqSafConceptCodeByLine) in BSafStructure > find first tqSafConceptCodeByLine no-lock no-error. if not available tqSafConceptCodeByLine then do : assign oiReturnStatus = -3 vcMessage = trim(substitute(#T-37'Cannot define level &1 of the SAF structure &2.':255(583)t-37#,string(viSAFCyclingCounter),string(bBudgetWBS.SafStructure_ID))). <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-463':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if not av. tqSafConceptCodeByLine */ assign viNewRecordSafStructureID = bBudgetWBS.SafStructure_ID vcNewRecordSafStructureCode = bBudgetWBS.tcSafStructureCode viNewRecordSafConceptID = tqSafConceptCodeByLine.tiSafConcept_ID vcNewRecordSafConceptCode = tqSafConceptCodeByLine.tcSafConceptCode. end. /* if vcNewRecordFDSType = {&BUDGETFDSTYPE-SAF} */ /* ================================================================================================ */ /* Calculate the WBS sequence for new record: */ /* - When parent = root-node then use a fixed jump */ /* - Otherwise: take the average of the highest child and the next WBS on the same or higher level */ /* ================================================================================================ */ <M-27 run BudgetWBSCreateGetSequence (input icBudgetTcRowid (icBudgetTcRowid), input viParentBudgetWBSID (iiParentBudgetWBSID), input viNewRecordFDSSeq (iiNewRecordFDSSeq), output vcNewRecordWBSSeq (ocNewRecordWBSSeq), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper <> 0 then do : assign oiReturnStatus = viFcReturnSuper vcMessage = trim(#T-38'An internal error has occurred while calculating the sequence of the new node.':255(584)T-38#) + chr(10) + trim(substitute(#T-39'Parent node ID: &1.':255(585)T-39#,string(viParentBudgetWBSID))) + chr(10) + trim(substitute(#T-40'The COA sequence of the new node is &1.':255(586)t-40#,string(viNewRecordFDSSeq))) + chr(10) + trim(substitute(#T-41'Return Status: &1.':255(587)T-41#,string(oiReturnStatus))). <M-28 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-1923':U (icFcMsgNumber), input '' (icFcExplanation), input '' (icFcIdentification), input '' (icFcContext), output viFcReturnSuper (oiReturnStatus)) in BBudget> Return. end. /* if viFcReturnSuper <> 0 */ /* =========================================================== */ /* Create the new WBS-record and a corresponding output record */ /* =========================================================== */ <M-11 run AddDetailLine (input 'BudgetWBS':U (icTable), input tBudget.tc_Rowid (icParentRowid), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper < 0 then do : assign oiReturnStatus = viFcReturnSuper. return. end. /* if viFcReturnSuper < 0 */ assign tBudgetWBS.BudgetFDS_ID = viNewRecordFDSID tBudgetWBS.BudgetFDSType = vcNewRecordFDSType tBudgetWBS.BudgetFDSSeq = viNewRecordFDSSeq tBudgetWBS.SafStructure_ID = viNewRecordSafStructureID tBudgetWBS.SafConcept_ID = viNewRecordSafConceptID tBudgetWBS.tcSafStructureCode = vcNewRecordSafStructureCode tBudgetWBS.tcSafConceptCode = vcNewRecordSafConceptCode tBudgetWBS.BudgetWBSCode = icNewBudgetWBSCode tBudgetWBS.BudgetWBSLineNumber= iiNewBudgetWBSLineNumber tBudgetWBS.BudgetWBSTopicDescription = icNewBudgetWBSTopicDescription tBudgetWBS.BudgetWBSIsPrintDesc = ilNewBudgetWBSIsPrintDesc tBudgetWBS.tcBudgetGroupCode = icNewBudgetGroupCode tBudgetWBS.tcAltCOAGroupCode = icNewAltCOAGroupCode tBudgetWBS.BudgetWBSFDSLink = icNewBudgetWBSFDSLink. if icNewBudgetWBSCategory = "" or icNewBudgetWBSCategory = ? then assign tBudgetWBS.BudgetWBSCategory = {&BUDGETWBSCATEGORY-ASSET}. else if icNewBudgetWBSCategory = {&BUDGETWBSCATEGORY-INCOME-TR} then assign tBudgetWBS.BudgetWBSCategory ={&BUDGETWBSCATEGORY-INCOME}. else if icNewBudgetWBSCategory = {&BUDGETWBSCATEGORY-EXPENSE-TR} then assign tBudgetWBS.BudgetWBSCategory = {&BUDGETWBSCATEGORY-EXPENSE}. else if icNewBudgetWBSCategory = {&BUDGETWBSCATEGORY-LIABILITY-TR} then tBudgetWBS.BudgetWBSCategory = {&BUDGETWBSCATEGORY-LIABILITY}. /* tBudgetWBS.BudgetWBSSeq = vdNewRecordWBSSeq */ assign tBudgetWBS.BudgetWBSFDSList = icBudgetWBSFDSList tBudgetWBS.BudgetWBSFDSCode = icBudgetWBSFDSCode tBudgetWBS.ParentBudgetWBS_ID = viParentBudgetWBSID tBudgetWBS.tcBudgetWBSSeqStr = vcNewRecordWBSSeq. assign vcBudgetWBSFDSCodeFrom = "":U vcBudgetWBSFDSCodeTo = "":U vcBudgetWBSFDSCode = "":U vcBudgetWBSFDSList = "":U. <M-2 run InterpretFDSLink (input icNewBudgetWBSFDSLink (icBudgetFDSLink), output vcBudgetWBSFDSCodeFrom (ocBudgetWBSFDSCodeFrom), output vcBudgetWBSFDSCodeTo (ocBudgetWBSFDSCodeTo), output vcBudgetWBSFDSCode (ocBudgetWBSFDSCode), output vcBudgetWBSFDSList (ocBudgetWBSFDSList), output viFcReturnSuper (oiReturnStatus)) in BBudget> assign tBudgetWBS.BudgetWBSFDSFromCode = vcBudgetWBSFDSCodeFrom tBudgetWBS.BudgetWBSFDSToCode = vcBudgetWBSFDSCodeTo tBudgetWBS.BudgetWBSFDSCode = vcBudgetWBSFDSCode tBudgetWBS.BudgetWBSFDSList = vcBudgetWBSFDSList. create tNewBudgetWBS. buffer-copy tBudgetWBS except BudgetWBSSeq to tNewBudgetWBS. /* ============================================================= */ /* Create new VersionFigure-records for the new budgetWBS record */ /* DO the same for the corresponding output records */ /* ============================================================= */ for each tBudgetVersion where tBudgetVersion.tc_ParentRowid = tBudget.tc_Rowid and tBudgetVersion.tc_Status <> "D":U no-lock : if (tBudget.tcProjectCode <> "":U and tBudget.tcProjectCode <> ?) or (tBudget.tcCostCentreCode <> "":U and tBudget.tcCostCentreCode <> ?) then do : <M-25 run AddDetailLine (input 'BudgetVersionFigure':U (icTable), input tBudgetVersion.tc_Rowid (icParentRowid), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper < 0 then do : assign oiReturnStatus = viFcReturnSuper. return. end. /* if viFcReturnSuper < 0 */ assign tBudgetVersionFig.BudgetWBS_ID = tBudgetWBS.BudgetWBS_ID tBudgetVersionFig.tiBudgetFDSSeq = tBudgetWBS.BudgetFDSSeq tBudgetVersionFig.tcBudgetFDSType = tBudgetWBS.BudgetFDSType tBudgetVersionFig.tcBudgetWBSCode = tBudgetWBS.BudgetWBSCode tBudgetVersionFig.tcBudgetWBSSeq = tBudgetWBS.tcBudgetWBSSeqStr tBudgetVersionFig.tiParentBudgetWBS_ID = tBudgetWBS.ParentBudgetWBS_ID. create tNewBudgetVersionFigure. buffer-copy tBudgetVersionFig to tNewBudgetVersionFigure. end. /* Project or CC budget */ else do : <M-26 run AddDetailLine (input 'BudgetVersionGLFig':U (icTable), input tBudgetVersion.tc_Rowid (icParentRowid), output viFcReturnSuper (oiReturnStatus)) in BBudget> if viFcReturnSuper < 0 then do : assign oiReturnStatus = viFcReturnSuper. return. end. /* if viFcReturnSuper < 0 */ assign tBudgetVersionGLFig.BudgetWBS_ID = tBudgetWBS.BudgetWBS_ID tBudgetVersionGLFig.tiBudgetFDSSeq = tBudgetWBS.BudgetFDSSeq tBudgetVersionGLFig.tcBudgetFDSType = tBudgetWBS.BudgetFDSType tBudgetVersionGLFig.tcBudgetWBSCode = tBudgetWBS.BudgetWBSCode tBudgetVersionGLFig.tiBudgetWBSLineNumber= tBudgetWBS.BudgetWBSLineNumber tBudgetVersionGLFig.tcBudgetWBSTopicDescription = tBudgetWBS.BudgetWBSTopicDescription tBudgetVersionGLFig.tlBudgetWBSIsPrintDesc = tBudgetWBS.BudgetWBSIsPrintDesc tBudgetVersionGLFig.tcBudgetGroupCode = tBudgetWBS.tcBudgetGroupCode tBudgetVersionGLFig.tcAltCOAGroupCode = tBudgetWBS.tcAltCOAGroupCode tBudgetVersionGLFig.tcBudgetWBSFDSLink = tBudgetWBS.BudgetWBSFDSLink tBudgetVersionGLFig.tcBudgetWBSCategory = if tBudgetWBS.BudgetWBSCategory = "" or tBudgetWBS.BudgetWBSCategory = ? then {&BUDGETWBSCATEGORY-ASSET} else tBudgetWBS.BudgetWBSCategory tBudgetVersionGLFig.tcBudgetWBSSeq = tBudgetWBS.tcBudgetWBSSeqStr tBudgetVersionGLFig.tiParentBudgetWBS_ID = tBudgetWBS.ParentBudgetWBS_ID. create tNewBudgetVersionGLFig. buffer-copy tBudgetVersionGLFig to tNewBudgetVersionGLFig. end. /* not Project or CC budget */ end. /* for each */