Thursday, March 4, 2010

Pick a sales order line through code

Code snippet to pick a sales order line.............

InventMovement movement;
TmpInventTransWMS TmpInventTransWMS;
inventTrans inventTrans;
InventTransWMS_Pick inventTranspick;
SalesLine SalesLine;
SalesId SalesId;
InventTransId InventTransId;
Qty Qty_topick;

;

SalesId = "_SalesId";
InventTransId = "_InventTransId";
Qty_topick = "_QTy to Pick";

select SalesLine where SalesLine.SalesId== SalesId && SalesLine.InventTransId == inventTransId;
{
movement = InventMovement::construct(SalesLine);
select inventtrans where inventtrans.TransRefId == SalesLine.salesid &&
inventTrans.inventTransId ==InventTransId ;
inventTranspick = new InventTransWMS_Pick(movement,tmpInventTransWMS);
TmpInventTransWMS.InventQty= (UnitConvert::qty(Qty_topick,SalesLine.SalesUnit,inventTable::find(SalesLine.ItemId).inventUnitId(),SalesLine.ItemId));
TmpInventTransWMS.InventDimId=SalesLine.InventDimId;
TmpInventTransWMS.RefRecId=inventTrans.RecId;
TmpInventTransWMS.LineNum=SalesLine.LineNum;
TmpInventTransWMS.write();
InventTransWMS_Pick::updateInvent(inventTranspick,TmpInventTransWMS);
TmpInventTransWMS.clear();
SalesLine.clear();
inventTrans.clear();
}

2 comments:

Chris Jamison said...

This is great! I was just starting to write code for this myself, when I did a Google search and found your code snippet.

I'm going to code it now. If I have any gotchas or changes, I'll post them later.

Thank You!

Chris Jamison said...

Thanks for this post. I started writing code to do just this thing today. I'll try it, and if I see any changes, I'll re-post.

Thanks for your blogging. You are appreciated.