You are on page 1of 2

With the following code we can able to import the project budget and revising

too from Project forecast

MenuItemName actionName;
MenuFunction menuFunction;
Args args = new args();
IProjBudgetGridUpdatable projBudgetGridUpdatable;
ProjBudget projBudget,ProjBudgetWFStatus,projBudgetRec;
ProjBudgetLine projBudgetLine,PBL;
projBudgetRevision projBudgetRevision;
projBudgetRevisionLine projBudgetRevisionLine;
ProjBudgetAllocationLine projBudgetAllocationLine;
ForecastModelId defaultModelIdForForecastImport;
FormDataSource projBudget_ds,ProjBudgetLineRevenue_ds,ProjBudgetLineCost_ds;
ProjBudgetImportBatch projBudgetImportBatch = new ProjBudgetImportBatch();

args = new Args();
actionName = menuitemActionStr(projBudgetImportBatch);

ttsbegin;

projbudget::findOrCreateProjectBudget("HH");
Select forupdate projBudget where projBudget.RootProjId == "HH";
if(projBudget.BudgetWorkflowStatus == ProjBudgetWorkflowStatus::Created)
{

projBudgetImportBatch.parmProjId("HH");
projBudgetImportBatch.parmProjBudgetRecId(projBudget.RecId);
projBudgetImportBatch.parmSource("CurrentF");
projBudgetImportBatch.parmMarkValue(0);
projBudgetImportBatch.parmProjBudgetImportOptions(ProjBudgetImportOptions::Units);
projBudgetImportBatch.parmProjBaseBudgetOn(projbaseBudgetOn::Forecast);
projBudgetImportBatch.parmSummarizeByCategory(noyes::Yes);
projBudgetImportBatch.parmInBatch(noyes::No);
args.parmObject(projBudgetImportBatch);
menuFunction = new MenuFunction(actionName, MenuItemType::Action);
menuFunction.run(args);

projbudget::updateProjBudgetStatus(projBudget.RecId,ProjBudgetWorkflowStatus::Submitted);

projbudget::updateProjBudgetStatus(projBudget.RecId,ProjBudgetWorkflowStatus::Approved);
args.record(projbudget);
args.parmEnumType(enumnum(ProjBudgetManagerActionType));
args.parmEnum(ProjBudgetManagerActionType::Commit);
ProjBudgetManager::main(args);

}
projBudgetLine.clear();
projBudgetRec.clear();
// Budget revision
if(projBudget.BudgetWorkflowStatus == ProjBudgetWorkflowStatus::Approved)
{
projBudgetRevision::createRevision(projBudget.RecId);
select ProjBudgetRevision where ProjBudgetRevision.ProjBudget == projBudget.RecId;
projBudgetImportBatch.parmProjId("HH");
projBudgetImportBatch.parmProjBudgetRecId(projBudget.RecId);
projBudgetImportBatch.parmProjBudgetRevisionRecId(projBudgetRevision.RecId);
projBudgetImportBatch.parmSource("CurrentF");
projBudgetImportBatch.parmMarkValue(0);
projBudgetImportBatch.parmProjBudgetImportOptions(ProjBudgetImportOptions::Units);
projBudgetImportBatch.parmProjBaseBudgetOn(projbaseBudgetOn::Forecast);
projBudgetImportBatch.parmSummarizeByCategory(noyes::Yes);
projBudgetImportBatch.parmInBatch(noyes::No);
args.parmObject(projBudgetImportBatch);
menuFunction = new MenuFunction(actionName, MenuItemType::Action);
menuFunction.run(args);

ProjBudgetRevision::updateProjBudgetRevisionStatus(ProjBudgetRevision.RecId,ProjBudgetRevision
WFStatus::Submitted);

ProjBudgetRevision::updateProjBudgetRevisionStatus(ProjBudgetRevision.RecId,ProjBudgetRevision
WFStatus::Approved);
args.record(ProjBudgetRevision);
ProjBudgetRevisionManager::main(args);
while select forupdate PBL where PBL.ProjId == "HH"
{
PBL.UncommittedRevisions =0;
PBL.update();

while select projBudgetRevisionLine where projBudgetRevisionLine.ProjBudgetRevision ==
ProjBudgetRevision.RecId
{
select forupdate projBudgetAllocationLine where
projBudgetAllocationLine.ProjBudgetLine == PBL.RecId;
projBudgetAllocationLine.CommittedRevisions = projBudgetRevisionLine.RevisionAmount;
projBudgetAllocationLine.TotalAllocationAmount =
projBudgetRevisionLine.NewTotalBudget;
projBudgetAllocationLine.update();
}
}
}