Dynamics AX2012 R2 CU7 を実行しており、コーディングしました:,
"すでに設定されているベース会社からすべての会社に会計年度をコピーする",
Dynamics AX 2009 であったソース システムの機能です。Dynamics AX 2012 R2、CU7 の構造は非常に異なるため、X++ コーディングを使用して同じ機能を実現する方法がわかりません。
元のコード:
void clicked()
{
ModulePeriodStat ledger, bank, cust, asset, invent, prod, proj, purch, sales, tax, vend ;
PeriodEnd period;
LedgerPeriod ledgerPeriod2;
CompanyInfo companyInfo;
Dialog dlg;
;
super();
dlg = new Dialog("Confirm: ");
dlg.addText("You will create these periods in all companies "+date2str(period,321,2,2,2,2,4));
dlg.run();
if ((dlg.closedOk()))
{
ttsbegin;
while select crosscompany companyInfo
{
if (companyInfo.dataAreaId != 'ct11' && companyInfo.dataAreaId != 'ct13' && companyInfo.dataAreaId != 'md11' && companyInfo.dataAreaId != 'mf11')
changecompany(companyInfo.dataAreaId)
{
ledgerPeriod2 = null;
while select forUpdate ledgerPeriod // where (ledgerPeriod.PeriodEnd == period)
{
ledger = ledgerPeriod.StatusLedger;
bank = ledgerPeriod.StatusBank;
cust = ledgerPeriod.StatusCust;
asset = ledgerPeriod.StatusFixedAsset;
invent = ledgerPeriod.StatusInvent;
prod = ledgerPeriod.StatusProd;
proj = ledgerPeriod.StatusProj;
purch = ledgerPeriod.StatusPurch;
sales = ledgerPeriod.StatusSalesOrder;
tax = ledgerPeriod.StatusTax;
vend = ledgerPeriod.StatusVend;
period = ledgerPeriod.PeriodEnd;
ledgerPeriod2.PeriodStart = ledgerPeriod.PeriodStart;
ledgerPeriod2.PeriodCode = ledgerPeriod.PeriodCode;
ledgerPeriod2.PeriodEnd = period;
ledgerPeriod2.PeriodStatus = ledgerPeriod.PeriodStatus;
ledgerPeriod2.Commentaries = ledgerPeriod.Commentaries;
ledgerPeriod2.StatusLedger = ledger;
ledgerPeriod2.StatusBank = bank;
ledgerPeriod2.StatusCust = cust;
ledgerperiod2.StatusFixedAsset = asset;
ledgerPeriod2.StatusInvent = invent;
ledgerPeriod2.StatusProd = prod;
ledgerperiod2.StatusProj = proj;
ledgerPeriod2.StatusPurch = purch;
ledgerperiod2.StatusSalesOrder = sales;
ledgerPeriod2.StatusTax = tax;
ledgerperiod2.StatusVend = vend;
try
{
ledgerperiod2.insert();
}
catch (Exception::DuplicateKeyException)
{
period = period;
print('Problem encountered with company: '+companyinfo.dataAreaId);
}
}
}
}
ttscommit;
box::info('Periods Created Successfully');
}
}