Friday 22 July 2016

How to Convert Ledger dimension into Default dimension

Display Main account from LedgerDimension and convert Ledgerdimension into Defaultdimension:

Hi,
Here We will talk, how to display MainAccountId from LedgerDimension and second, how to convert LedgerDimension into DefaultDimension so that we can display financial dimensions separately....
Code will be like:
Example-1: Suppose we need to display MainAccountId from Purchase requisition detail form/Purchase requisition lines/ Financials/ Distribution amounts (AccountingDistribution table) to Purchase requisition line grid (PurchReqLine table) then code will be like...

//created by v-vimsin on 18th July 2016
//BP deviation documented
display public MainAccountNum MSDisplayLedgerDim()
{
    PurchReqTable           purchReqTableLoc;
    AccountingDistribution  accountingDistributionLoc;

    purchReqTableLoc = PurchReqTable::find(this.PurchReqTable);

    select RecId,SourceDocumentHeader,SourceDocumentLine,LedgerDimension from accountingDistributionLoc
        where  purchReqTableLoc.SourceDocumentHeader    == accountingDistributionLoc.SourceDocumentHeader
            && this.SourceDocumentLine                  == accountingDistributionLoc.SourceDocumentLine;

    return MainAccount::find(DimensionStorage::getMainAccountIdFromLedgerDimension(accountingDistributionLoc.LedgerDimension)).MainAccountId;

}


Example-1: Suppose we need to display Cost center from Purchase requisition detail form/Purchase requisition lines/ Financials/ Distribution amounts (AccountingDistribution table) to Purchase requisition line grid (PurchReqLine table) then we will convert LedgerDimension to DefaultDimension first and then return Cost center. Code will be like...

//created by v-vimsin on 18th July 2016
//BP deviation documented
display public DimensionValue MSDisplayCostCenter()
{
    PurchReqTable                   purchReqTableLoc;
    DimensionDefault                defaultdimension;
    AccountingDistribution          accountingDistributionLoc;
    DimensionAttribute              DimensionAttributeLoc;
    DimensionAttributeValue         DimensionAttributeValueLoc;
    DimensionAttributeValueSetItem  DimAttrValueSetItemLoc;

    purchReqTableLoc = PurchReqTable::find(this.PurchReqTable);

    select RecId,SourceDocumentHeader,SourceDocumentLine,LedgerDimension from accountingDistributionLoc
        where  purchReqTableLoc.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 == "@SYS343410";
    return DimAttrValueSetItemLoc.DisplayValue;
}


For this time that's it.

Happy DAXing....

No comments:

Post a Comment