Thursday, August 25, 2016

Extracting all possible ledger combinations in account structure

This post describes how to extract all possible ledger combination in accounts structures. 

Execute the following job to obtains all valid combinations.

static void srclJobExtractAllAccountStruct(Args _args)
{
    DimensionHierarchy                  dimensionHierarchy;
    DimensionAttribute                  dimensionAttribute;
    DimensionHierarchyLevel             dimensionHierarchyLevel;
    DimensionConstraintNode             dimensionConstraintNode;
    DimensionConstraintNodeCriteria     dimensionConstraintNodeCriteria;
    
    setPrefix('Account Structures Combination');
    
    while select Name from dimensionHierarchy
        where dimensionHierarchy.StructureType == DimensionHierarchyType::AccountStructure
    join RecId from dimensionHierarchyLevel
        where dimensionHierarchyLevel.DimensionHierarchy == dimensionHierarchy.RecId
    join Name from dimensionAttribute
        where dimensionHierarchyLevel.DimensionAttribute == dimensionAttribute.RecId
    join RecId from dimensionConstraintNode
        where dimensionConstraintNode.DimensionHierarchyLevel == dimensionHierarchyLevel.RecId
    join RangeFrom, RangeTo from dimensionConstraintNodeCriteria
        where dimensionConstraintNodeCriteria.DimensionConstraintNode == dimensionConstraintNode.RecId
    {
        setPrefix(dimensionHierarchy.Name);
        info(strFmt('%1 | %2 - %3', dimensionAttribute.Name, dimensionConstraintNodeCriteria.RangeFrom, dimensionConstraintNodeCriteria.RangeTo));
    }
}

Output