Unreserve / Unpick a sales order line X++
In this article we will see how to unreserved or unpick the piked sales order line. In standard AX 2012 we can do it manually by using the 'Update line" and pick functionality.
For doing it automatically, I am going to add a button(Action Menu Item) on Sales order Header, using this button we will call the class to do the job.
below is the code which dose the job..
One good thing about this job is, it also show the relation on InventTrans and SalesLine in AX 2012. As you all know that, there is no more InventTransID in InventTrans Table, we have to pick it from InventTransOrigin.
/// Contains the code that does the actual job of the class ---Mallik.
///
{
InventTrans inventTransLocal;
InventTransOriginSalesLine inventTransOriginSalesLine;
InventTransOrigin inventTransOrigin;
SalesLine salesLine;
InventTransWMS_Pick inventTransWMS_Pick;
TmpInventTransWMS tmpInventTransWMS;
Query baseQueryInventTrans;
QueryBuildDataSource qbdsInventTrans;
baseQueryInventTrans = new Query();
qbdsInventTrans = baseQueryInventTrans.addDataSource(tableNum(InventTrans));
baseQueryInventTrans.dataSourceTable(tableNum(InventTrans));
qbdsInventTrans.clearDynalinks();
qbdsInventTrans.clearRanges();
qbdsInventTrans.addRange(fieldNum(InventTrans,StatusReceipt)).value(SysQuery::value(StatusReceipt::None));
qbdsInventTrans.addRange(fieldNum(InventTrans,StatusIssue)).value(SysQuery::range(StatusIssue::Picked,StatusIssue::OnOrder));
inventTransWMS_Pick = InventTransWMS_Pick::newStandard(tmpInventTransWMS,baseQueryInventTrans);
while select forUpdate salesLine where salesLine.SalesId == salesTable.SalesId
&& salesLine.ILSLocked == true
{
select inventTransLocal
where inventTransLocal.ItemId == salesline.ItemId
&& inventTransLocal.StatusIssue == StatusIssue::Picked
exists join inventTransOrigin
where inventTransOrigin.RecId == inventTransLocal.InventTransOrigin
exists join inventTransOriginSalesLine
where inventTransOriginSalesLine.SalesLineInventTransId == salesline.InventTransId;
if (inventTransLocal.RecId)
{
inventTransWMS_Pick.createFromInventTrans(inventTransLocal);
}
}
inventTransWMS_Pick.updateInvent();
}
Happy learning.. Mallik
No comments:
Post a Comment