project QadFinancials > class BBudget > method BudgetCheckInfoResolveCyPrjCC

Description

This submethod of BudgetCheckInfoResolve will assign the CompanyID/ProjectID/CostCentreID in the input-table based on the Codes and remove lines with a GL that is not enabled for Budgetting by assigned


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBudget.BudgetCheckInfoResolve


program code (program8/bbudget.p)

/* ================= */
    /* Start Block       */
    /* ================= */
    MAINBLOCKCYPRJCC : DO :
    
        /* ============================================== */
        /* State the Company_ID based on the Company-code */
        /* ============================================== */
        if can-find (first tBudgetCheckInfo where 
                           tBudgetCheckInfo.tcCompanyCode <> "":U    and 
                           tBudgetCheckInfo.tcCompanyCode <> ?       and
                           (tBudgetCheckInfo.tiCompanyID = 0 or 
                            tBudgetCheckInfo.tiCompanyID = ?))
        then do :
            <Q-17 run CompanyPrim (all) (Read) (NoCache)
          (input ?, (LookupCompanyId)
           input ?, (CompanyCode)
           output dataset tqCompanyPrim) in BCompany >
            for each tBudgetCheckInfo where 
                     tBudgetCheckInfo.tcCompanyCode <> "":U    and 
                     tBudgetCheckInfo.tcCompanyCode <> ?       and
                     (tBudgetCheckInfo.tiCompanyID = 0 or 
                      tBudgetCheckInfo.tiCompanyID = ?)
                     by tBudgetCheckInfo.tcCompanyCode :
                find tqCompanyPrim where 
                     tqCompanyPrim.tcCompanyCode = tBudgetCheckInfo.tcCompanyCode
                     no-lock no-error.
                if available tqCompanyPrim
                then assign tBudgetCheckInfo.tiCompanyID = tqCompanyPrim.tiCompany_ID.
                else do :
                    assign oiReturnStatus = -1
                           vcMessage      = trim(substitute(#T-29'The specified entity code (&1) is not defined in the system or is invalid. The budget check rejected the input information:':255(16418)t-29#,tBudgetCheckInfo.tcCompanyCode)) + chr(10) + 
                                            trim(substitute(#T-30'Project: &1.':255(708)T-30#,tBudgetCheckInfo.tcCompanyCode)) + chr(10) + 
                                            trim(substitute(#T-31'Entity: &1.':255(353)T-31#,(if tBudgetCheckInfo.tiCompanyId = ? then "?":U else string(tBudgetCheckInfo.tiCompanyId)))).
                    <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-3983':U (icFcMsgNumber),
                             input  '' (icFcExplanation),
                             input  '' (icFcIdentification),
                             input  '' (icFcContext),
                             output viFcReturnSuper (oiReturnStatus)) in BBudget>
                    Leave MAINBLOCKCYPRJCC.
                end. /* if not available */                                       
            end. /* for each */        
        end. /* if */
        
        /* ============================================== */
        /* State the GlIsWithBudget when unknown          */
        /* Remove GLs that are not allowed for Budgetting */
        /* ============================================== */
        if can-find (first tBudgetCheckInfo where 
                           tBudgetCheckInfo.tiCompanyId      <> 0       and 
                           tBudgetCheckInfo.tiCompanyId      <> ?       and 
                           tBudgetCheckInfo.tlGLIsWithBudget = ?        and
                           ((tBudgetCheckInfo.tcGLCode <> "":U and 
                             tBudgetCheckInfo.tcGLCode <> ?)      or  
                            (tBudgetCheckInfo.tiGLID <> 0      and 
                             tBudgetCheckInfo.tiGLID <> ?)))
        then do :
            <Q-19 run GLByCodeIDIsWithBudget (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input ?, (GLCode)
           input ?, (GLID)
           input true, (GLIsWithBudget)
           output dataset tqGLByCodeIDIsWithBudget) in BGL >
            for each tBudgetCheckInfo where 
                     tBudgetCheckInfo.tiCompanyId      <> 0       and 
                     tBudgetCheckInfo.tiCompanyId      <> ?       and 
                     ((tBudgetCheckInfo.tcGLCode <> "":U and 
                       tBudgetCheckInfo.tcGLCode <> ?)      or  
                      (tBudgetCheckInfo.tiGLID <> 0      and 
                       tBudgetCheckInfo.tiGLID <> ?)):
                find tqGLByCodeIDIsWithBudget where                                
                     tqGLByCodeIDIsWithBudget.tiGL_ID  = tBudgetCheckInfo.tiGLID or
                     tqGLByCodeIDIsWithBudget.tcGLCode = tBudgetCheckInfo.tcGLCode 
                     no-lock no-error.
                if available tqGLByCodeIDIsWithBudget
                then assign tBudgetCheckInfo.tiGLID           = tqGLByCodeIDIsWithBudget.tiGL_ID 
                            tBudgetCheckInfo.tcGLCode         = tqGLByCodeIDIsWithBudget.tcGLCode
                            tBudgetCheckInfo.tlGLIsWithBudget = tqGLByCodeIDIsWithBudget.tlGLIsWithBudget.
                else assign tBudgetCheckInfo.tlGLIsWithBudget = false.
                if tBudgetCheckInfo.tlGLIsWithBudget <> true
                then delete tBudgetCheckInfo.
            end. /* for each */
        end. /* if */
        
        /* ============================================== */
        /* State the project_ID based on the project-code */
        /* ============================================== */
        if can-find (first tBudgetCheckInfo where 
                           tBudgetCheckInfo.tiCompanyId   <> 0       and 
                           tBudgetCheckInfo.tiCompanyId   <> ?       and 
                           tBudgetCheckInfo.tcProjectCode <> "":U    and 
                           tBudgetCheckInfo.tcProjectCode <> ?       and
                           (tBudgetCheckInfo.tiProjectID = 0 or 
                            tBudgetCheckInfo.tiProjectID = ?))
        then do :
            <Q-5 run ProjectPrim (Start) in BProject >
            BLOCKPROJECT : DO :
                for each tBudgetCheckInfo where 
                         tBudgetCheckInfo.tiCompanyId   <> 0       and 
                         tBudgetCheckInfo.tiCompanyId   <> ?       and 
                         tBudgetCheckInfo.tcProjectCode <> "":U    and 
                         tBudgetCheckInfo.tcProjectCode <> ?       and
                         (tBudgetCheckInfo.tiProjectID = 0 or 
                          tBudgetCheckInfo.tiProjectID = ?)
                         by tBudgetCheckInfo.tcProjectCode :
                    find tqProjectPrim where 
                         tqProjectPrim.tcProjectCode = tBudgetCheckInfo.tcProjectCode
                         no-lock no-error.
                    if not available tqProjectPrim
                    then do :
                       <Q-7 run ProjectPrim (all) (Read) (NoCache)
          (input tBudgetCheckInfo.tiCompanyId, (CompanyId)
           input ?, (ProjectID)
           input tBudgetCheckInfo.tcProjectCode, (ProjectCode)
           output dataset tqProjectPrim) in BProject >
                        find tqProjectPrim where 
                             tqProjectPrim.tcProjectCode = tBudgetCheckInfo.tcProjectCode
                             no-lock no-error.
                    end. /* if not available tqProjectPrim */
                    if available tqProjectPrim
                    then assign tBudgetCheckInfo.tiProjectID = tqProjectPrim.tiProject_ID.
                    else do :
                        assign oiReturnStatus = -1
                               vcMessage      = trim(#T-21'The specified project is not defined in the system or is invalid. The budget check rejected the input information:':255(707)t-21#) + chr(10) + 
                                                trim(substitute(#T-22'Project: &1.':255(708)T-22#,tBudgetCheckInfo.tcProjectCode)) + chr(10) + 
                                                trim(substitute(#T-23'Entity: &1.':255(353)T-23#,string(tBudgetCheckInfo.tiCompanyId))).
                        <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-3981':U (icFcMsgNumber),
                                 input  '' (icFcExplanation),
                                 input  '' (icFcIdentification),
                                 input  '' (icFcContext),
                                 output viFcReturnSuper (oiReturnStatus)) in BBudget>
                        Leave BLOCKPROJECT.
                    end. /* if not available */
                end. /* for each */
            END. /* BLOCKPROJECT */
            <Q-6 run ProjectPrim  (Stop) in BProject >
            if oiReturnStatus < 0 
            then Leave MAINBLOCKCYPRJCC.
        end. /* if */
                     
        /* ==================================================== */
        /* State the CostCentre_ID based on the CostCentre-code */
        /* ==================================================== */
        if can-find (first tBudgetCheckInfo where 
                           tBudgetCheckInfo.tiCompanyId   <> 0       and 
                           tBudgetCheckInfo.tiCompanyId   <> ?       and 
                           tBudgetCheckInfo.tcCostCentreCode <> "":U    and 
                           tBudgetCheckInfo.tcCostCentreCode <> ?       and
                           (tBudgetCheckInfo.tiCostCentreID = 0 or 
                            tBudgetCheckInfo.tiCostCentreID = ?))
        then do :
            <Q-11 run CostCentrePrim  (Start) in BCostCentre > 
            BLOCKCOSTCENTRE : DO :
                for each tBudgetCheckInfo where 
                         tBudgetCheckInfo.tiCompanyId   <> 0       and 
                         tBudgetCheckInfo.tiCompanyId   <> ?       and 
                         tBudgetCheckInfo.tcCostCentreCode <> "":U and 
                         tBudgetCheckInfo.tcCostCentreCode <> ?    and
                         (tBudgetCheckInfo.tiCostCentreID = 0 or 
                          tBudgetCheckInfo.tiCostCentreID = ?) 
                         by tBudgetCheckInfo.tcCostCentreCode :
                    find tqCostCentrePrim where 
                         tqCostCentrePrim.tcCostCentreCode = tBudgetCheckInfo.tcCostCentreCode
                         no-lock no-error.
                    if not available tqCostCentrePrim
                    then do :
                        <Q-13 run CostCentrePrim (all) (Read) (NoCache)
          (input tBudgetCheckInfo.tiCompanyId, (CompanyId)
           input ?, (CostCentreID)
           input tBudgetCheckInfo.tcCostCentreCode, (CostCentreCode)
           output dataset tqCostCentrePrim) in BCostCentre >
                        find tqCostCentrePrim where 
                             tqCostCentrePrim.tcCostCentreCode = tBudgetCheckInfo.tcCostCentreCode
                             no-lock no-error.
                    end. /* if not available tqCostCentrePrim */
                    if available tqCostCentrePrim
                    then assign tBudgetCheckInfo.tiCostCentreID = tqCostCentrePrim.tiCostCentre_ID.
                    else do :
                        assign oiReturnStatus = -1
                               vcMessage      = trim(#T-25'The specified cost center is not defined in the system or is invalid. The budget check rejected the input information:':255(709)t-25#) + chr(10) + 
                                                trim(substitute(#T-26'Cost center: &1.':255(710)T-26#,tBudgetCheckInfo.tcCostCentreCode)) + chr(10) + 
                                                trim(substitute(#T-27'Entity: &1.':255(353)T-27#,string(tBudgetCheckInfo.tiCompanyId))).
                        <M-24 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-3982':U (icFcMsgNumber),
                             input  '' (icFcExplanation),
                             input  '' (icFcIdentification),
                             input  '' (icFcContext),
                             output viFcReturnSuper (oiReturnStatus)) in BBudget>
                        Leave BLOCKCOSTCENTRE.
                    end. /* if not available */
                end. /* for each */
            END. /* BLOCKCOSTCENTRE */
            <Q-12 run CostCentrePrim  (Stop) in BCostCentre >
            if oiReturnStatus < 0 
            then Leave MAINBLOCKCYPRJCC.
        end. /* if */
        
    END. /* MAINBLOCKCYPRJCC */
    
    
    /* ============================================= */
    /* Empty result-sets for single executed queries */
    /* Return in case of errors                      */
    /* ============================================= */
    empty temp-table tqCompanyPrim.
    empty temp-table tqGLByCodeIDIsWithBudget.
    if oiReturnStatus < 0 
    then return.