AX2009:
X++:
static void setDimension(Args _args)
{
CustTable custTable;
ttsBegin;
while select forUpdate custTable
where custTable.LineOfBusinessId
{
custTable.Dimension[1] = custTable.LineOfBusinessId;
custTable.update();
}
ttsCommit;
}
AX2012:
X++:
static void setDimension(Args _args)
{
DimensionValue dimValue;
CustTable custTable;
DimensionFinancialTag dimFinTag;
FinancialTagCategory finTagCat;
DimensionAttributeDirCategory dimAttrCat;
DimensionAttribute dimAttr;
DimensionAttributeValueSetItem dimAttrSetItem;
DimensionAttributeValue dimAttrValue;
DimensionDefault dimDefaultRecId;
ttsBegin;
while select forUpdate custTable
order by custTable.LineOfBusinessId // the dimension value is stored here
where custTable.LineOfBusinessId
{
if (custTable.LineOfBusinessId != dimValue)
{
dimValue = custTable.LineOfBusinessId;
dimDefaultRecId = 0;
select firstOnly dimFinTag
where dimFinTag.Value == dimValue
join finTagCat
where finTagCat.RecId == dimFinTag.FinancialTagCategory
join dimAttrCat
where dimAttrCat.DirCategory == finTagCat.RecId
join dimAttr
where dimAttr.RecId == dimAttrCat.DimensionAttribute
join dimAttrValue
where dimAttrValue.DimensionAttribute == dimAttr.RecId
&& dimAttrValue.EntityInstance == dimFinTag.RecId;
while select count(RecId), maxOf(DimensionAttributeValue) from dimAttrSetItem
group by DimensionAttributeValueSet
{
if (dimAttrSetItem.RecId == 1 && dimAttrSetItem.DimensionAttributeValue == dimAttrValue.RecId)
{
dimDefaultRecId = dimAttrSetItem.DimensionAttributeValueSet;
break;
}
}
}
custTable.DefaultDimension = dimDefaultRecId;
custTable.update();
}
ttsCommit;
}
Разумеется, не забываем сначала пройтись по таблице и сохранить все уникальные значения аналитики вручную, чтобы система создала записи DimensionAttributeValue и DimensionAttributeValueSetItem.