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();
}

Transfer Order code Snippet.

Create a Transfer Order Through Code.....................

InventTransFerTable InventTransFerTable;
InventTransFerLine InventTransFerLine;
InventTable InventTable;
NumberSeq NumberSeq;
;
NumberSeq = NumberSeq::newGetNumFromCode(Inventparameters::numRefTransferId().NumberSequence);
InventTransferTable.TransferId = NumberSeq.num();
InventTransferTable.InventLocationIdFrom = “_FromWarehouse”;
InventTransferTable.InventLocationIdTo = “_ToWarehouse”;
InventTransferTable.initFromAddress();
InventTransferTable.initValue();
InventTransferTable.initDeliveryMode();
InventTransferTable.initToAddress();
InventTransferTable.insert();
InventTransferLIne.clear();
InventTransferLine.initFromInventTransferTable(_InventTransferTable,NoYes::Yes);
InventTransferLine.ItemId = ”_Itemid”;
InventTransFerLine.LineNum = InventTransferLine::lastLineNum(_InventTransferTable.TransferId) + 1;
InventTable = InventTable::find(InventTransferLine.ItemId);
InventTransferLine.initFromInventTable(InventTable);
InventTransferLine.QtyTransfer = “QTY”;
InventTransferLine.QtyRemainReceive =”_QTYremainRecive”;
InventTransferLine.QtyRemainShip = “_QtyRemainShip”;
InventTransferLine.InventDimId = “_inventDimid”;
InventTransferLine.insert();

Dynamics AX 2009 Code Snippets

it's been so long to find a blog entry on my blog. I would like to post more snippets which can be usefull in Dynamics Ax 2009. Will be posting some more very soon..........