project QadFinancials > class BBudget > method AdditionalUpdValBudgetFDSCycle

Description

This method is recursive submethod of method AdditionalUpdValBudgetFDS which will check content of FDS records.


Parameters


icBudgetTcRowidinputcharacterBudgetTcRowid
icBudgetCodeinputcharacterBudgetCode
iiBudgetWBSIDinputintegerBudgetWBSID
iiSafStructureIDinputintegerSafStructureID
icSafStructureCodeinputcharacterSafStructureCode
iiSafDepthinputintegerSafDepth
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBudget.AdditionalUpdValBudgetFDS
method BBudget.AdditionalUpdValBudgetFDSCycle


program code (program4/bbudget.p)

/* =========================================================================================== */
    /* 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 */
    /* =========================================================================================== */
    for each tBudgetWBS where 
             tBudgetWBS.tc_ParentRowid      = icBudgetTcRowid   and 
             tBudgetWBS.ParentBudgetWBS_ID  = iiBudgetWBSID     and
             tBudgetWBS.tc_Status          <> "D":U             and 
             (tBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-SAF} or
              tBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-TOTAL})
             no-lock :
        
        /* ====================================================================================== */
        /* For the total-nodes we just call this method recursively without raising the Saf-Depth */
        /* ====================================================================================== */
        if tBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-TOTAL}
        then do :
            <M-6 run AdditionalUpdValBudgetFDSCycle (input  icBudgetTcRowid (icBudgetTcRowid), 
                                         input  icBudgetCode (icBudgetCode), 
                                         input  tBudgetWBS.Budget_ID (iiBudgetWBSID), 
                                         input  iiSafStructureID (iiSafStructureID), 
                                         input  icSafStructureCode (icSafStructureCode), 
                                         input  iiSafDepth (iiSafDepth), 
                                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
            if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
            Return.
        end. /* if tBudgetWBS.BudgetFDSType = {&BUDGETFDSTYPE-TOTAL} */
        
        /* =================== */
        /* Raise the Saf-Depth */
        /* =================== */
        assign iiSafDepth = iiSafDepth + 1.
        
        /* ============================================ */
        /* Check if the SafStructure is still the same  */
        /* ============================================ */
        if tBudgetWBS.SafStructure_ID <> iiSafStructureID
        then do :
            assign oiReturnStatus = -1
                   vcMessage      = trim(#T-7'The SAF structure of this WBS node must match the SAF structure of its highest SAF parent.':255(489)t-7#) + chr(10) + 
                                    trim(substitute(#T-8'Budget: &1.':255(470)T-8#,icBudgetCode)) + chr(10) + 
                                    trim(substitute(#T-9'Budget WBS node: &1.':255(490)T-9#,tBudgetWBS.BudgetWBSCode)) + chr(10) + 
                                    trim(substitute(#T-10'Highest SAF structure (code/ID): &1/&2.':255(491)T-10#,icSafStructureCode,iiSafStructureID)) + chr(10) + 
                                    trim(substitute(#T-11'Current SAF structure (code/ID): &1/&2.':255(492)T-11#,tBudgetWBS.tcSafStructureCode,tBudgetWBS.SafStructure_ID)) + chr(10) + 
                                    trim(substitute(#T-12'SAF structure level: &1.':255(493)T-12#,string(iiSafDepth))).
            <M-1 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  icBudgetTcRowid (icRowid),
                     input  'QADFIN-596':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if tBudgetWBS.SafStructure_ID = 0 */
        
        /* ============================================ */
        /* Check the SafConcept for existance           */
        /* ============================================ */
        <Q-2 run SafConceptCodeByLine (all) (Read) (NoCache)
          (input tBudgetWBS.SafStructure_ID, (SafStructure_ID)
           input iiSafDepth, (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-13'Cannot find the SAF concept of the SAF structure for this WBS node.':255(494)t-13#) + chr(10) + 
                                    trim(substitute(#T-14'Budget: &1.':255(470)T-14#,icBudgetCode)) + chr(10) + 
                                    trim(substitute(#T-15'Budget WBS node: &1.':255(490)T-15#,tBudgetWBS.BudgetWBSCode)) + chr(10) + 
                                    trim(substitute(#T-16'SAF structure (code/ID): &1/&2.':255(495)T-16#,tBudgetWBS.tcSafStructureCode,tBudgetWBS.SafStructure_ID)) + chr(10) + 
                                    trim(substitute(#T-17'SAF structure level: &1.':255(493)T-17#,string(iiSafDepth))).
            <M-3 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  icBudgetTcRowid (icRowid),
                     input  'QADFIN-597':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* of not available tqSafConceptCodeByLine */
        
        /* ================================================================ */
        /* Check the SafConcept of the WBS against the one of the Structure */
        /* ================================================================ */
        if tqSafConceptCodeByLine.tiSafConcept_ID <> tBudgetWBS.SafConcept_ID
        then do :
            assign oiReturnStatus = -1
                   vcMessage      = trim(#T-18'Invalid SAF concept for the SAF structure of this WBS node.':255(496)T-18#) + chr(10) + 
                                    trim(substitute(#T-19'Budget: &1.':255(470)T-19#,icBudgetCode)) + chr(10) + 
                                    trim(substitute(#T-20'Budget WBS node: &1.':255(490)T-20#,tBudgetWBS.BudgetWBSCode)) + chr(10) + 
                                    trim(substitute(#T-21'SAF structure (code/ID): &1/&2.':255(495)T-21#,tBudgetWBS.tcSafStructureCode,tBudgetWBS.SafStructure_ID)) + chr(10) + 
                                    trim(substitute(#T-22'SAF structure level: &1.':255(493)T-22#,"1":U)) + chr(10) + 
                                    trim(substitute(#T-23'SAF concept in WBS (code/ID): &1/&2.':255(497)T-23#,tBudgetWBS.tcSafConceptCode,tBudgetWBS.SafConcept_ID)) + chr(10) +
                                    trim(substitute(#T-24'SAF concept in SAF structure (code/ID): &1/&2.':255(498)T-24#,tqSafConceptCodeByLine.tcSafConceptCode,tqSafConceptCodeByLine.tiSafConcept_ID)).
            <M-4 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  icBudgetTcRowid (icRowid),
                     input  'QADFIN-598':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if tqSafConceptCodeByLine.tiSafConcept_ID <> tBudgetWBS.SafConcept_ID */
        
        /* ============================================== */
        /* Recursively call a method with the same checks */
        /* ============================================== */
        <M-5 run AdditionalUpdValBudgetFDSCycle (input  icBudgetTcRowid (icBudgetTcRowid), 
                                         input  icBudgetCode (icBudgetCode), 
                                         input  tBudgetWBS.Budget_ID (iiBudgetWBSID), 
                                         input  iiSafStructureID (iiSafStructureID), 
                                         input  icSafStructureCode (icSafStructureCode), 
                                         input  iiSafDepth (iiSafDepth), 
                                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
        if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper.
        if oiReturnStatus < 0 then return.
        
    end. /* for each tBudgetFDS */