0
特定の次元(AX 2012 R2)の予算残高を計算する必要があります。コードで予算残高を計算する
次のコードを正しく実行しますが、完了するまでに時間がかかります。
これは、私が望むだけでなく、AXを持つすべての予算残高を計算したためです。
最後に、変数BudgetTmpBalance
には、すべての予算エントリのレコードがあります。
私が検討していないことがあります。誰でも分かりますか?
ありがとうございます。
コード:
BudgetTransactionLine recBudgetTransactionLine;
DimensionAttributeValueCombination recDimensionAttributeValueCombination;
date FiscalYearStart, FiscalYearEnd;
AccountingDistribution recAccountingDistribution;
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource qbdsJoin;
QueryBuildRange qbr;
BudgetCalculateBalance budgetCalculateBalance = new BudgetCalculateBalance();
BudgetTmpBalance budgetTmpBalance;
DimensionDisplayValue pDimensionDisplayValue;
;
pDimensionDisplayValue = "Correct Value";
select * from recDimensionAttributeValueCombination where recDimensionAttributeValueCombination.LedgerDimensionType == LedgerDimensionType::Budget &&
recDimensionAttributeValueCombination.DisplayValue == pDimensionDisplayValue;
FiscalYearStart = str2Date("01/04/" + int2str(year(today())), 123);
FiscalYearEnd = str2Date("31/03/" + int2str(year(today()) + 1), 123);
//Find recId of header that I Want (Works fine)
select BudgetTransactionHeader from recBudgetTransactionLine where recBudgetTransactionLine.LedgerDimension == recDimensionAttributeValueCombination.RecId &&
(recBudgetTransactionLine.Date >= FiscalYearStart && recBudgetTransactionLine.Date <= FiscalYearEnd);
qbds = query.addDataSource(tableNum(BudgetTransactionHeader));
qbr = qbds.addRange(FieldNum(BudgetTransactionHeader, TransactionStatus));
qbr.value(queryValue(1));
qbr = qbds.addRange(FieldNum(BudgetTransactionHeader, RecId));
qbr.value(queryValue(recBudgetTransactionLine.BudgetTransactionHeader));//Header RecId (correct value)
qbdsJoin= qbds.addDataSource(tableNum(BudgetTransactionLine));
qbdsJoin.relations(false);
qbdsJoin.fields().dynamic(NoYes::Yes);
qbdsJoin.addLink(fieldNum(BudgetTransactionHeader, RecId), fieldNum(BudgetTransactionLine, BudgetTransactionHeader));
qbdsJoin.joinMode(JoinMode::InnerJoin);
budgetCalculateBalance.parmDimensionFocus("CTA+UN+CC");
budgetCalculateBalance.parmCalculateLedgerAmounts(NoYes::Yes);
budgetCalculateBalance.parmFiscalCalendarRecId(Ledger::fiscalCalendar());
budgetCalculateBalance.parmStartDate(FiscalYearStart);
budgetCalculateBalance.parmEndDate(FiscalYearEnd);
budgetCalculateBalance.parmIncludeSubModels(NoYes::No);
budgetCalculateBalance.parmIncludeAllBudgetModelsIfNotSpecified(NoYes::No);
budgetCalculateBalance.parmBudgetModelId("TOTAL");
budgetCalculateBalance.parmBudgetType();
budgetCalculateBalance.parmAccumulateAmounts(NoYes::No);
budgetCalculateBalance.parmLedgerCategory(CurrentOperationsTax::Current);
budgetCalculateBalance.parmQuery(query);
budgetTmpBalance = budgetCalculateBalance.calculatePeriodBalances();