project QadFinancials > class BBudget > method ValidateComponentValidateStructDet

Description

This method is the submethod of ValidateComponentValidateStruct because it could not contain all code


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBudget.ValidateComponentValidateStruct


program code (program5/bbudget.p)

<Q-33 run ProjectPrim  (Start) in BProject >
    <Q-35 run CostCentrePrim  (Start) in BCostCentre >
    /* ======================================================= */
    /* Go through all non deleted budgets                      */
    /* ======================================================= */
    for each tNewBudget where 
             tNewBudget.tc_Status <> "D":U :
        
        /* ======================================================= */
        /* We can only have a single budget for a project          */
        /* We can only have 1 operationla budget for a cost-centre */
        /* ======================================================= */
        /* ========================================= */
        /* Check other budget for the same CC or Prj */
        /* ========================================= */
        if tNewBudget.tcProjectCode <> "":U and 
           tNewBudget.tcProjectCode <> ?
        then do :
            if tNewBudget.BudgetStatus  = {&BUDGETSTATUS-OPERATIONAL}
            then do:
                find first btNewBudget where 
                           btNewBudget.tc_Rowid      <> tNewBudget.tc_Rowid and 
                           btNewBudget.tc_status     <> "D":U              and
                           btNewBudget.BudgetStatus   = {&BUDGETSTATUS-OPERATIONAL} and 
                           btNewBudget.tcProjectCode  = tNewBudget.tcProjectCode
                           no-lock no-error.
                if available btNewBudget
                then do :
                    assign oiReturnStatus = -1
                           vcMessage      = trim(substitute(#T-18'Duplicate operational budgets (&1 / &2) detected for a single project (&3).':255(17333)T-18#, tNewBudget.BudgetCode, btNewBudget.BudgetCode, tNewBudget.tcProjectCode)).
                    <M-1 run SetMessage (input  vcMessage (icMessage),
                         input  '':U (icArguments),
                         input  'tBudget.tcProjectCode':U (icFieldName),
                         input  tNewBudget.tcProjectCode (icFieldValue),
                         input  'E':U (icType),
                         input  3 (iiSeverity),
                         input  tNewBudget.tc_Rowid (icRowid),
                         input  'QADFIN-1286':U (icFcMsgNumber),
                         input  '' (icFcExplanation),
                         input  '' (icFcIdentification),
                         input  '' (icFcContext),
                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
                end. /* if available btNewBudget */
                else do :
                    if tNewBudget.tcProjectCode <> "":U and tNewBudget.tcProjectCode <> ?
                    then do:
                       <Q-31 run ProjectPrim (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input ?, (ProjectID)
           input tNewBudget.tcProjectCode, (ProjectCode)
           output dataset tqProjectPrim) in BProject >
                       find first tqProjectPrim no-error.
                       assign tNewBudget.Project_ID = if available tqProjectPrim
                                                      then tqProjectPrim.tiProject_ID
                                                      else 0.
                    end.
                    <Q-2 run BudgetByProjectCostCentre (first) (Read) (NoCache)
          (input ?, (CompanyId)
           input ?, (CostCentreCode)
           input ?, (CostCentreID)
           input if tNewBudget.Project_ID = ? or tNewBudget.Project_ID = 0 then tNewBudget.tcProjectCode else '':U, (ProjectCode)
           input tNewBudget.Project_ID, (ProjectID)
           input string(tNewBudget.tc_rowid), (RowidToSkip)
           input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus)
           output dataset tqBudgetByProjectCostCentre) in BBudget >
                    find first tqBudgetByProjectCostCentre where
                               tqBudgetByProjectCostCentre.tiProject_ID   = tNewBudget.Project_ID and
                               tqBudgetByProjectCostCentre.tcBudgetStatus = {&BUDGETSTATUS-OPERATIONAL} and
                               tqBudgetByProjectCostCentre.tc_rowid       <> tNewBudget.tc_Rowid
                               no-lock no-error.
                    if available tqBudgetByProjectCostCentre
                    then do :
                        assign oiReturnStatus = -1
                               vcMessage      = trim(substitute(#T-19'Duplicate operational budgets (&1 / &2) detected for a single project (&3).':255(17333)T-19#, tNewBudget.BudgetCode, tqBudgetByProjectCostCentre.tcBudgetCode, tNewBudget.tcProjectCode)).
                        <M-3 run SetMessage (input  vcMessage (icMessage),
                         input  '':U (icArguments),
                         input  'tBudget.tcProjectCode':U (icFieldName),
                         input  tNewBudget.tcProjectCode (icFieldValue),
                         input  'E':U (icType),
                         input  3 (iiSeverity),
                         input  tNewBudget.tc_Rowid (icRowid),
                         input  'QADFIN-1287':U (icFcMsgNumber),
                         input  '' (icFcExplanation),
                         input  '' (icFcIdentification),
                         input  '' (icFcContext),
                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
                    end. /* if available tqBudgetByProjectCostCentre */
                end. /* not if available btNewBudget */
            end.
            /* ======================================================================== */
            /* The BudgetCurrency should match the ProjectCurrency when both are filled */
            /* ======================================================================== */
            find first tNewBudgetCompany where 
                       tNewBudgetCompany.Budget_ID  = tNewBudget.Budget_ID and 
                       tNewBudgetCompany.Company_ID <> 0                   and 
                       tNewBudgetCompany.Company_ID <> ?
                       no-lock no-error. 
            <Q-7 run ProjectByCode (all) (Read) (NoCache)
          (input (if available tNewBudgetCompany then tNewBudgetCompany.Company_ID else viCompanyId), (CompanyId)
           input tNewBudget.tcProjectCode, (ProjectCode)
           output dataset tqProjectByCode) in BProject >
            find first tqProjectByCode where 
                       tqProjectByCode.tcProjectCode = tNewBudget.tcProjectCode 
                       no-lock no-error.
            if available tqProjectByCode              and 
               tqProjectByCode.tcCurrencyCode <> "":U and 
               tqProjectByCode.tcCurrencyCode <> ?    and 
               tqProjectByCode.tcCurrencyCode <> tNewBudget.tcCurrencyCode
            then do :
                assign oiReturnStatus = -1
                       vcMessage      = trim(substitute(#T-20'The currency of a project budget (&1) should match the currency of the project (&2/&3).':255(453)T-20#, tNewBudget.BudgetCode, tNewBudget.tcProjectCode, tqProjectByCode.tcCurrencyCode)).
                <M-8 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  'tBudget.tcCostCentreCode':U (icFieldName),
                     input  tNewBudget.tcCostCentreCode (icFieldValue),
                     input  'E':U (icType),
                     input  3 (iiSeverity),
                     input  tNewBudget.tc_Rowid (icRowid),
                     input  'QADFIN-1598':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            end. /* if available tqProjectByCode  and */
            
        end. /* if tNewBudget.tcProjectCode <> "":U and */
        if tNewBudget.tcCostCentreCode <> "":U and 
           tNewBudget.tcCostCentreCode <> ? 
        then do :
            if tNewBudget.BudgetStatus  = {&BUDGETSTATUS-OPERATIONAL}
            then do:
                find first btNewBudget where 
                           btNewBudget.tc_Rowid         <> tNewBudget.tc_Rowid         and 
                           btNewBudget.tc_status        <> "D":U                       and
                           btNewBudget.BudgetStatus      = {&BUDGETSTATUS-OPERATIONAL} and 
                           btNewBudget.tcCostCentreCode  = tNewBudget.tcCostCentreCode
                           no-lock no-error.
                if available btNewBudget
                then do :
                    assign oiReturnStatus = -1
                           vcMessage      = trim(substitute(#T-21'Duplicate operational budgets (&1 / &2) detected for a single cost center (&3).':255(454)T-21#, tNewBudget.BudgetCode, btNewBudget.BudgetCode, tNewBudget.tcCostCentreCode)).
                    <M-4 run SetMessage (input  vcMessage (icMessage),
                         input  '':U (icArguments),
                         input  'tBudget.tcCostCentreCode':U (icFieldName),
                         input  tNewBudget.tcCostCentreCode (icFieldValue),
                         input  'E':U (icType),
                         input  3 (iiSeverity),
                         input  tNewBudget.tc_Rowid (icRowid),
                         input  'QADFIN-1288':U (icFcMsgNumber),
                         input  '' (icFcExplanation),
                         input  '' (icFcIdentification),
                         input  '' (icFcContext),
                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
                end. /* if available btNewBudget */
                else do :
                    if (tNewBudget.CostCentre_ID = ? or tNewBudget.CostCentre_ID = 0) and
                        tNewBudget.tcCostCentreCode <> "":U and tNewBudget.tcCostCentreCode <> ?
                    then do:
                        <Q-32 run CostCentrePrim (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input ?, (CostCentreID)
           input tNewBudget.tcCostCentreCode, (CostCentreCode)
           output dataset tqCostCentrePrim) in BCostCentre >
                        find first tqCostCentrePrim no-error.
                        assign tNewBudget.CostCentre_ID = if available tqCostCentrePrim
                                                          then tqCostCentrePrim.tiCostCentre_ID
                                                          else 0.
                    end.
                    assign vcCostCentreCode = if tNewBudget.CostCentre_ID = ? or tNewBudget.CostCentre_ID = 0 then tNewBudget.tcCostCentreCode else "":U.
                    <Q-5 run BudgetByProjectCostCentre (first) (Read) (NoCache)
          (input ?, (CompanyId)
           input vcCostCentreCode, (CostCentreCode)
           input tNewBudget.CostCentre_ID, (CostCentreID)
           input ?, (ProjectCode)
           input ?, (ProjectID)
           input string(tNewBudget.tc_rowid), (RowidToSkip)
           input {&BUDGETSTATUS-OPERATIONAL}, (BudgetStatus)
           output dataset tqBudgetByProjectCostCentre) in BBudget >
                    find first tqBudgetByProjectCostCentre where
                               tqBudgetByProjectCostCentre.tiCostCentre_ID = tNewBudget.CostCentre_ID and
                               tqBudgetByProjectCostCentre.tcBudgetStatus  = {&BUDGETSTATUS-OPERATIONAL} and
                               tqBudgetByProjectCostCentre.tc_rowid       <> tNewBudget.tc_Rowid
                               no-lock no-error.
                    if available tqBudgetByProjectCostCentre
                    then do :
                        assign oiReturnStatus = -1
                               vcMessage      = trim(substitute(#T-22'Duplicate operational budgets (&1 / &2) detected for a single cost center (&3).':255(454)T-22#, tNewBudget.BudgetCode, tqBudgetByProjectCostCentre.tcBudgetCode, tNewBudget.tcCostCentreCode)).
                        <M-6 run SetMessage (input  vcMessage (icMessage),
                         input  '':U (icArguments),
                         input  'tBudget.tcCostCentreCode':U (icFieldName),
                         input  tNewBudget.tcCostCentreCode (icFieldValue),
                         input  'E':U (icType),
                         input  3 (iiSeverity),
                         input  tNewBudget.tc_Rowid (icRowid),
                         input  'QADFIN-1289':U (icFcMsgNumber),
                         input  '' (icFcExplanation),
                         input  '' (icFcIdentification),
                         input  '' (icFcContext),
                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
                    end. /* if available tqBudgetByProjectCostCentre */
                end. /* not if available btNewBudget */
            end.
        end. /* if tNewBudget.tcCostCentreCode <> "":U and */
        
        /* ====================================================================== */
        /* Budget Periods                                                         */
        /*   The dates should be consecutive                                      */
        /*   The Seq-field should be set based on the From-dates: Assign it here  */
        /* ====================================================================== */
        assign vcMessage = "":U.
        NEWBUDGETPERIODLOCK : Do : 
            assign viNewRecordCounter = 0.
            for each tNewBudgetPeriod where
                     tNewBudgetPeriod.tc_ParentRowid  = tNewBudget.tc_Rowid and 
                     tNewBudgetPeriod.tc_Status      <> "D":U
                     by tNewBudgetPeriod.BudgetPeriodFromDate :
                if tNewBudgetPeriod.BudgetPeriodFromDate > tNewBudgetPeriod.BudgetPeriodTillDate
                then do :
                    assign vcMessage = trim(substitute(#T-38'The From Date (&1) of a Budget Period should precede the To Date (&2). Budget: &3.':251(53197)T-38#,string(tNewBudgetPeriod.BudgetPeriodFromDate,"99/99/9999":U),string(tNewBudgetPeriod.BudgetPeriodTillDate,"99/99/9999":U),tNewBudget.BudgetCode)).
                    Leave NEWBUDGETPERIODLOCK.
                end. /* if vtPreviousPeriodEndDate <> ? and */
                assign viNewRecordCounter = viNewRecordCounter + 1.
                if vtPreviousPeriodEndDate <> ? and 
                   tNewBudgetPeriod.BudgetPeriodFromDate <> vtPreviousPeriodEndDate + 1
                then do :
                    assign vcMessage = trim(substitute(#T-23'Budget periods must be consecutive. The period with the start date &1 and the end date &2 is not consecutive to the previous period with end date &3.':255(455)t-23#,string(tNewBudgetPeriod.BudgetPeriodFromDate,"99/99/9999":U),string(tNewBudgetPeriod.BudgetPeriodTillDate,"99/99/9999":U),string(vtPreviousPeriodEndDate,"99/99/9999":U))).
                    Leave NEWBUDGETPERIODLOCK.
                end. /* if vtPreviousPeriodEndDate <> ? and */
                assign vtPreviousPeriodEndDate = tNewBudgetPeriod.BudgetPeriodTillDate.
                if tNewBudgetPeriod.BudgetPeriodSeq <> viNewRecordCounter
                then do :
                    assign tNewBudgetPeriod.BudgetPeriodSeq = viNewRecordCounter.
                    if tNewBudgetPeriod.tc_Status = "":U then assign tNewBudgetPeriod.tc_Status = "C":U.
                end. /* if tNewBudgetPeriod.BudgetPeriodSeq <> viNewRecordCounter */
            end. /* for each tNewBudgetPeriod */
            if viNewRecordCounter = 0
            then do :
                assign vcMessage = trim(#T-24' No budget period was found. You must define budget periods to use budgets.':255(456)t-24#).
                Leave NEWBUDGETPERIODLOCK.
            end. /* if viNewRecordCounter = 0 */
            if viNewRecordCounter > 24 and 
               ((tNewBudget.Project_ID       <> 0    and tNewBudget.Project_ID       <> ?) or
                (tNewBudget.CostCentre_ID    <> 0    and tNewBudget.CostCentre_ID    <> ?) or
                (tNewBudget.tcProjectCode    <> "":U and tNewBudget.tcProjectCode    <> ?) or
                (tNewBudget.tcCostCentreCode <> "":U and tNewBudget.tcCostCentreCode <> ?))
            then assign vcMessage = trim(#T-25'The maximum number of periods for project and cost center budgets is 24.':255(457)T-25#).
            else if viNewRecordCounter > 54
                 then assign vcMessage = trim(#T-26'Maximum number of periods for budgets is 54.':255(458)T-26#).
        END. /* NEWBUDGETPERIODLOCK */
        if vcMessage <> "":U
        then do :
            assign oiReturnStatus = -1.
            <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-1611':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        end. /* if vcMessage <> "":U */
        
        if tNewBudget.BudgetIsFRWLinked <> true
        then do:
            /* =============================================================================== */
            /* State SharedSet-ID's on the header and check this with the mentioned companies  */
            /* =============================================================================== */
            assign vcMessage = "":U.
            <Q-10 run CompanySSByCompanyIDCodeSSType (Start) in BCompany >
            NEWBUDGETCOMPANYBUDGETBLOCK : Do :
                find first tNewBudgetCompany where
                           tNewBudgetCompany.tc_ParentRowid  = tNewBudget.tc_Rowid and 
                           tNewBudgetCompany.tcCompanyCode  <> "":U                and 
                           tNewBudgetCompany.tcCompanyCode  <> ?                   and 
                           tNewBudgetCompany.tc_Status      <> "D":U
                           no-lock no-error. /* no-error was checked in the beginning of this method but there was no error */
                if not available tNewBudgetCompany
                then leave NEWBUDGETCOMPANYBUDGETBLOCK.
                assign vcFirstNewBudgetCompanyCode = tNewBudgetCompany.tcCompanyCode.
                if can-find (first tNewBudgetFDS where 
                                   tNewBudgetFDS.tc_ParentRowid = tNewBudget.tc_Rowid and
                                   tNewBudgetFDS.BudgetFDSType  = {&BUDGETFDSTYPE-GL})
                then do :
                    <Q-11 run CompanySSByCompanyIDCodeSSType (all) (Read) (Cache)
              (input ?, (CompanyId)
               input {&SHAREDSETTYPECODE-GL}, (SharedSetType)
               input vcFirstNewBudgetCompanyCode, (CompanyCode)
               output dataset tqCompanySSByCompanyIDCodeSSType) in BCompany >
                    find first tqCompanySSByCompanyIDCodeSSType no-lock no-error.
                    assign tNewBudget.GLSharedSet_ID = (if available tqCompanySSByCompanyIDCodeSSType then tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID else 0).
                end. /* GL */
                if can-find (first tNewBudgetFDS where 
                                   tNewBudgetFDS.tc_ParentRowid = tNewBudget.tc_Rowid and
                                   tNewBudgetFDS.BudgetFDSType  = {&BUDGETFDSTYPE-DIVISION})
                then do :
                    <Q-12 run CompanySSByCompanyIDCodeSSType (all) (Read) (Cache)
              (input ?, (CompanyId)
               input {&SHAREDSETTYPECODE-DIVISION}, (SharedSetType)
               input vcFirstNewBudgetCompanyCode, (CompanyCode)
               output dataset tqCompanySSByCompanyIDCodeSSType) in BCompany >
                    find first tqCompanySSByCompanyIDCodeSSType no-lock no-error.
                    assign tNewBudget.DivisionSharedSet_ID = (if available tqCompanySSByCompanyIDCodeSSType then tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID else 0).
                end. /* Div */
                if (tNewBudget.tcProjectCode <> "":U and 
                    tNewBudget.tcProjectCode <> ?) or 
                   can-find (first tNewBudgetFDS where 
                                   tNewBudgetFDS.tc_ParentRowid = tNewBudget.tc_Rowid and
                                   tNewBudgetFDS.BudgetFDSType  = {&BUDGETFDSTYPE-PROJECT})
                then do :
                    <Q-13 run CompanySSByCompanyIDCodeSSType (all) (Read) (Cache)
              (input ?, (CompanyId)
               input {&SHAREDSETTYPECODE-PROJECT}, (SharedSetType)
               input vcFirstNewBudgetCompanyCode, (CompanyCode)
               output dataset tqCompanySSByCompanyIDCodeSSType) in BCompany >
                    find first tqCompanySSByCompanyIDCodeSSType no-lock no-error.
                    assign tNewBudget.ProjectSharedSet_ID = (if available tqCompanySSByCompanyIDCodeSSType then tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID else 0).
                end. /* Prj */
                if (tNewBudget.tcCostCentreCode <> "":U and 
                    tNewBudget.tcCostCentreCode <> ?) or 
                   can-find (first tNewBudgetFDS where 
                                   tNewBudgetFDS.tc_ParentRowid = tNewBudget.tc_Rowid and
                                   tNewBudgetFDS.BudgetFDSType  = {&BUDGETFDSTYPE-COSTCENTRE})
                then do :
                    <Q-14 run CompanySSByCompanyIDCodeSSType (all) (Read) (Cache)
              (input ?, (CompanyId)
               input {&SHAREDSETTYPECODE-COSTCENTRE}, (SharedSetType)
               input vcFirstNewBudgetCompanyCode, (CompanyCode)
               output dataset tqCompanySSByCompanyIDCodeSSType) in BCompany >
                    find first tqCompanySSByCompanyIDCodeSSType no-lock no-error.
                    assign tNewBudget.CostCentreSharedSet_ID = (if available tqCompanySSByCompanyIDCodeSSType then tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID else 0).
                end. /* GL */
                for each tNewBudgetCompany where
                         tNewBudgetCompany.tc_ParentRowid  = tNewBudget.tc_Rowid and 
                         tNewBudgetCompany.tc_Status      <> "D":U               and
                         tNewBudgetCompany.tcCompanyCode  <> "":U                and 
                         tNewBudgetCompany.tcCompanyCode  <> ?                   and
                         tNewBudgetCompany.tcCompanyCode  <> vcFirstNewBudgetCompanyCode 
                         no-lock : 
                    <Q-15 run CompanySSByCompanyIDCodeSSType (all) (Read) (Cache)
              (input ?, (CompanyId)
               input ?, (SharedSetType)
               input tNewBudgetCompany.tcCompanyCode, (CompanyCode)
               output dataset tqCompanySSByCompanyIDCodeSSType) in BCompany >
                    find first tqCompanySSByCompanyIDCodeSSType where 
                               tqCompanySSByCompanyIDCodeSSType.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-GL}
                               no-lock no-error.
                    if tNewBudget.GLSharedSet_ID <> 0             and 
                       available tqCompanySSByCompanyIDCodeSSType and 
                       tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID <> tNewBudget.GLSharedSet_ID
                    then assign vcMessage = trim(substitute(#T-27'The GL shared set of entity &1 differs from the GL shared set of entity &2.':255(459)t-27#,vcFirstNewBudgetCompanyCode,tqCompanySSByCompanyIDCodeSSType.tcCompanyCode)) + chr(10) + vcMessage.
                    find first tqCompanySSByCompanyIDCodeSSType where 
                               tqCompanySSByCompanyIDCodeSSType.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-DIVISION}
                               no-lock no-error.
                    if tNewBudget.DivisionSharedSet_ID <> 0       and 
                       available tqCompanySSByCompanyIDCodeSSType and 
                       tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID <> tNewBudget.DivisionSharedSet_ID
                    then assign vcMessage = trim(substitute(#T-28'The sub-account shared set of entity &1 differs from the sub-account shared set of entity &2.':255(460)t-28#,vcFirstNewBudgetCompanyCode,tqCompanySSByCompanyIDCodeSSType.tcCompanyCode)) + chr(10) + vcMessage.
                    find first tqCompanySSByCompanyIDCodeSSType where 
                               tqCompanySSByCompanyIDCodeSSType.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-PROJECT}
                               no-lock no-error.
                    if tNewBudget.ProjectSharedSet_ID <> 0        and 
                       available tqCompanySSByCompanyIDCodeSSType and 
                       tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID <> tNewBudget.ProjectSharedSet_ID
                    then assign vcMessage = trim(substitute(#T-29'The project shared set of entity &1 differs from the project shared set of entity &2.':255(461)t-29#,vcFirstNewBudgetCompanyCode,tqCompanySSByCompanyIDCodeSSType.tcCompanyCode)) + chr(10) + vcMessage.
                    find first tqCompanySSByCompanyIDCodeSSType where 
                               tqCompanySSByCompanyIDCodeSSType.tcSharedSetTypeCode = {&SHAREDSETTYPECODE-COSTCENTRE}
                               no-lock no-error.
                    if tNewBudget.CostCentreSharedSet_ID <> 0     and 
                       available tqCompanySSByCompanyIDCodeSSType and 
                       tqCompanySSByCompanyIDCodeSSType.tiSharedSet_ID <> tNewBudget.ProjectSharedSet_ID
                    then assign vcMessage = trim(substitute(#T-30'The cost center shared set of entity &1 differs from the cost center shared set of entity &2.':255(462)t-30#,vcFirstNewBudgetCompanyCode,tqCompanySSByCompanyIDCodeSSType.tcCompanyCode)) + chr(10) + vcMessage.
                end. /* for eacht tNewBudgetCompany */
            END. /* NEWBUDGETCOMPANYBUDGETBLOCK */
            <Q-16 run CompanySSByCompanyIDCodeSSType (Stop) in BCompany >
            if vcMessage <> "":U
            then do :
                assign oiReturnStatus = -1.
                <M-17 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-1610':U (icFcMsgNumber),
                         input  '' (icFcExplanation),
                         input  '' (icFcIdentification),
                         input  '' (icFcContext),
                         output viFcReturnSuper (oiReturnStatus)) in BBudget>
            end. /* if vcMessage <> "":U */
        end. /* if tNewBudget.BudgetIsFRWChartLink <> true */
        else do:
            <Q-56 run FRWCompanyByFRWChartID (all) (Read) (NoCache)
               (input ?, (CompanyId)
                input tNewBudget.FRWChart_ID, (FRWChart_ID)
                output dataset tqFRWCompanyByFRWChartID) in BFRWChart>
            
            for each tqFRWCompanyByFRWChartID no-lock:            
                if not can-find (first tNewBudgetCompany
                                where tNewBudgetCompany.tc_ParentRowid  = tNewBudget.tc_Rowid and 
                                      tNewBudgetCompany.tc_Status       <> "D":U              and
                                      tNewBudgetCompany.tcCompanyCode   = tqFRWCompanyByFRWChartID.tcCompanyCode)
                then do:
                    assign vcMessage = trim(#T-84'Not all entities of the report chart are listed on the general tab.':255(463569012)T-84#)
                           oiReturnStatus = -1.
        
                    <M-67 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-522989':U (icFcMsgNumber), 
                        input  '' (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BBudget>
                end. /*if not can-find (first tNewBudgetCompany */
            end. /*for each */
        end.
        
        /* Validations for BudgetForecastType */
        <M-37 run ValidateComponentValidateStructDetSub (output viFcReturnSuper (oiReturnStatus)) in BBudget>
        if viFcReturnSuper < 0
        then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper > 0 and oiReturnStatus = 0
        then assign oiReturnStatus = viFcReturnSuper.
        
    end. /* for each tNewBudget where */
    <Q-34 run ProjectPrim  (Stop) in BProject >
    <Q-36 run CostCentrePrim  (Stop) in BCostCentre >