Dimensions

PHOTO EMBED

Tue Jan 21 2025 11:22:59 GMT+0000 (Coordinated Universal Time)

Saved by @MinaTimo

[ExtensionOf(tableStr(GeneralJournalAccountEntry))]
public final class NA_GeneralJournalAccountEntry_Extension
{
    public DimensionDisplayValue getDimensionCombinationValues(LedgerDimensionAccount ledgerdimension)
    {
        DimensionAttributeLevelValueAllView dimensionAttributeLevelValueAllView;
        DimensionAttribute                  dimensionAttribute;
        Set                                 dimensionAttributeProcessed;
        LedgerDimensionAccount              _ledgerDimension;
        str                                 segmentName ;
        DimensionDisplayValue segmentDescription;
        SysDim                              segmentValue;

        str getDynamicAccountAttributeName(TableNameShort _dimensionAttrViewName)
        {

            #Dimensions
            container cachedResult;
            SysModelElement modelElement;
            SysDictTable sysDictTable;
            DictView dictView;
            Label label;

            Debug::assert(_dimensionAttrViewName like #DimensionEnabledPrefixWithWildcard);

            // Get/cache results of the AOT metadata lookup on the view

            cachedResult = DimensionCache::getValue(DimensionCacheScope::DynamicAccountAttributeName, [_dimensionAttrViewName]);

            if (cachedResult == conNull())
            {

                // Find the matching model element and instantiate the AOT metadata definition of the view

                select firstOnly AxId, Name from modelElement
                where  modelElement.ElementType == UtilElementType::Table
                    && modelElement.Name == _dimensionAttrViewName;


                sysDictTable = new sysDictTable(modelElement.AxId);

                Debug::assert(sysDictTable.isView());

                // Create an instance of the view and get the singular representation of the entity name as a label ID (do not translate)

                dictView = new dictView(modelElement.AxId);

                cachedResult = [dictView.singularLabel()];

                DimensionCache::insertValue(DimensionCacheScope::DynamicAccountAttributeName, [_dimensionAttrViewName], cachedResult);

            }

            label = new label();


            return label.extractString(conPeek(cachedResult, 1));
        }


        _ledgerDimension = ledgerdimension;

        if (_ledgerDimension)
        {

            dimensionAttributeProcessed = new Set(extendedTypeId2Type(extendedTypeNum(DimensionAttributeRecId)));

            while select DisplayValue, AttributeValueRecId from dimensionAttributeLevelValueAllView
            order by dimensionAttributeLevelValueAllView.GroupOrdinal, dimensionAttributeLevelValueAllView.ValueOrdinal
            where dimensionAttributeLevelValueAllView.ValueCombinationRecId == _ledgerDimension
            join Name, Type, ViewName, RecId from dimensionAttribute
                where dimensionAttribute.RecId == dimensionAttributeLevelValueAllView.DimensionAttribute

            {
                if (!dimensionAttributeProcessed.in(dimensionAttribute.RecId))
                {
                    if (DimensionAttributeType::DynamicAccount == dimensionAttribute.Type)
                    {
                        // Use the singular name of the view backing the multi-typed entity
                        segmentName = getDynamicAccountAttributeName(dimensionAttribute.ViewName);
                    }
                    else
                    {
                        // Use the name of the attribute directly for all other types (main account, custom list, existing list)
                        segmentName = dimensionAttribute.localizedName();
                    }

                    segmentValue = dimensionAttributeLevelValueAllView.DisplayValue;

                    if (strLen(segmentDescription) == 0)

                    {

                        segmentDescription = DimensionAttributeValue::find(

 

                    dimensionAttributeLevelValueAllView.AttributeValueRecId).getName();

                    }

                    else

                    {

                        segmentDescription += strFmt(" - %1", DimensionAttributeValue::find(

 

                    dimensionAttributeLevelValueAllView.AttributeValueRecId).getName());

                    }

                    dimensionAttributeProcessed.add(dimensionAttribute.RecId);

                }

            }

        }

        return  segmentDescription;

    }

    public display  str 200 DimensionValue()
    {

        return this.getDimensionCombinationValues(this.LedgerDimension);
     
    }

    public display  str 200 MOFID()
    {
        DimensionAttributeValueSetStorage dimStorage;
        ;
        dimStorage = DimensionAttributeValueSetStorage::find(LedgerDimensionFacade::getDefaultDimensionFromLedgerDimension(this.LedgerDimension));
        return dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName("FD11_MOF").RecId);
      
    }

    public display  str 200 MOFName()
    {   
        DimensionFinancialTag DimensionFinancialTag;
        select DimensionFinancialTag where DimensionFinancialTag.Value == this.MOFID();
        return DimensionFinancialTag.Description;
      
    }

    public display  str 200 DimensionID()
    {
       return LedgerDimensionFacade::getDisplayValueForLedgerDimension(this.LedgerDimension);
    }

    public display  str 200 ItemId()
    {
        DimensionAttributeValueSetStorage dimStorage;
        ;
        dimStorage = DimensionAttributeValueSetStorage::find(LedgerDimensionFacade::getDefaultDimensionFromLedgerDimension(this.LedgerDimension));
        return dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName("FD10_Item").RecId);
      
    }

}
content_copyCOPY