project QadFinancials > class BBudget > method ValidateComponentBudgetCompany
Description
This method has the same functionality as the RKBF
Parameters
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program5/bbudget.p)
/* ========================================================= */
/* Fill Company_ID in BudgetCompany based on the CompanyCode */
/* This cannot be done using RKBF because then the current */
/* company is then added as parameter value for the query. */
/* Assign Budget.BudgetType based upon other fields */
/* ========================================================= */
for each t_sBudget where
t_sBudget.tc_Status ="C":U or
t_sBudget.tc_Status ="N":U :
/* Assign Budget.BudgetType based upon other fields */
if t_sBudget.Project_ID <> 0 and
t_sBudget.Project_ID <> ?
then assign t_sBudget.BudgetType = {&BUDGETTYPE-PROJECT}.
else if t_sBudget.CostCentre_ID <> 0 and
t_sBudget.CostCentre_ID <> ?
then assign t_sBudget.BudgetType = {&BUDGETTYPE-COSTCENTRE}.
else assign t_sBudget.BudgetType = {&BUDGETTYPE-GLOBAL}.
end. /* for each t_sBudget where */
for each t_sBudgetCompany where
t_sBudgetCompany.tc_Status ="C":U or
t_sBudgetCompany.tc_Status ="N":U :
/* Read all companies */
if not can-find (first tqCompanyPrim)
then do :
<Q-1 run CompanyPrim (all) (Read) (NoCache)
(input ?, (LookupCompanyId)
input ?, (CompanyCode)
output dataset tqCompanyPrim) in BCompany >
end. /* if not can-find (first ) */
/* Set the company-code */
find tqCompanyPrim where
tqCompanyPrim.tcCompanyCode = t_sBudgetCompany.tcCompanyCode
no-lock no-error.
if available tqCompanyPrim
then assign t_sBudgetCompany.Company_ID = tqCompanyPrim.tiCompany_ID.
else do :
assign t_sBudgetCompany.Company_ID = ?
oiReturnStatus = -1
vcMessage = trim(substitute(#T-2'Invalid entity (&1) specified for the budget.':255(14123)T-2#,t_sBudgetCompany.tcCompanyCode)).
<M-3 run SetMessage (input vcMessage (icMessage),
input '':U (icArguments),
input 'tBudgetCompany.tcCompanyCode':U (icFieldName),
input t_sBudgetCompany.tcCompanyCode (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input t_sBudgetCompany.tc_Rowid (icRowid),
input 'QADFIN-3206':U (icFcMsgNumber),
input '':U (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BBudget>
end. /* Not if available */
end. /* for each t_sBudgetCompany where */