[英]Is there a way to improve this dynamics ax update job
我正在開發AX 2009安裝。 工作是更新WMSOrderTrans表。 這是我到目前為止所得到的:
WMSOrderTrans wmsOrderTrans;
;
while select wmsOrderTrans
{
if (wmsOrderTrans.BBBpackingSlipExists())
{
ttsBegin;
wmsOrderTrans.selectForUpdate(true);
wmsOrderTrans.BBBPackingSlipExists = NoYes::Yes;
wmsOrderTrans.doUpdate();
ttsCommit;
}
}
這項工作大約需要一個小時才能完成測試系統。 這讓我擔心生產系統的性能 。
目前,代碼已經被編寫為具有最小的鎖定問題(如果應該更新並且然后立即提交,則為每一行執行selectForUpdate)。 原因是,當作業運行時,用戶將在系統上工作。
我的問題是, 如果有一種合理的方式以較少的交易開銷實現這項工作。
while select forUpdate ...
...似乎不是一個選項,因為它會鎖定表,直到作業完成。
任何輸入都表示贊賞。
這是BBBPackingSlipExists方法的代碼:
display boolean BBBpackingSlipExists()
{
InventDim inventDimCur;
InventDim inventDimPackSlip;
InventTrans inventTransPackSlip;
;
select firstonly RecId from inventTransPackSlip
where inventTransPackSlip.InventTransId == this.inventTransId
&& (inventTransPackSlip.StatusIssue == StatusIssue::Deducted
|| inventTransPackSlip.StatusIssue == StatusIssue::Sold)
&& !inventTransPackSlip.PackingSlipReturned
exists join inventDimCur
where inventDimCur.inventDimId == this.inventDimId
exists join inventDimPackSlip
where inventDimPackSlip.inventDimId == inventTransPackSlip.inventDimId
&& inventDimCur.inventSerialId == inventDimPackSlip.inventSerialId
;
if (inventTransPackSlip.RecId != 0 && this.isReserved)
{
return true;
}
return false;
}
這看起來像是轉換為基於集合邏輯的主要候選者,我會選擇這樣的東西。 請注意,作業沒有經過測試,因為我沒有2009環境(這在2012年甚至沒有編譯),所以如果你需要更改代碼,請隨意將其編輯到我的答案中。
請注意,isreserved check包含在查詢中,以及packingslipexists方法中的exists連接
static void Job250(Args _args)
{
WMSOrderTrans wmsOrderTrans;
InventDim inventDimCur;
InventDim inventDimPackSlip;
InventTrans inventTransPackSlip;
;
wmsOrderTrans.skipDatabaseLog(true);
wmsOrderTrans.skipDataMethods(true);
wmsOrderTrans.skipEvents(true);
update_recordset wmsOrderTrans setting BBBPackingSlipExists = NoYes::Yes
where wmsOrderTrans.isReserved
exists join inventTransPackSlip
where inventTransPackSlip.InventTransId == wmsOrderTrans.inventTransId
&& (inventTransPackSlip.StatusIssue == StatusIssue::Deducted
|| inventTransPackSlip.StatusIssue == StatusIssue::Sold)
&& !inventTransPackSlip.PackingSlipReturned
exists join inventDimCur
where inventDimCur.inventDimId == wmsOrderTrans.inventDimId
exists join inventDimPackSlip
where inventDimPackSlip.inventDimId == inventTransPackSlip.inventDimId
&& inventDimCur.inventSerialId == inventDimPackSlip.inventSerialId;
}
請參閱update_recordset上的文檔以及為什么可能需要skip *方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.