Wednesday, October 29, 2014

Fetching Financial Dimension Value X++

This post shows the code for extracting Financial Dimension value by providing dimension name for each dimension combination which is created and persisted. 

The DimensionAttributeValueCombination table contains information about accounts and various dimensions combinations that are used. However, they are stored as a combination ex: (100010-AX-00001- – – -). These values are retrieved through DimensionAttributeValueSetStorage storage class. This class can be used to manipulate these combinations.

The job below helps you in finding out the required values. 


static void AI_GetProjectCostCenterValue(Args _args)
{
    ProjTable                           projTable;
    DimensionAttributeValueSetStorage   dimStorage;
    str                                 dimValue;
       
    projTable = projTable::find('000409');
    dimStorage = DimensionAttributeValueSetStorage::find
                 projTable.DefaultDimension);
    
    info(strFmt('Project 000409, Cost Center value : %1',                        dimStorage.getDisplayValueByDimensionAttribute(                      DimensionAttribute::findByName('CostCenter').RecId)));
    
}

Output

Project 
In order to fetch Value and Description use the following query

      DimensionAttributeValueSet      dimensionAttributeValueSet;
    DimensionAttributeValueSetItem  dimensionAttributeValueSetItem;
    DimensionAttributeValue         dimensionAttributeValue;
    DimensionAttribute              dimensionAttribute;
    DimensionFinancialTag           dimensionFinancialTag;
    ProjTable                       projTable;

    while select RecId from projTable
        join RecId from dimensionAttributeValueSet
            where dimensionAttributeValueSet.RecId == projTable.DefaultDimension
               && projTable.ProjId == this.ProjId
        join RecId from dimensionAttributeValueSetItem
            where dimensionAttributeValueSetItem.DimensionAttributeValueSet == dimensionAttributeValueSet.RecId
        join RecId from dimensionAttributeValue
            where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
        join RecId from dimensionAttribute
            where dimensionAttributeValue.DimensionAttribute == dimensionAttribute.RecId
//&& dimensionAttribute.Name == 'A_Managing_Group' //Un Comment to get specific value of Financial Dimension
        join Description from dimensionFinancialTag
            where dimensionFinancialTag.RecId == dimensionAttributeValue.EntityInstance
{
    info(strfmt('%1', dimensionFinancialTag.Description));
}

2 comments:

  1. How do I fetch the default dimensions on the projects using an sql statement?

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete