web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to get Financial Dimension Cost Center value for the Report!

(0) ShareShare
ReportReport
Posted on by 1,883

Dear all,

I need financial dimension cost center value for Purchase order confirmation report. I wrote following method on purchtable to get the value cost center for all purchase order reports. Please kindly have a look on below method and its not returning any value. 

public str getCostCenterByDefaultDimension()
{
DimensionAttributeValueSetStorage dimStorage;
Str costCenter;
Counter i;

dimStorage = DimensionAttributeValueSetStorage::find(this.DefaultDimension);

for (i= 1 ; i<= dimStorage.elements() ; i++)
{
 
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == 'CostCenter')
{
costCenter = dimStorage.getDisplayValueByIndex(i);
}
}

return costCenter;
}

Best Regards,

Faqru Shaik

*This post is locked for comments

I have the same question (0)
  • Mariano Gracia Profile Picture
    on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    this is an example with VendTable instead of PurchTable:

    static void tutorialAccesDisplayDimensionValue(Args _args)
    {
        VendTable                       vendTable;
        DimensionAttributeValueSetItem  dimensionAttributeValueSetItem;
        DimensionAttributeValue         dimensionAttributeValue;
        DimensionAttribute              dimensionAttribute;
    
        while select firstOnly vendTable
            where vendTable.DefaultDimension
            join dimensionAttributeValueSetItem
            index hint ValueSetAttributeValueIdx
            where dimensionAttributeValueSetItem.DimensionAttributeValueSet == vendTable.DefaultDimension
            join dimensionAttributeValue
                index hint RecId
                where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
                join DimensionAttribute
                    index hint RecId
                    where dimensionAttribute.RecId  == dimensionAttributeValue.DimensionAttribute
                       && dimensionAttribute.BackingEntityType == tableNum(DimensionFinancialTag) // Cost center dimension
        {
            info(strFmt("%1 %2", dimensionAttribute.localizedName(), dimensionAttributeValueSetItem.DisplayValue));
        }
    }


  • Faqruddin Profile Picture
    1,883 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Hello Mariano,

    I wants to use above method in RDP class. But I have following error..

    The table 'VendTable' does not contain the method 'tutorialAccesDisplayDimensionValue'.

  • Mariano Gracia Profile Picture
    on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    What I have posted is a job, of course the VendTable does not contains that method, you shoud create a new method in the PurchTable and add the code (of course you will need to modify it)

  • Faqruddin Profile Picture
    1,883 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    I didn't check properly. I just do small modification above method. But In RDP when I call this method I have error "The wrong number of arguments has been specified for the method".

    Could you please check the code and correct me.

    public str tutorialAccesDisplayDimensionValue(VendTable vendTable )

    {

       DimensionAttributeValueSetItem  dimensionAttributeValueSetItem;

       DimensionAttributeValue         dimensionAttributeValue;

       DimensionAttribute              dimensionAttribute;

       DimensionAttributeValueSet      dimAttrValueSet;

        select firstOnly vendTable

           where vendTable.DefaultDimension

           join dimensionAttributeValueSetItem

           index hint ValueSetAttributeValueIdx

           where dimensionAttributeValueSetItem.DimensionAttributeValueSet == vendTable.DefaultDimension

           join dimensionAttributeValue

               index hint RecId

               where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue

               join DimensionAttribute

                   index hint RecId

                   where dimensionAttribute.RecId  == dimensionAttributeValue.DimensionAttribute

                      && dimensionAttribute.BackingEntityType == tableNum(DimensionFinancialTag); // Cost center dimension

       return dimensionAttributeValue.getValue();

    }

  • Faqruddin Profile Picture
    1,883 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Dears, 

    I need cost center dimension for Purchase order reports. Please have a look my code.

      display public DimensionValue displayCostCenter()
    
      {
    
       PurchTable                      purchTable;
       DimensionDefault                defaultdimension;
       AccountingDistribution         accountingDistributionLoc;
       DimensionAttribute            DimensionAttributeLoc;
       DimensionAttributeValue        DimensionAttributeValueLoc;
       DimensionAttributeValueSetItem    DimAttrValueSetItemLoc;
    
       purchTable = PurchTable::find(this.PurchId);
      
    
       select accountingDistributionLoc
           where  purchTable.SourceDocumentHeader ==  accountingDistributionLoc.SourceDocumentHeader
           && this.SourceDocumentLine           ==  accountingDistributionLoc.SourceDocumentLine;
    
       defaultdimension = DimensionStorage::GetDefaultDimensionfromLedgerDimension(accountingDistributionLoc.LedgerDimension);
    
       select RecId, Name from DimensionAttributeLoc
              join RecId, DimensionAttribute from DimensionAttributeValueLoc
          join DimAttrValueSetItemLoc
                   where DimensionAttributeValueLoc.DimensionAttribute    ==  DimensionAttributeLoc.RecId
                  && DimAttrValueSetItemLoc.DimensionAttributeValue == DimensionAttributeValueLoc.RecId
                  && DimAttrValueSetItemLoc.DimensionAttributeValueSet == defaultdimension
              && DimensionAttributeLoc.Name == "CostCenter";
    
      return DimAttrValueSetItemLoc.DisplayValue;
    }


  • Mariano Gracia Profile Picture
    on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Why do you look at the AccountingDistribution table?, why don't you use PurchTable.DefaultDimension field?

    Don't use the Name field to search the dimensionAttribute record, try to use BackingEntityType field, each dimension has a related view (the cost center dimension has the DimensionFinancialTag view, the customer dimension has the DimAttributeCustTable, and so on), if you are using a personalized dimension filter by a RecId value parametrized else where:

    select firstOnly dimensionAttributeValueSetItem
            index hint ValueSetAttributeValueIdx
            where dimensionAttributeValueSetItem.DimensionAttributeValueSet == purchTable.DefaultDimension
            join dimensionAttributeValue
                index hint RecId
                where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue
                join DimensionAttribute
                    index hint RecId
                    where dimensionAttribute.RecId  == dimensionAttributeValue.DimensionAttribute
                       && dimensionAttribute.BackingEntityType == tableNum(DimensionFinancialTag);


  • XB Profile Picture
    1,875 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Check this

  • Sohaib Cheema Profile Picture
    49,141 User Group Leader on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Hi Faqrue,

    for better understanding of you own-self you may divide the problem into parts

    1) Display methods don't work with temp tables. (make sure you are not doing this)

    2) return a hard coded value e.g. ret "Test string"; and fix your report

    3) discuss/review code for retrieval of dimension

  • Faqruddin Profile Picture
    1,883 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Hello,

    Thanks for your replies. Mr. Sohaib thanks for your information. I make it above code as public but still I didn't get cost center value for purchase order report. Please let me know, Is this correct way to call below method in RDP  class.

    public DimensionValue displayCostCenter()

     {

       PurchTable purchTable;

       DimensionAttributeValueSetItem  dimensionAttributeValueSetItem;

       DimensionAttributeValue         dimensionAttributeValue;

       DimensionAttribute              dimensionAttribute;

      select firstOnly dimensionAttributeValueSetItem

           index hint ValueSetAttributeValueIdx

           where dimensionAttributeValueSetItem.DimensionAttributeValueSet == purchTable.DefaultDimension

           join dimensionAttributeValue

               index hint RecId

               where dimensionAttributeValue.RecId == dimensionAttributeValueSetItem.DimensionAttributeValue

               join DimensionAttribute

                   index hint RecId

                   where dimensionAttribute.RecId  == dimensionAttributeValue.DimensionAttribute

                      && dimensionAttribute.BackingEntityType == tableNum(DimensionFinancialTag);

         return dimensionAttributeValueSetItem.DisplayValue;

     }

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at
    RE: How to get Financial Dimension Cost Center value for the Report!

    Hi Faqru Shaik,

    There is an error in your select statement.

    DimensionFinancialTag contains custom dimension ( dimensions that does not have backing entity), if you want to get Cost center you need to use tableNum(DimAttributeOMCostCenter)

    However, theoretically you can have multiple dimensions with same backing entity but different names, e.g. you can create "Cost Center 2". In this case select statement will return you first attribute with this backing entity type, so I personally prefer to have a parameter where user can specify what dimensions is required for this functionality, or search attribute by name.

    You can try next code:

    DimensionAttribute                 attribute = DimensionAttribute::findByName("Cost center");
    DimensionAttributeValueSetItemView dimensionAttributeValueSetItemView ;
    
    select DisplayValue from dimensionAttributeValueSetItemView 
        where dimensionAttributeValueSetItemView.DimensionAttributeValueSet == purchTable.DefaultDimension 
           && dimensionAttributeValueSetItemView.DimensionAttribute         == attribute.RecId;
    
    return dimensionAttributeValueSetItemView.DisplayValue;


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Willem van Duren Profile Picture

Willem van Duren 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans