// Getting Dimension Values from LedgerDimension in Ax 2012
static void getDimensionValueFromLedgerDimension(Args _args)
{
DimensionAttribute dimensionAttributeTable;
DimensionAttributeValueGroupStatus dimAttrValueGroupStatusTable;
DimensionAttributeValueGroupCombination dimAttrValueGroupComboTable;
DimensionAttributeValueGroup dimAttrValueGroupTable;
DimensionAttributeLevelValue dimAttrLevelValueTable;
DimensionAttributeValue dimAttrValueTable;
DimensionAttrValueCOAOverride dimAttrValueCOAOverrideTable;
DimensionAttrValueLedgerOverride dimAttrValueLedgerOverrideTable;
DimensionFinancialTag dimensionFinancialTagTable;
InventPosting inventPostingTable;
DimensionValue Dimension1, Dimension2, Dimension3;
MainAccountNum LedgerAccount;
RecId LedgerRecId, dimCombinationId;
dimCombinationId = 5637144728; // for example here i gave a valid ledgerdimension
// find MainAccountId from LedgerDimension
LedgerAccount = MainAccount::findByLedgerDimension(dimCombinationId).MainAccountId;
LedgerRecId = Ledger::findLedgerRecIdByLegalEntity(CompanyInfo::findDataArea(curext()).RecId);
Dimension1 = “”;
Dimension2 = “”;
Dimension3 = “”;
while select Ordinal from dimAttrValueGroupComboTable order by Ordinal
where dimAttrValueGroupComboTable.DimensionAttributeValueCombination == dimCombinationId
join dimAttrValueGroupTable
where dimAttrValueGroupTable.RecId == dimAttrValueGroupComboTable.DimensionAttributeValueGroup
outer join dimAttrValueGroupStatusTable
where dimAttrValueGroupStatusTable.DimensionAttributeValueGroup == dimAttrValueGroupTable.RecId
join dimAttrLevelValueTable
where dimAttrLevelValueTable.DimensionAttributeValueGroup == dimAttrValueGroupTable.RecId
join pessimisticLock IsSuspended, IsTotal, ActiveFrom, ActiveTo, DimensionAttribute, RecId, EntityInstance from dimAttrValueTable
where dimAttrValueTable.RecId == dimAttrLevelValueTable.DimensionAttributeValue
outer join pessimisticLock IsSuspended, ActiveFrom, ActiveTo, RecId from dimAttrValueCOAOverrideTable
where dimAttrValueCOAOverrideTable.DimensionAttributeValue == dimAttrValueTable.RecId && dimAttrValueCOAOverrideTable.ChartOfAccounts == LedgerChartOfAccounts::current()
outer join pessimisticLock IsSuspended, ActiveFrom, ActiveTo, RecId from dimAttrValueLedgerOverrideTable
where dimAttrValueLedgerOverrideTable.DimensionAttributeValue == dimAttrValueTable.RecId && dimAttrValueLedgerOverrideTable.Ledger == LedgerRecId
{
dimensionFinancialTagTable = null;
select * from dimensionFinancialTagTable
where dimensionFinancialTagTable.RecId == dimAttrValueTable.EntityInstance
join dimensionAttributeTable
where dimensionAttributeTable.RecId == dimAttrValueTable.DimensionAttribute;
if (dimensionAttributeTable.Name == ‘Department’)
{
Dimension1 = dimensionFinancialTagTable.Value;
}
if (dimensionAttributeTable.Name == ‘CostCenter’)
{
Dimension2 = dimensionFinancialTagTable.Value;
}
if (dimensionAttributeTable.Name == ‘Purpose’)
{
Dimension3 = dimensionFinancialTagTable.Value;
}
}
info(strFmt(“%1 %2 %3?,Dimension1,Dimension2,Dimension3));
}