Monday, 25 November 2013

Display methods for Default Dimension Display

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;

}

No comments:

Post a Comment

SQL/SSRS Interview questions I thought of blogging some SQL/SSRS interview questions.

Below are some. I will add more, when I complete the compilation 1. What is OLTP(Online Transaction Processing)? OLTP stands ...