Invent Trans record not created in counting journal ax 2009

Dear All,

I 'm trying to import Inventory Counting Journal by code, everything works fine, but when the Onhand qty is less than the Counted qty, Invent trans record is not getting created, but the same works when Onhand is greater than Counted qty

Even though invent trans record is not created, but inventtransid exists in Invenjournaltrans table

I used below piece of code:

journalTr.InventOnHand = InventSumDatePhysicalDim::onHandQty(trDate,itemId,locinventdim,invDimParm);

journalTr.Counted = invCountedQty;

journalTr.CostPrice = availcostprice;

journalTr.validateWrite();

journalTr.insert(NoYes::Yes);

journalTr.inventMovement().journalSetCounted();

journalTr.update();

Note: Above code is working fine when Onhand qty > Counted also when both are same.

Thanks,

Regards,

Ansar Basha.S

Found resolution

A stupid line of code is very problamatic, Here is the code

journalTr.insert(); // Its not required to pass parameter as NoYes::Yes

It works perfect.

Regards,

Ansar Basha.S