project QadFinancials > class BBudget > method ApiGetBudgetWBSSafInfoDetails

Description

This method will return the saf-information for a single WBS-node and return the ID of the parent-node of type saf


Parameters


iiBudgetWBSIDinputintegerBudgetWBSID
oiSafConceptIDoutputintegerSafConceptId
ocSafConceptCodeoutputcharacterSAF Concept Code
oiSafIDoutputintegerSafID
ocSafCodeoutputcharacterSAF Code
oiSafStructureIDoutputintegerSafStructureID
ocSafStructureCodeoutputcharacterSafStructureCode
oiNewSafBudgetWBSIDoutputintegerNewSafBudgetWBSID
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBudget.ApiGetBudgetWBSSafInfo


program code (program9/bbudget.p)

/* =========== */
    /* Get the WBS */
    /* =========== */
    if iiBudgetWBSID = 0 or 
       iiBudgetWBSID = ? 
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-10'Internal error: no input was provided to find the SAF data of a WBS node.':255(557)T-10#).
        <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-1305':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if iiBudgetWBSID = 0 or */
    <Q-1 run BudgetWBSByWBSIDSAF (all) (Read) (NoCache)
          (input iiBudgetWBSID, (BudgetWBSID)
           output dataset tqBudgetWBSByWBSIDSAF) in BBudget >
    find first tqBudgetWBSByWBSIDSAF where 
               tqBudgetWBSByWBSIDSAF.tiBudgetWBS_ID = iiBudgetWBSID
               no-lock no-error.
    if not available tqBudgetWBSByWBSIDSAF
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-11'Internal error: cannot find the WBS node based on its ID.':255(558)T-11#) + chr(10) + 
                                trim(SUBSTITUTE(#T-12'Budget WBS ID: &1.':255(550)T-12#,string(iiBudgetWBSID))).
        <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-1306':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if not available tqBudgetWBSByWBSIDSAF */
    
    /* ================================================================== */
    /* Assign the SAF-information + convert the saf-code into the saf-ID  */
    /* ================================================================== */
    assign oiSafStructureID   = tqBudgetWBSByWBSIDSAF.tiSafStructure_ID
           ocSafStructureCode = tqBudgetWBSByWBSIDSAF.tcSafStructureCode
           oiSafConceptID     = tqBudgetWBSByWBSIDSAF.tiSafConcept_ID     
           ocSafConceptCode   = tqBudgetWBSByWBSIDSAF.tcSafConceptCode
           ocSafCode          = tqBudgetWBSByWBSIDSAF.tcBudgetWBSFDSDefault.
    if ocSafCode <> "":U and 
       ocSafCode <> ?
    then do :
        <Q-4 run SafByIdCodeConceptID (all) (Read) (NoCache)
          (input oiSafConceptID, (SafConcept_ID)
           input ocSafCode, (SafCode)
           input ?, (SafID)
           output dataset tqGetSafForSafConcept) in BSaf >
        find tqGetSafForSafConcept where 
             tqGetSafForSafConcept.tiSafConcept_ID = oiSafConceptID and 
             tqGetSafForSafConcept.tcSafCode       = ocSafCode
             no-lock no-error.
        if not available tqGetSafForSafConcept
        then do :
            assign oiReturnStatus = -3
                   vcMessage      = trim(#T-13'Internal error: the SAF ID based on the SAF code of a WBS node is missing.':255(559)T-13#) + chr(10) + 
                                    trim(SUBSTITUTE(#T-14'Budget WBS ID: &1.':255(560)T-14#,string(iiBudgetWBSID))) + chr(10) + 
                                    trim(SUBSTITUTE(#T-15'SAF Code: &1.':255(561)T-15#,string(ocSafCode))) + chr(10) + 
                                    trim(SUBSTITUTE(#T-16'SAF concept ID: &1.':255(562)T-16#,string(oiSafConceptID))).
            <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-1308':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if not available tqGetSafForSafConcept */
        assign oiSafID = tqGetSafForSafConcept.tiSaf_ID.
    end. /* if ocSafCode <> "":U and */
    
    /* ==================================================================== */
    /* Skip in case there is no parent anymore                              */
    /* ==================================================================== */
    if tqBudgetWBSByWBSIDSAF.tiParentBudgetWBS_ID = ? or 
       tqBudgetWBSByWBSIDSAF.tiParentBudgetWBS_ID = 0
    then do :
        assign oiNewSafBudgetWBSID = ?.
        return.
    end. /* if tqBudgetWBSByWBSIDSAF.tiParentBudgetWBS_ID = ? or */
    
    /* ==================================================================== */
    /* Get the parent                                                       */
    /* ==================================================================== */
    <Q-8 run BudgetWBSByBudgetIDWBSCode (all) (Read) (NoCache)
          (input ?, (BudgetID)
           input tqBudgetWBSByWBSIDSAF.tiParentBudgetWBS_ID, (BudgetWBSID)
           input ?, (BudgetWBSCode)
           input ?, (ParentBudgetWBSID)
           input ?, (BudgetCode)
           input ?, (BudgetStatus)
           output dataset tqBudgetWBSByBudgetID) in BBudget >
    find first tqBudgetWBSByBudgetID where 
               tqBudgetWBSByBudgetID.tiBudgetWBS_ID = tqBudgetWBSByWBSIDSAF.tiParentBudgetWBS_ID
               no-lock no-error.
    if not available tqBudgetWBSByBudgetID
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-17'Internal error: the parent node of a WBS node is missing.':255(563)T-17#) + chr(10) + 
                                trim(SUBSTITUTE(#T-18'Budget WBS ID: &1.':255(550)T-18#,string(iiBudgetWBSID))) + chr(10) + 
                                trim(SUBSTITUTE(#T-19'Parent ID of the budget WBS: &1.':255(564)T-19#,string(tqBudgetWBSByWBSIDSAF.tiParentBudgetWBS_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-2121':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if not available tqBudgetWBSByBudgetID */        
    
    /* ==================================================================== */
    /* Get the parent repeatively for TOTAL                                 */
    /* ==================================================================== */
    do viCounter = 5 to 1 by -1 : 
        if not available tqBudgetWBSByBudgetID            or
           tqBudgetWBSByBudgetID.tiParentBudgetWBS_ID = 0 or
           tqBudgetWBSByBudgetID.tiParentBudgetWBS_ID = ? or
           tqBudgetWBSByBudgetID.tcBudgetFDSType <> {&BUDGETFDSTYPE-TOTAL} 
        then leave.
        assign viParentBudgetWBSIDTemp = tqBudgetWBSByBudgetID.tiParentBudgetWBS_ID.
        <Q-6 run BudgetWBSByBudgetIDWBSCode (all) (Read) (NoCache)
          (input ?, (BudgetID)
           input viParentBudgetWBSIDTemp, (BudgetWBSID)
           input ?, (BudgetWBSCode)
           input ?, (ParentBudgetWBSID)
           input ?, (BudgetCode)
           input ?, (BudgetStatus)
           output dataset tqBudgetWBSByBudgetID) in BBudget >
        find first tqBudgetWBSByBudgetID where 
                   tqBudgetWBSByBudgetID.tiBudgetWBS_ID = viParentBudgetWBSIDTemp
                   no-lock no-error.
        if not available tqBudgetWBSByBudgetID
        then do :
            assign oiReturnStatus = -3.
                   vcMessage      = trim(#T-20'Internal error: the parent node of a WBS node is missing.':255(563)T-20#) + chr(10) + 
                                    trim(SUBSTITUTE(#T-21'Budget WBS ID: &1.':255(550)T-21#,string(iiBudgetWBSID))) + chr(10) + 
                                    trim(SUBSTITUTE(#T-22'Parent ID of the budget WBS: &1.':255(564)T-22#,string(viParentBudgetWBSIDTemp))).
            <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-1309':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if not available tqBudgetWBSByBudgetID */
        if tqBudgetWBSByBudgetID.tcBudgetFDSType <> {&BUDGETFDSTYPE-TOTAL} and 
           tqBudgetWBSByBudgetID.tcBudgetFDSType <> {&BUDGETFDSTYPE-SAF} 
        then leave.
    end. /* do Counter */
    
    /* ============================================================================ */
    /* If the parent is not a SAF then we set the output to ? else it gets assigned */
    /* ============================================================================ */
    if tqBudgetWBSByBudgetID.tcBudgetFDSType <> {&BUDGETFDSTYPE-SAF} 
    then do :
        assign oiNewSafBudgetWBSID = ?.
        return.
    end. /* if tqBudgetWBSByBudgetID.tcBudgetFDSType <> {&BUDGETFDSTYPE-SAF} */
    assign oiNewSafBudgetWBSID = tqBudgetWBSByBudgetID.tiBudgetWBS_ID.