Need to do purchase order line registration process through code

Hi Everyone,

I need to do the purchase line registration and post it as in below form through x++ in AX 2009.

Thanks in advance!

static void Job231(Args _args)
{
PurchLine pLine;
TmpInventTransWMS tmpITWMS;
InventTransWMS_Register itr;
InventMovement movement;
;
pLine = PurchLine::find(“PO49708”, 1); // sample PO

movement = InventMovement::construct(pLine);
tmpITWMS.initFromInventTrans(InventTrans::findTransId(pLine.InventTransId));
tmpITWMS.InventQty = 1;
tmpITWMS.LineNum = 1; // the po’s line number
tmpITWMS.InventDimId = pLine.InventDimId;

tmpITWMS.insert(); // make sure to insert temporary table to generate recid reference

InventTransWMS_Register::updateInvent(pLine, tmpITWMS);
}

This code does the job…!