Get Ledger Dimension Value in AX 2012

In Microsoft Dynamics AX 2009, an account number from the LedgerTable table was considered to represent a ledger account. The account number was combined with the financial dimensions array to link financial activity to a ledger account. An example of this was the LedgerTrans table, in which the AccountNum field represented the ledger account and the Dimension field represented the financial dimensions.

In Microsoft Dynamics AX 2012, these fields are deleted and replaced with a single field that holds the main account and all financial dimensions related to financial activity. Of course to get this value from this single field in AX 2012 are more complex than two fields which consist of main account id and array of financial dimension.

There is 2 way in this blog to get ledger dimension value in AX 2012

1.  Using view, see an example on a job below :

static void getDimensionValuesUsingView(Args _args)

 LedgerJournalTrans ledgerJournalTrans; //Table that stores ledger journal transaction
 DimensionAttributeLevelValueAllView dimAttrView; //View that will display all values for ledger dimensions
 DimensionAttribute dimAttr; //Main dimension attribute table
 int i;

 while select ledgerJournalTrans where ledgerJournalTrans.JournalNum == "00432"
 info(strFmt("%1. %2", i, DimensionAttributeValueCombination::find(ledgerJournalTrans.LedgerDimension).DisplayValue));
 while select DisplayValue from dimAttrView 
 where dimAttrView.ValueCombinationRecId == ledgerJournalTrans.LedgerDimension
 join BackingEntityType from dimAttr
 where dimAttr.RecId == dimAttrView.DimensionAttribute
 switch (dimAttr.BackingEntityType)
 //For existing value
 case tableNum(DimAttributeMainAccount):
 info(strFmt("Main Account : %1", dimAttrView.DisplayValue));

 case tableNum(DimAttributeOMBusinessUnit):
 info(strFmt("Business Unit : %1", dimAttrView.DisplayValue));

 case tableNum(DimAttributeCustTable):
 info(strFmt("Customer : %1", dimAttrView.DisplayValue));

 case tableNum(DimAttributeOMDepartment):
 info(strFmt("Department : %1", dimAttrView.DisplayValue));

 case tableNum(DimAttributeHcmWorker):
 info(strFmt("Worker : %1", dimAttrView.DisplayValue));
 //For Custom Financial dimension
 case tableNum(DimensionFinancialTag):
 info(strFmt("%1 : %2", dimAttr.Name, dimAttrView.DisplayValue));


By using job above, yo can get all dimension value from a ledger dimension. Picture below show to you execution result of job above.


2. Using DimensionStorage class

Different from using view example, example below can be used to get a single dimension value, like only main account or only department. Follow step by step below :

Add below method to Global class

public static str getLedgerDimensionValue(RefRecId _ledgerDimension,
 Name _dimensionName)
 DimensionStorage dimensionStorage;
 DimensionStorageSegment segment;
 int segmentCount, segmentIndex;
 int hierarchyCount, hierarchyIndex;
 str segmentName, segmentDescription;
 SysDim segmentValue;

 dimensionStorage = DimensionStorage::findById(_ledgerDimension);
 if (dimensionStorage == null)
 throw error("@SYS83964");

 hierarchyCount = dimensionStorage.hierarchyCount();
 //Loop through hierarchies to get individual segments
 for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++)
 segmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);

 //Loop through segments and display required values
 for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)
 // Get segment
 segment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);

 // Get the segment information
 if (segment.parmDimensionAttributeValueId() != 0 &&
 .DimensionAttribute).Name == _DimensionName)
 segmentValue = segment.parmDisplayValue();
 segmentDescription = segment.getName();

 return segmentValue + " (" + segmentDescription + ")";

To use method above, see an example job below :

static void getSingleDimensionValue(Args _args)
 LedgerJournalTrans ledgerJournalTrans;
 Select firstOnly ledgerJournalTrans where ledgerJournalTrans.JournalNum == "00432";
 info(strFmt("Main account : %1", 
 getLedgerDimensionValue(ledgerJournalTrans.LedgerDimension, "MainAccount")));
 info(strFmt("Department : %1", 
 getLedgerDimensionValue(ledgerJournalTrans.LedgerDimension, "Department")));

and this is the result :



Leave a Reply

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

You are commenting using your 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

Create a website or blog at

Up ↑

%d bloggers like this: