Hi,
Importing products (distinct) into AX2012 using the ecoResProduct service i have a question.
In the following example I am reading items from a comma seperated file. Now for each read
record I initialize all the service objects that are being used to create the product, and at the end
i add the product to the ecoResProd object and create it using the service. Is this the correct way
to use the service, calling the ecoProdSvc.create() for each record read ? If I dont call the ecoProdSvc.create()
and just add them to the ecoResProd.createProduct().add(distMaster);, I get an error telling me that the product
exist.
static void AXCImportItemUsingAXD(Args _args)
{
EcoResProductService ecoProdSvc;
EcoResEcoResProduct ecoResProd;
EcoResEcoResProduct_Product_Distinct distMaster;
EcoResEcoResProduct_translation translation;
EcoResEcoResProduct_Identifier identifier;
EcoResEcoResProduct_ProductDimGroup prodDimGroup;
EcoResEcoResProduct_StorageDimGroup storDimGroup;
EcoResEcoResProduct_TrackingDimGroup tracDimGroup;
EcoResProduct ecoResProduct;
;
while (io.status() == IO_Status::OK)
{
// initialize the Service object
ecoProdSvc = EcoResProductService::construct();
// initialize the EcoResEcoResProduct object
ecoResProd = new EcoResEcoResProduct();
// Create a new product distinct master
distMaster = new EcoResEcoResProduct_Product_Distinct();
// Take the newly created and initialize ProdMaster
// variable and fill with product data
distMaster.parmDisplayProductNumber(strLRTrim(conPeek(readCon,1)));
distMaster.parmProductType(EcoResProductType::Item);
distMaster.parmSearchName(strLRTrim(conPeek(readCon,2)));
// Create a translation object
translation = distMaster.createTranslation().addNew();
// fill the translation object
translation.parmDescription(strLRTrim(conPeek(readCon,2)));
translation.parmLanguageId(“da”);
translation.parmName(strLRTrim(conPeek(readCon,1)));
// Create a new identifier object
Identifier = distMaster.createIdentifier().addNew();
// fill the identifier
identifier.parmProductNumber(strLRTrim(conPeek(readCon,1)));
// Create the StorageDimgroup object
storDimGroup = distMaster.createStorageDimGroup().addNew();
storDimGroup.parmProduct(strLRTrim(conPeek(readCon,1)));
storDimGroup.parmStorageDimensionGroup(“HW”);
// Create the TrackingDimGroup object
tracDimGroup = distMaster.createTrackingDimGroup().addNew();
tracDimGroup.parmProduct(strLRTrim(conPeek(readCon,1)));
tracDimGroup.parmTrackingDimensionGroup(“HW-SER”);
// add the product to ecoResProd
ecoResProd.createProduct().add(distMaster);
// create the product using service
ecoProdSvc.create(ecoResProd);
}
}