project QadFinancials > class BBudget > method AdditionalUpdValBudgetFDS

Description

This method will check the content of the FDS records.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBudget.AdditionalUpdates


program code (program4/bbudget.p)

/* ======================= */
    /* Go through the budgets  */
    /* ======================= */
    for each tBudget where 
             tBudget.tc_Status <> "D":U and 
             (tBudget.BudgetStatus = {&BUDGETSTATUS-OPERATIONAL} or
              tBudget.BudgetStatus = {&BUDGETSTATUS-VALID})
             no-lock :
                  
        /* =============================================================== */
        /* Reset + Skip records were no FDS is changed for furhter testing */
        /* =============================================================== */
        assign viHighestSafLevel = 0.
        if not can-find (first tBudgetFDS where 
                               tBudgetFDS.tc_ParentRowid = tBudget.tc_Rowid and 
                               (tBudgetFDS.tc_Status = "C":U or
                                tBudgetFDS.tc_Status = "N":U))
        then next.
        
        /* ================================================================================ */
        /* Each of following types can only occur once in the FDS-tree: GL/Div/Prj/CC       */
        /* ================================================================================ */
        assign vcFDSRowid = "":U.
        find first tBudgetFDS where 
                   tBudgetFDS.tc_ParentRowid  = tBudget.tc_Rowid    and 
                   tBudgetFDS.BudgetFDSType   = {&BUDGETFDSTYPE-GL} and 
                   tBudgetFDS.tc_Status      <> "D":U
                   no-lock no-error.
        if available tBudgetFDS
        then do :
            assign vcFDSRowid = tBudgetFDS.tc_Rowid.
            find first tBudgetFDS where 
                       tBudgetFDS.tc_ParentRowid  = tBudget.tc_Rowid    and 
                       tBudgetFDS.BudgetFDSType   = {&BUDGETFDSTYPE-GL} and
                       tBudgetFDS.tc_Status      <> "D":U               and
                       tBudgetFDS.tc_Rowid       <> vcFDSRowid
                       no-lock no-error.
            if available tBudgetFDS
            then do :
                assign oiReturnStatus = -1
                       vcMessage      = trim(substitute(#T-15'COA type &2 can only occur once in the COA tree of budget &1.':255(572)T-15#,tBudget.BudgetCode,{&BUDGETFDSTYPE-GL-TR})).
                <M-1 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudget.BudgetCode':U (icFieldName),
                     input  tBudget.BudgetCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tBudget.tc_Rowid (icRowid),
                     input  'QADFIN-569':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            end. /* if available tBudgetFDS */
        end. /* if available tBudgetFDS */
        assign vcFDSRowid = "":U.
        find first tBudgetFDS where 
                   tBudgetFDS.tc_ParentRowid = tBudget.tc_Rowid          and 
                   tBudgetFDS.BudgetFDSType  = {&BUDGETFDSTYPE-DIVISION} and
                   tBudgetFDS.tc_Status      <> "D":U               
                   no-lock no-error.
        if available tBudgetFDS
        then do :
            assign vcFDSRowid = tBudgetFDS.tc_Rowid.
            find first tBudgetFDS where 
                       tBudgetFDS.tc_ParentRowid  = tBudget.tc_Rowid          and 
                       tBudgetFDS.BudgetFDSType   = {&BUDGETFDSTYPE-DIVISION} and
                       tBudgetFDS.tc_Status      <> "D":U                     and
                       tBudgetFDS.tc_Rowid       <> vcFDSRowid
                       no-lock no-error.
            if available tBudgetFDS
            then do :
                assign oiReturnStatus = -1
                       vcMessage      = trim(substitute(#T-16'COA type &2 can only occur once in the COA tree of budget &1.':255(572)T-16#,tBudget.BudgetCode,{&BUDGETFDSTYPE-DIVISION-TR})).
                <M-2 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudget.BudgetCode':U (icFieldName),
                     input  tBudget.BudgetCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tBudget.tc_Rowid (icRowid),
                     input  'QADFIN-570':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            end. /* if available tBudgetFDS */
        end. /* if available tBudgetFDS */
        assign vcFDSRowid = "":U.
        find first tBudgetFDS where 
                   tBudgetFDS.tc_ParentRowid = tBudget.tc_Rowid         and 
                   tBudgetFDS.BudgetFDSType  = {&BUDGETFDSTYPE-PROJECT} and
                   tBudgetFDS.tc_Status      <> "D":U
                   no-lock no-error.
        if available tBudgetFDS
        then do :
            assign vcFDSRowid = tBudgetFDS.tc_Rowid.
            find first tBudgetFDS where 
                       tBudgetFDS.tc_ParentRowid  = tBudget.tc_Rowid         and 
                       tBudgetFDS.BudgetFDSType   = {&BUDGETFDSTYPE-PROJECT} and
                       tBudgetFDS.tc_Status      <> "D":U                    and
                       tBudgetFDS.tc_Rowid       <> vcFDSRowid
                       no-lock no-error.
            if available tBudgetFDS
            then do :
                assign oiReturnStatus = -1
                       vcMessage      = trim(substitute(#T-17'COA type &2 can only occur once in the COA tree of budget &1.':255(572)T-17#,tBudget.BudgetCode,{&BUDGETFDSTYPE-PROJECT-TR})).
                <M-3 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudget.BudgetCode':U (icFieldName),
                     input  tBudget.BudgetCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tBudget.tc_Rowid (icRowid),
                     input  'QADFIN-571':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            end. /* if available tBudgetFDS */
        end. /* if available tBudgetFDS */
        assign vcFDSRowid = "":U.
        find first tBudgetFDS where 
                   tBudgetFDS.tc_ParentRowid = tBudget.tc_Rowid            and 
                   tBudgetFDS.BudgetFDSType  = {&BUDGETFDSTYPE-COSTCENTRE} and
                   tBudgetFDS.tc_Status      <> "D":U 
                   no-lock no-error.
        if available tBudgetFDS
        then do :
            assign vcFDSRowid = tBudgetFDS.tc_Rowid.
            find first tBudgetFDS where 
                       tBudgetFDS.tc_ParentRowid  = tBudget.tc_Rowid            and 
                       tBudgetFDS.BudgetFDSType   = {&BUDGETFDSTYPE-COSTCENTRE} and
                       tBudgetFDS.tc_Status      <> "D":U                       and
                       tBudgetFDS.tc_Rowid       <> vcFDSRowid
                       no-lock no-error.
            if available tBudgetFDS
            then do :
                assign oiReturnStatus = -1
                       vcMessage      = trim(substitute(#T-18'COA type &2 can only occur once in the COA tree of budget &1.':255(572)T-18#,tBudget.BudgetCode,{&BUDGETFDSTYPE-COSTCENTRE-TR})).
                <M-4 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudget.BudgetCode':U (icFieldName),
                     input  tBudget.BudgetCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tBudget.tc_Rowid (icRowid),
                     input  'QADFIN-572':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            end. /* if available tBudgetFDS */
        end. /* if available tBudgetFDS */
        
        /* =================================================================================== */
        /* FDS-Type SAF should be situated on the lowest levels (exception towards type Total) */
        /* Maximum of SAF-levels = 5                                                           */
        /* =================================================================================== */
        assign viSAFCounter = 0.
        for each tBudgetFDS where 
                 tBudgetFDS.tc_ParentRowid = tBudget.tc_Rowid     and 
                 tBudgetFDS.BudgetFDSType  = {&BUDGETFDSTYPE-SAF} and
                 tBudgetFDS.tc_Status      <> "D":U 
                 no-lock :
            assign viSAFCounter = viSAFCounter + 1.
            if viHighestSafLevel = 0 or
               viHighestSafLevel > tBudgetFDS.BudgetFDSSeq
            then assign viHighestSafLevel = tBudgetFDS.BudgetFDSSeq.
        end. /* for each tBudgetFDS where */
        if viSAFCounter > 5
        then do :
            assign oiReturnStatus = -1
                   vcMessage      = trim(substitute(#T-19'The COA tree can contain a maximum of 5 entries of COA type &2. Budget: &1.':255(529)t-19#,tBudget.BudgetCode,{&BUDGETFDSTYPE-SAF-TR})).
            <M-5 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudget.BudgetCode':U (icFieldName),
                     input  tBudget.BudgetCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tBudget.tc_Rowid (icRowid),
                     input  'QADFIN-573':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        end. /* if viSAFCounter > 5 */
        if viSAFCounter > 0 
        then do :
            find first tBudgetFDS where 
                       tBudgetFDS.tc_ParentRowid  = tBudget.tc_Rowid       and 
                       tBudgetFDS.BudgetFDSSeq    > viHighestSafLevel      and
                       tBudgetFDS.BudgetFDSType  <> {&BUDGETFDSTYPE-SAF}   and 
                       tBudgetFDS.BudgetFDSType  <> {&BUDGETFDSTYPE-TOTAL} and 
                       tBudgetFDS.tc_Status      <> "D":U 
                       no-lock no-error.
            if available tBudgetFDS
            then do :
                assign oiReturnStatus = -1
                       vcMessage      = trim(substitute(#T-20'The COA nodes of type &2 should be on the lowest levels of the COA tree. Budget: &1.':255(573)T-20#,tBudget.BudgetCode,{&BUDGETFDSTYPE-SAF-TR})) + chr(10) + 
                                        trim(substitute(#T-21'Highest SAF level: &1.':255(574)T-21#,viHighestSafLevel)) + chr(10) + 
                                        trim(substitute(#T-22'Number of SAF levels: &1.':255(575)T-22#,viSAFCounter)) + chr(10) + 
                                        trim(substitute(#T-23'COA sequence of the corrupt COA node: &1.':255(576)T-23#,tBudgetFDS.BudgetFDSSeq)) + chr(10) + 
                                        trim(substitute(#T-24'COA type of the corrupt COA node: &1.':255(577)T-24#,tBudgetFDS.BudgetFDSType)).
                <M-6 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudget.BudgetCode':U (icFieldName),
                     input  tBudget.BudgetCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tBudget.tc_Rowid (icRowid),
                     input  'QADFIN-574':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            end. /* if available tBudgetFDS */
        end. /* if viSAFCounter > 0 */
        
        /* =========================================================================================== */
        /* The SafStructures of all BudgetWBS-nodes of FDSType 'SAF' on the highest level should match */
        /* their childs (SafStructure) and the SafConcepts shoudl match with the depth in the FDS-tree */
        /* =========================================================================================== */
        if tBudget.BudgetStatus = {&BUDGETSTATUS-OPERATIONAL}
        then 
        for each tBudgetWBS where 
                 tBudgetWBS.tc_ParentRowid   = tBudget.tc_Rowid       and 
                 tBudgetWBS.BudgetFDSSeq     = viHighestSafLevel      and
                 tBudgetWBS.BudgetFDSType    = {&BUDGETFDSTYPE-SAF}   and 
                 tBudgetWBS.tc_Status       <> "D":U 
                 no-lock :
            if tBudgetWBS.SafStructure_ID = 0
            then do :
                assign oiReturnStatus = -1
                       vcMessage      = trim(substitute(#T-25'You must enter the SAF structure of this WBS node (&1).':255(578)T-25#,tBudgetWBS.BudgetWBSCode)) + chr(10) + 
                                        trim(substitute(#T-26'Budget: &1.':255(470)T-26#,tBudget.BudgetCode)) + chr(10) + 
                                        trim(substitute(#T-27'Budget WBS node: &1.':255(490)T-27#,tBudgetWBS.BudgetWBSCode)).
                <M-9 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudgetWBS.BudgetWBSCode':U (icFieldName),
                     input  tBudgetWBS.BudgetWBSCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tBudgetWBS.tc_Rowid (icRowid),
                     input  'QADFIN-593':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            end. /* if tBudgetWBS.SafStructure_ID = 0 */
            else do :
                <Q-11 run SafConceptCodeByLine (all) (Read) (NoCache)
          (input tBudgetWBS.SafStructure_ID, (SafStructure_ID)
           input 1, (SafStructureLineNumber)
           input ?, (SafStructureCode)
           output dataset tqSafConceptCodeByLine) in BSafStructure >
                find first tqSafConceptCodeByLine
                           no-lock no-error.
                if not available tqSafConceptCodeByLine
                then do :
                    assign oiReturnStatus = -1
                           vcMessage      = trim(#T-28'Cannot find the SAF concept of the SAF structure for this WBS node.':255(494)t-28#) + chr(10) + 
                                            trim(substitute(#T-29'Budget: &1.':255(470)T-29#,tBudget.BudgetCode)) + chr(10) + 
                                            trim(substitute(#T-30'Budget WBS node: &1.':255(490)T-30#,tBudgetWBS.BudgetWBSCode)) + chr(10) + 
                                            trim(substitute(#T-31'SAF structure (code/ID): &1/&2.':255(495)T-31#,tBudgetWBS.tcSafStructureCode,tBudgetWBS.SafStructure_ID)) + chr(10) + 
                                            trim(substitute(#T-32'SAF structure level: &1.':255(493)T-32#,"1":U)).
                    <M-12 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudgetWBS.BudgetWBSCode':U (icFieldName),
                     input  tBudgetWBS.BudgetWBSCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tBudgetWBS.tc_Rowid (icRowid),
                     input  'QADFIN-594':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
                end. /* of not available tqSafConceptCodeByLine */
                if tqSafConceptCodeByLine.tiSafConcept_ID <> tBudgetWBS.SafConcept_ID
                then do :
                    assign oiReturnStatus = -1
                           vcMessage      = trim(#T-33'Invalid SAF concept for the SAF structure of this WBS node.':255(496)T-33#) + chr(10) + 
                                            trim(substitute(#T-34'Budget: &1.':255(470)T-34#,tBudget.BudgetCode)) + chr(10) + 
                                            trim(substitute(#T-35'Budget WBS node: &1.':255(490)T-35#,tBudgetWBS.BudgetWBSCode)) + chr(10) + 
                                            trim(substitute(#T-36'SAF structure (code/ID): &1/&2.':255(495)T-36#,tBudgetWBS.tcSafStructureCode,tBudgetWBS.SafStructure_ID)) + chr(10) + 
                                            trim(substitute(#T-37'SAF structure level: &1.':255(493)T-37#,"1":U)) + chr(10) + 
                                            trim(substitute(#T-38'SAF concept in WBS (code/ID): &1/&2.':255(497)T-38#,tBudgetWBS.tcSafConceptCode,tBudgetWBS.SafConcept_ID)) + chr(10) +
                                            trim(substitute(#T-39'SAF concept in SAF structure (code/ID): &1/&2.':255(498)T-39#,tqSafConceptCodeByLine.tcSafConceptCode,tqSafConceptCodeByLine.tiSafConcept_ID)).
                    <M-13 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudgetWBS.BudgetWBSCode':U (icFieldName),
                     input  tBudgetWBS.BudgetWBSCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tBudgetWBS.tc_Rowid (icRowid),
                     input  'QADFIN-595':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
                end. /* if tqSafConceptCodeByLine.tiSafConcept_ID <> tBudgetWBS.SafConcept_ID */
                /* ============================================== */
                /* Recursively call a method with the same checks */
                /* ============================================== */
                <M-14 run AdditionalUpdValBudgetFDSCycle (input  tBudget.tc_Rowid (icBudgetTcRowid), 
                                          input  tBudget.BudgetCode (icBudgetCode), 
                                          input  tBudgetWBS.Budget_ID (iiBudgetWBSID), 
                                          input  tBudgetWBS.SafStructure_ID (iiSafStructureID), 
                                          input  tBudgetWBS.tcSafStructureCode (icSafStructureCode), 
                                          input  1 (iiSafDepth), 
                                          output viFcReturnSuper (oiReturnStatus)) in BBudget>
                if viFcReturnSuper <> 0 and 
                   viFcReturnSuper < oiReturnStatus
                then assign oiReturnStatus = viFcReturnSuper.
            end. /* if vlFcQueryRecordsAvailable <> false */
        end. /* for each tBudgetWBS */                 
        
    end. /* for each tBudget where */
    
    if oiReturnStatus < 0 
    then return.