Hi,
How to create a product and release that product based on Company using X++ or manual ax 2012 ??
thanks, advance.. :)
*This post is locked for comments
Hi,
How to create a product and release that product based on Company using X++ or manual ax 2012 ??
thanks, advance.. :)
*This post is locked for comments
use below job, it takes data from excel and create/release product in your current LE - tweak it as needed.
static void createAndReleaseProduct(Args _args)
{
EcoResProductService ecoResProdService;
EcoResEcoResProduct ecoResProd;
EcoResEcoResProduct_Product product;
EcoResEcoResProduct_Translation translation;
EcoResEcoResProduct_Identifier identifier;
EcoResEcoResProduct_ProductDimGroup productDimGroup;
EcoResEcoResProduct_TrackingDimGroup trackingDimGroup;
EcoResEcoResProduct_StorageDimGroup storageDimGroup;
InventModelGroupItem inventModelGroupItem;
InventItemGroupItem inventItemGroupItem;
InventTable inventTable;
DimensionAttributeValueSetStorage storage;
container dimAttributeList;
container dimValueList;
int i;
DimensionDefault defaultDimension;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row;
str productName;
str storageDim;
str trackingDim;
str itemModelGroup;
str itemGroupItem;
str prodDimGroup;
Name searchName;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//specify the file path that you want to read
workbooks.open(@'C:\item.xlsx');
worksheets = workbooks.item(1).worksheets();
worksheet = workbooks.item(1).worksheets().itemFromNum(1);
cells = worksheet.cells();
do
{
row ++;
productName = cells.item(row, 1).value().bStr();
searchName = cells.item(row, 2).value().bStr();
storageDim = cells.item(row, 3).value().bStr();
trackingDim = cells.item(row, 4).value().bStr();
itemModelGroup = cells.item(row, 5).value().bStr();
itemGroupItem = cells.item(row, 6).value().bStr();
type = cells.item(row+1, 1).value().variantType();
//Initialize the service object
ecoResProdService = EcoResProductService::construct();
ecoResProd = new EcoResEcoResProduct();
product = new EcoResEcoResProduct_Product_Distinct();
//Newly created and initialize prodMaster
product.parmDisplayProductNumber(productName);
product.parmProductType(EcoResProductType::Item);
product.parmSearchName(searchName);
//Create a new translation object:
translation = product.createTranslation().addNew();
translation.parmDescription("product");
translation.parmLanguageId("en-us");
translation.parmName("Product data");
identifier = product.createIdentifier().addNew();
identifier.parmProductNumber(productName);
// Storage dimension
storageDimGroup = product.createStorageDimGroup().addNew();
storageDimGroup.parmProduct(productName);
storageDimGroup.parmStorageDimensionGroup(storageDim);
// tracking dimension
trackingDimGroup = product.createTrackingDimGroup().addNew();
trackingDimGroup.parmProduct(productName);
trackingDimGroup.parmTrackingDimensionGroup(trackingDim);
ecoResProd.createProduct().add(product);
ecoResProdService.create(ecoResProd);
// Release to current legal entity
EcoResProductReleaseManager::releaseProductWithLegalEntityData(EcoResProduct::findByProductNumber(productName).RecId,
CompanyInfo::findDataArea(curext()).RecId,
productName,
searchName);
inventTable = InventTable::find(productName);
inventModelGroupItem.clear();
// insert entry to inventModelGroupItem
inventModelGroupItem.ModelGroupId = itemModelGroup;
inventModelGroupItem.ItemDataAreaId = inventTable.dataAreaId;
inventModelGroupItem.ModelGroupDataAreaId = inventTable.dataAreaId;
inventModelGroupItem.ItemId = inventTable.ItemId;
inventModelGroupItem.insert();
inventItemGroupItem.clear();
// insert entry to inventItemGroupItem
inventItemGroupItem.ItemDataAreaId = inventTable.dataAreaId;
inventItemGroupItem.ItemId = inventTable.ItemId;
inventItemGroupItem.ItemGroupId = itemGroupItem;
inventItemGroupItem.ItemGroupDataAreaId = inventTable.dataAreaId;
inventItemGroupItem.insert();
info(strfmt('Product %1 imported and released to legal entity %2.', productName, CompanyInfo::findDataArea(curext()).Name));
}
while (type != COMVariantType::VT_EMPTY);
{
application.quit();
}
}
Please refer the below link to create Products in AX 2012 using X++ code:
pawansaxblog.blogspot.in/.../how-to-create-product-in-ax2012-using-x.html
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156