Product Creation in Ax 2012 using x++


Public void tst_Productcreate()
{
EcoResProductService erProdSvc;
EcoResEcoResProduct EcoResProd;
EcoResEcoResProduct_Product_distinct ProdMast;
EcoResEcoResProduct_Translation Translation;
EcoResEcoResProduct_Identifier Identifier;
EcoResEcoResProduct_ProductDimGroup ProdDimGroup;
EcoResEcoResProduct_Product_Distinct DistProd;
EcoResProduct ecoResProduct;
// Used for releasing Product
EcoResEcoResProduct_StorageDimGroup storageDimGroup;
// Used to assign Storage Dim Group
EcoResEcoResProduct_TrackingDimGroup trackingDimension;
// used to assign Tracking Dimension
erProdSvc = EcoResProductService::construct();
EcoResProd = new EcoResEcoResProduct();
ProdMast = new EcoResEcoResProduct_Product_distinct();
ttsBegin;
ProdMast.parmDisplayProductNumber(“Test84756”);
ProdMast.parmProductType(EcoResProductType::Item);
// Product is Item OR Service
ProdMast.parmSearchName(“Test84756”);
DistProd = new EcoResEcoResProduct_Product_Distinct();
Translation = ProdMast.createTranslation().addNew();
Translation.parmDescription (“Test Product1”);
Translation.parmLanguageId(“en-us”);
Translation.parmName (“Test Product1”);
Identifier = ProdMast.createIdentifier().addNew();
Identifier.parmProductNumber(“Test84756”);
//Code for adding Storage Dimension Group….
storageDimGroup = ProdMast.createStorageDimGroup().addNew();
storageDimGroup.parmProduct(“Test84756”);
storageDimGroup.parmStorageDimensionGroup(“Tst2”);
// Code for adding Tracking Dimension Group….
trackingDimension = ProdMast.createTrackingDimGroup().addNew();
trackingDimension.parmProduct(“Test84756”);
trackingDimension.parmTrackingDimensionGroup(“tst2”);
EcoResProd.createProduct().add(ProdMast);
erProdSvc.create(EcoResProd);
info(“Test Product1 is created”);
// Code for releasing Product
ecoResProduct = EcoResProduct::findByProductNumber(“Test84756”);
EcoResProductReleaseManagerBase::releaseProduct(ecoResProduct.RecId,CompanyInfo::findDataArea(“tst2”).RecId);
ttsCommit;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s