Wednesday, September 11, 2013

Display methods for Default Dimension Display


How to display default financial dimension values on other form or report


We have Default Financial Dimension on major entity forms. How to show them in a display method w.r.t. entity id. I am taking Project table here with which we have Financial Dimension attached. We are going to write the below display methods where we want to display the financial dimension values.

display str ProjectDimensionProjectGroup()
{
    DimensionAttributeValueSetStorage       dimStorage;
    ProjTable                               lProjTable;
    Counter                                 i;
    ;

    lProjTable = ProjTable::find(TableView::findRecId(this.RecId).ProjId);
    dimStorage = DimensionAttributeValueSetStorage::find(lProjTable.DefaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "ProjectGroup")
        {
            return strFmt("%1",dimStorage.getDisplayValueByIndex(i));
        }
    }
    return '';
}

display str ProjectDimensionBusinessUnit()
{
    DimensionAttributeValueSetStorage       dimStorage;
    ProjTable                               lProjTable;
    Counter                                 i;
    ;

    lProjTable = ProjTable::find(TableView::findRecId(this.RecId).ProjId);
    dimStorage = DimensionAttributeValueSetStorage::find(lProjTable.DefaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "BusinessUnit")
        {
            return strFmt("%1",dimStorage.getDisplayValueByIndex(i));
        }
    }
    return '';
}

display str ProjectDimensionDepartment()
{
    DimensionAttributeValueSetStorage       dimStorage;
    ProjTable                               lProjTable;
    Counter                                 i;
    ;

    lProjTable = ProjTable::find(TableView::findRecId(this.RecId).ProjId);
    dimStorage = DimensionAttributeValueSetStorage::find(lProjTable.DefaultDimension);

    for (i=1 ; i<= dimStorage.elements() ; i++)
    {
        if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Department")
        {
            return strFmt("%1",dimStorage.getDisplayValueByIndex(i));
        }
    }
    return '';
}

And to display Business Unit name rather than value, use below methods:

display str ProjectDimensionBusinessUnit()
{
    ProjTable                               lProjTable;
    DimensionValue                          lDimensionValue;

    DimensionValue getDimension(DimensionDefault _dim,Name _dimName)
    {
        DimensionAttributeValueSetItem  valueSetItem;
        DimensionAttributeValue         dimAttrValue;
        DimensionAttribute              dimAttr;
        ;

        select Name from dimAttr
        join dimAttrValue
        where dimAttrValue.DimensionAttribute == dimAttr.RecId && dimAttr.Name == _dimName
        join valueSetItem
        where valueSetItem.DimensionAttributeValue == dimAttrValue.RecId
            && valueSetItem.DimensionAttributeValueSet == _dim;
    
        return valueSetItem.DisplayValue;
    }
    ;

    lProjTable = ProjTable::find(TableView.ProjId);
    lDimensionValue = getDimension(lProjTable.DefaultDimension,'BusinessUnit'); 

    return (select Name from OMOperatingUnit where OMOperatingUnit.OMOperatingUnitNumber == lDimensionValue).name;

}

2 comments:

  1. This is really interesting and knowledgeable. Thanks for sharing. I really appreciate it a lot. Please do more blogs in the future. Thank you and God bless to the blogger!

    Rica
    www.imarksweb.org

    ReplyDelete
  2. I really enjoyed reading your article. I found this as an informative and interesting post, so i think it is very useful and knowledgeable. I would like to thank you for the effort you have made in writing this article.


    edupdf.org


    ReplyDelete