Code verification

Hi All,

I am imported data in VendTable through excel import option.
Now I need to update InventTableModule and InventItemLocation table.
For this I wrote a job. If anything wrong please let me know.
My code is:
InventTable inventTable;
InventTableModule inventTableModule;
InventItemLocation inventItemLocation;
BOMUnitId UOM;
Price price1;

;
ttsbegin;

while select inventTable
{
while select forupdate inventItemLocation
{
inventItemLocation.initValue();
inventItemLocation.ItemId = inventTable.ItemId;
inventItemLocation.InventDimId = InventDim::inventDimIdBlank();
if(inventItemLocation.validateWrite())
{
inventItemLocation.insert();
}
}
}

while select inventTable
{
while select forupdate inventTableModule
{

inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;

inventTableModule.UnitId= UOM;
inventTableModule.Price = price1;
inventTableModule.OverDeliveryPct=0;
inventTableModule.UnderDeliveryPct=100;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
if(inventTableModule.validateWrite())
{
inventTableModule.insert();
}
}
}
ttscommit;
}

Hi,

1.Why are you inserting record for the update statement(while select for update inventitemlocation,inventtablle module).

2.There is no comparision in child loop based on the parent loop.

3.Did you noticed for every item creation.System will create 3 records in invent table module(Invent,Purch,Sales).