During data upgrade to AX2012 we had issue in ‘Product Upgrade’ preprocessing checklist. Validation errors were observed due to presence of same item in different companies with different‘DimGroupId’ or ‘ItemType’ values.
Accordingly the String size of ‘itemIdBase’ and ‘EcoResProductNumber’ EDTs were increased to 30 to avoid the truncation of ‘ItemId’ and ‘ProductNumber’.
Only way left to resolve the issue was by renaming the ‘ItemId’ of these items. So we renamed all the items which are of type ‘StopItem’ to ‘%Old Item Name’.
The best option left to optimize the work load instead of manually updating the item was to use the renamePrimaryKey method.
static void renamePKInventTable()
{
#File
#define.prefixItem('Old')
InventTable inventTable;
container getCompanyList;
int i;
DataAreaName id;
container getCompany()
{
dataArea dataArea;
// Virtual Companies should not be added.
while select dataArea
where dataArea.isVirtual != NoYes::Yes
{
getCompanyList += [dataArea.id];
}
return getCompanyList;
}
;
getCompanyList = getCompany();
for(i = 1; i<= conlen(getCompanyList); i++)
{
id = conpeek(getCompanyList, i);
changeCompany(id)
{
inventTable.clear();
while select inventTable
where inventTable.RMCItemType == RMCItemType::StopItem
&& inventTable.dataAreaId == id
&& !(inventTable.ItemId like 'Old*')
{
ttsbegin;
inventTable.ItemId = #prefixItem +
#delimiterSpace +
inventTable.ItemId;
inventTable.renamePrimaryKey();
if(inventTable)
{
inventTable.selectForUpdate(boolean::true);
inventTable.ItemName = inventTable.ItemId;
inventTable.NameAlias = inventTable.ItemName;
inventTable.update();
}
ttscommit;
}
}
}
}
This X++ script renamed all the Items in Item Master across companies except the virtual company...!!
Iace Technologies and Services...!!!
No comments:
Post a Comment