void lookup()
{
InventTable inventTable;
InventModelGroupItem inventModelGroupItem;
InventItemGroupItem inventItemGroupItem;
InventTableModule inventTableModule;
InventItemSetupSupplyType inventItemSetupSupplyType;
EcoResStorageDimensionGroupItem ecoResStorageDimensionGroupItem;
EcoResTrackingDimensionGroupItem ecoResTrackingDimensionGroupItem;
EcoResStorageDimensionGroupProduct ecoResStorageDimensionGroupProduct;
EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
//Release product or product master
inventTable.clear();
inventTable.initValue();
if (ecoResDistinctProduct.RecId)
{
inventTable.initFromEcoResProduct(ecoResDistinctProduct);
}
else if (ecoResProductMaster.RecId)
{
inventTable.initFromEcoResProduct(ecoResProductMaster);
}
inventTable.ItemId = ProductNumber.valueStr();
inventTable.NameAlias = Name.valueStr();
if (inventTable.validateWrite())
{
inventTable.insert();
//Inventory model group
inventModelGroupItem.clear();
inventModelGroupItem.initValue();
inventModelGroupItem.ItemDataAreaId = inventTable.dataAreaId;
inventModelGroupItem.ItemId = inventTable.ItemId;
//inventModelGroupItem.ModelGroupId = "FIFO";
inventModelGroupItem.ModelGroupDataAreaId = curext();
inventModelGroupItem.insert();
//Item group
inventItemGroupItem.clear();
inventItemGroupItem.initValue();
inventItemGroupItem.ItemDataAreaId = inventTable.dataAreaId;
inventItemGroupItem.ItemId = inventTable.ItemId;
//inventItemGroupItem.ItemGroupId = "Parts";
inventItemGroupItem.ItemGroupDataAreaId = curext();
inventItemGroupItem.insert();
//Extended product details – Inventory
inventTableModule.clear();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
inventTableModule.insert();
//Extended product details – Purchase
inventTableModule.clear();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
inventTableModule.insert();
//Extended product details – Sales
inventTableModule.clear();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
inventTableModule.insert();
//Warehouse items
InventItemLocation::createDefault(inventTable.ItemId);
//Supply type setup
inventItemSetupSupplyType.clear();
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();
//Product storage dimension group
ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResDistinctProduct.RecId);
if (ecoResStorageDimensionGroupProduct.RecId)
{
ecoResStorageDimensionGroupItem.clear();
ecoResStorageDimensionGroupItem.initValue();
ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
ecoResStorageDimensionGroupItem.insert();
}
//Product tracking dimension group
ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResDistinctProduct.RecId);
if (ecoResTrackingDimensionGroupProduct.RecId)
{
ecoResTrackingDimensionGroupItem.clear();
ecoResTrackingDimensionGroupItem.initValue();
ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
ecoResTrackingDimensionGroupItem.insert();
}
}