Friday, March 21, 2014

Getting Individual Dimension Combination Values–Using Views [AX 2012]

// Getting Individual Dimension Combination Values–Using Views [AX 2012]


static void sgxIndividualDimensionValuesUsingView(Args _args)
{
    GeneralJournalAccountEntry          generalJournalAccountEntry; //Table that stores ledger transactions
    DimensionAttributeLevelValueAllView dimAttrView; //View that will display all values for ledger dimensions
    DimensionAttribute                  dimAttr; //Main dimension attribute table
    int i;
 
    setPrefix(‘Ledger dimension breakup’);
    while select generalJournalAccountEntry
    {
        i++;
        if (i > 100)
            break;
     
        setPrefix(int2str(i) + “. “ + DimensionAttributeValueCombination::find(generalJournalAccountEntry.LedgerDimension).DisplayValue);
        while select DisplayValue from dimAttrView  
            where dimAttrView.ValueCombinationRecId == generalJournalAccountEntry.LedgerDimension
            join BackingEntityType from dimAttr
                where dimAttr.RecId == dimAttrView.DimensionAttribute
        {
            switch (dimAttr.BackingEntityType)
            {
                case tableNum(DimAttributeMainAccount):
                    info(strFmt(“Main Account: %1?, dimAttrView.DisplayValue));
                    break;
             
                case tableNum(DimAttributeOMBusinessUnit):
                    info(strFmt(“Business Unit: %1?, dimAttrView.DisplayValue));
                    break;

                case tableNum(DimAttributeCustTable):
                    info(strFmt(“Customer: %1?, dimAttrView.DisplayValue));
                    break;

                case tableNum(DimAttributeOMDepartment):
                    info(strFmt(“Department: %1?, dimAttrView.DisplayValue));
                    break;

                case tableNum(DimAttributeHcmWorker):
                    info(strFmt(“Worker: %1?, dimAttrView.DisplayValue));
                    break;
            }  
        }
    }
 
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...