Thursday, March 17, 2016

Code to get Main account number and description from LedgerDimension

Hi guys,


Below code can be used to fetch the Main account number and its description from LedgerDimension field. 


DimensionAttributeValueCombination     dimAttrValueComb;
DimensionStorage                                 dimensionStorage;
DimensionDynamicAccount                  _ledgerDimension;       
DimensionStorageSegment                    segment;
str                                                         segmentName, segmentDescription;
SysDim                                                 segmentValue;

 ;

_ledgerDimension      = 5637146328;

dimAttrValueComb      = DimensionAttributeValueCombination::find(_ledgerDimension);

dimensionStorage       = DimensionStorage::findById(_ledgerDimension);
segment                     = dimensionStorage.getSegmentForHierarchy(1, 1);
if (segment.parmDimensionAttributeValueId() != 0)
{
        segmentName         = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;
        if (segmentName == 'MainAccount')
        {
            segmentValue        = segment.parmDisplayValue();
            segmentDescription  = segment.getName();
        }        
}
    info( strFmt("%1,   %2", segmentValue, segmentDescription));

No comments:

Post a Comment