最新消息:ww12345678 的部落格重装上线,希望大家继续支持。

Select on InventSum vs InventOnHand Class Dynamics Ax 2012 R3.

网络文摘 alirazazaidi 44浏览 0评论

Today I face the very strange behavior of X++ code.

We develop customization. We generate transfer and issuance through X++.

Logic was very simple,If stock is available then transfer  / Issuance or Adjustment journal create otherwise generate error message, We took this decision  based of query on Inventsum. It works fine in most of cases but In one case when stock is zero it fails. We create Movement Journal to generate stock in that Item variant.  The select query always return Zero stock in posted quantity. Even I get the recid in debug mode and placed in table explorer, Quantity is available in table explore.

This case occurs when got Zero stock in Inventsum table and we try to increase stock by movement journal, other wise select on InventSum works fine.

 

The query will be very similar

 

Select * from InventSum where Inventsum.ItemId == line.ItemId && inventSum.invetdimId == line.fromInventiDimId;

 

This will not work. Even Db synch, Inc Cil, Cache clear done, even Restart the Test server AOS.

 

I have to switch code from select query to Class InventOnhand. Very similar to following.

 

InventOnHand inventOnhand

InventDim       InventDim;

InventDimParm inventDimParm;

 

 

inventDimParm.initFormInventDim(_Line.FromInventDimId);

inventOnHand = InventOnhand::newParameters(_line.Itemid,_line.FromInventDimId,inventDimParm);

 

If (inventOnHand.availPhysical() > _line.RequestedQty)

{

Info( ” Quantity Avalible “);

}

Else

{

Info (” Not available “);

}

 

Its works perfectly fine. I think  InventonHand class is better the do direct query on Inventsum table.

 

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址