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

Notifications

Announcements

No record found.

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

    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

    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

    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

    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

    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

    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

    Check this

  • Sohaib Cheema Profile Picture
    49,443 User Group Leader on at

    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

    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

    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans