Dynamics ax 2012 Use arrays update item status
eg:
static void DA_UpdateItemStatus(Args _args) { int i,j; str _itemid; str d_itemId[]; InventTable l_item; Danzel_Temp d_t; TreeNode d_job; ; //存 for (i = 1;i <= 306;i ++) { select firstOnly d_t where d_t.RecId == i; d_itemId[i] = d_t.ItemId; //info(strFmt("%1",d_itemId[i])); } //取30400051 for (j = 1;j <=306 ;j ++)//306 { l_item = InventTable::find(d_itemId[j],true);// //info(strFmt("%1",l_item.ItemId)); if(DA_checkCanbeStopped::DA_checkCanbeStopped(l_item)) { ttsBegin; l_item.TEK_ItemStatus = TEK_ItemStatus::Stopped; l_item.update(); ttsCommit; // ttsBegin; select forUpdate d_t where d_t.ItemId == l_item.ItemId; d_t.Id = 1; d_t.update(); ttsCommit; } } }
Class:
public static boolean DA_checkCanbeStopped(InventTable _item) { boolean l_ret = true; InventSum l_inventSum; InventQtyPhysicalOnhand l_onHand; InventDim l_dim; Danzel_Temp d_temp; ; while select l_inventSum where l_inventSum.ItemId == _item.ItemId { l_onHand = l_inventSum.physicalInventCalculated(); if(l_onHand > 0) { l_ret = false; l_dim = l_inventSum.inventDim(); info(strfmt("Inventory not zero, Batch ID:%3 Qty.:%4 Warehouse:%1.%2,%5" ,l_dim.InventLocationId,l_dim.wMSLocationId,l_dim.inventBatchId,l_onHand,_item.ItemId)); //可忽略 ttsBegin; select forUpdate d_temp where d_temp.ItemId == _item.ItemId; d_temp.Id = 0; d_temp.update(); ttsCommit; } } return l_ret; }
留言评论
暂无留言