Hello below is the code to automatically register AX 2009 Journal Line.

Create the following method on InventJournalTrans table.

void registerInvent(InventQty _qty = this.Qty)
{
tmpInventTransWMS tmpInventTransWMS;
inventTrans inventTrans;
InventMovement movement;
InventTransWMS_Register inventTransRegister;
boolean first;
inventTransIdSum inventTransIdSum;
InventQty registeredQty, addQty;

;

movement = InventMovement::construct(this);

first = true;

if (movement.mustBeRegistered())
{

inventTransIdSum = new InventTransIdSum(this.inventTransId);

registeredQty = inventTransIdSum.registered();

if (registeredQty >= _qty)
{
addQty = 0;
}
else
{
addQty = _qty – registeredQty;
}

while select inventTrans index hint TransIdIdx order by qty
where inventTrans.statusIssue == StatusIssue::None &&
inventTrans.inventTransId == this.InventTransId &&
inventTrans.StatusReceipt >= StatusReceipt::Ordered &&
inventTrans.TransChildType == InventTransChildType::None &&
inventTrans.TransChildRefId == ”

{

tmpInventTransWMS.initValue();
tmpInventTransWMS.initFromInventTrans(inventTrans);

if (inventTrans.qty > addQty)
inventTrans.updateSplit(addQty);

tmpInventTransWMS.inventQty = inventTrans.Qty;
tmpInventTransWMS.insert();

addQty = addQty – inventTrans.qty;

first = false;

if (! addQty)
break;
}
}

if (addQty)
{
throw error(“@SYS53791”);
}

if (!first)
{
InventTransWMS_Register::updateInvent(this,tmpInventTransWMS);
}
}

Call to the above method using InventJournalTrans.pickInvent();

Where InventJournalTrans is the record on Journal lines which needs to be regsitered.