project QadFinancials > class BBudget > method BudgetWBSCreateMultipleGetInfo

Description

This method that returns information that is required on the UI before starting request 'Create Multiple BudgetWBS nodes':
It will return the FDStype, SafStructure and SafConcept for the new nodes


Parameters


icBudgetTcRowidinputcharacterBudget; BudgetTcRowid
icBudgetWBSTcRowidinputcharacterBudgetWBSTcRowid; tc_rowid of the current node you are on
ilCreateChildinputlogicalCreateChild
ocBudgetFDSTypeoutputcharacterBudgetFDSType of the new nodes
ocSafStructureCodeoutputcharacterSafStructureCode
ocSafConceptCodeoutputcharacterSAF Concept Code
olIsHighestSafLeveloutputlogicalIsHighestSafLevel
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program6/bbudget.p)

/* ==================================================================================================== */
    /* 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 icBudgetTcRowid = "":U or icBudgetTcRowid = ?
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-10'You must enter the budget identification (row ID) to create multiple budget topics.':255(698)t-10#).
        <M-1 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-875':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-11'Cannot find the budget based on its row ID (&1).':255(448)t-11#,string(icBudgetTcRowid))).
            <M-2 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-876':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-12'Cannot create multiple child topics for the budget WBS without specifying the current topic.':255(666)t-12#).
        <M-3 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-877':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if icBudgetWBSTcRowid  = "":U and */
    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-13'Cannot find the current budget WBS topic based on its row ID &1.':255(450)t-13#,string(icBudgetWBSTcRowid))).
            <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-878':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-14'You must validate the budget structure before maintaining the WBS.':255(451)t-14#).
        <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-879':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 vdParentBudgetWBSSeq */
    /* 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-15'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-15#,string(tBudgetWBS.BudgetFDSSeq + 1))).
            <M-6 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-880':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if not available tBudgetFDS */
        assign ocBudgetFDSType = tBudgetFDS.BudgetFDSType.
        /* State if this is the heighest Saf-level */
        if tBudgetFDS.BudgetFDSType <> {&BUDGETFDSTYPE-SAF}
        then assign olIsHighestSafLevel = false.
        else do :
            if can-find (first tBudgetFDS where                                     
                               tBudgetFDS.tc_ParentRowid  = tBudget.tc_Rowid         and 
                               tBudgetFDS.BudgetFDSSeq    < tBudgetWBS.BudgetFDSSeq  and
                               tBudgetFDS.tc_Status      <> "D":U                    and 
                               tBudgetFDS.BudgetFDSType   = {&BUDGETFDSTYPE-SAF})
            then assign olIsHighestSafLevel = false.
            else assign olIsHighestSafLevel = true.
        end. /* if tBudgetFDS.BudgetFDSType <> {&BUDGETFDSTYPE-SAF} */
    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-16'The system cannot create a root budget WBS topic because it cannot find the first level of the budget COA.':255(582)t-16#).
            <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-881':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if not available tBudgetFDS */
        assign ocBudgetFDSType      = tBudgetFDS.BudgetFDSType.
        /* State if this is the heighest Saf-level */
        assign olIsHighestSafLevel = (tBudgetFDS.BudgetFDSType = {&BUDGETFDSTYPE-SAF}).
        /* ========================================================================= */
        /* No further actions required if the new nodes are on the highest FDS-level */
        /* ========================================================================= */
        Return.
    end. /* not if available tBudgetWBS */
    
    /* ===================================================================== */
    /* No further actions required in case the new nodes are not of type SAF */
    /* ===================================================================== */
    if ocBudgetFDSType <> {&BUDGETFDSTYPE-SAF}
    then return.
    
    /* ============================================================================ */
    /* To find out the saf-concept, we go up the WBS-tree to the highest SAF-node   */
    /* There we find the structure and then we can get the concept of the structure */
    /* ============================================================================ */
    /* ====================================================================================== */
    /* 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 ocBudgetFDSType = {&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 SAFSETTINGSMULTIPLEBLOCK : 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 SAFSETTINGSMULTIPLEBLOCK.
        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 SAFSETTINGSMULTIPLEBLOCK.
        assign ocSafStructureCode  = bBudgetWBS.tcSafStructureCode.
        /* Get the safstructure of the tBudgetWBS record */
        <Q-8 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-17'Cannot define level &1 of the SAF structure &2.':255(583)t-17#,string(viSAFCyclingCounter),string(bBudgetWBS.SafStructure_ID))).
            <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-882':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if not av. tqSafConceptCodeByLine */
        assign ocSafConceptCode = tqSafConceptCodeByLine.tcSafConceptCode.
    end. /* if vcNewRecordFDSType = {&BUDGETFDSTYPE-SAF} */