How to get ledger dimension values for active account structure in AX 2012

These are the jobs for getting ledger dimension values for active account structure in AX 2012
1*
static void getDimensionCombinationValues(Args _args)
{
    DimensionAttributeLevelValueAllView dimensionAttributeLevelValueAllView;
    DimensionAttribute                  dimensionAttribute;   
    Set                                 dimensionAttributeProcessed;
    LedgerDimensionAccount              _ledgerDimension;
    str                                 segmentName, 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 = 22565435768;
    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;
                segmentDescription = DimensionAttributeValue::find(
                    dimensionAttributeLevelValueAllView.AttributeValueRecId).getName();

                dimensionAttributeProcessed.add(dimensionAttribute.RecId);               
                info(strFmt("%1: %2, %3", segmentName, segmentValue, segmentDescription));
            }
        }
    }
} 

 2*
static void getActiveDimensionCombinationValues(Args _args)
{
    // DimensionAttributeValueCombination stores the combinations of dimension values
    // Any tables that uses dimension  combinations for main account and dimensions
    // Has a reference to this table’s recid
    DimensionAttributeValueCombination  dimAttrValueCombination;   
    // Class Dimension storage is used to store and manipulate the values of combination
    DimensionStorage        dimensionStorage;
    // Class DimensionStorageSegment will get specfic segments based on hierarchies
    DimensionStorageSegment segment;
    int                     segmentCount, segmentIndex;
    int                     hierarchyCount, hierarchyIndex;
    str                     segmentName, segmentDescription;
    SysDim                  segmentValue;
    DimensionHierarchy      dimensionHierarchy;
    LedgerDimensionAccount  ledgerDimension;
    ;
      
    ledgerDimension = 22565435768;
    setPrefix("Dimension values");
    //Fetch the Value combination record
    dimAttrValueCombination = DimensionAttributeValueCombination::find(ledgerDimension);
    setPrefix("Breakup for " + dimAttrValueCombination.DisplayValue);

    // Get dimension storage
    dimensionStorage = DimensionStorage::findById(ledgerDimension,true);
   
    if (dimensionStorage == null)
    {
        throw error("@SYS83964");
    }
    dimensionHierarchy = DimensionStorage::getAccountStructureFromLedgerDimension(ledgerDimension);
    // Get hierarchy count
    hierarchyCount = dimensionStorage.hierarchyCount();
    //Loop through hierarchies to get individual segments
    for(hierarchyIndex = 1; hierarchyIndex <= hierarchyCount; hierarchyIndex++)
    {
        //get segment value for active account structure
        if( dimensionHierarchy.RecId == DimensionHierarchy::find(dimensionStorage.getHierarchyId(hierarchyIndex)).RecId)
        {
            setPrefix(strFmt("Hierarchy: %1", dimensionHierarchy.Name));
            //Get segment count for hierarchy
            segmentCount = dimensionStorage.segmentCountForHierarchy(hierarchyIndex);

            //Loop through segments and display required values
            for (segmentIndex = 1; segmentIndex <= segmentCount; segmentIndex++)
            {
                // Get segment
                segment = dimensionStorage.getSegmentForHierarchy(hierarchyIndex, segmentIndex);

                // Get the segment information
                if (segment.parmDimensionAttributeValueId() != 0)
                {
                    // Get segment name
                    segmentName = DimensionAttribute::find(DimensionAttributeValue::find(segment.parmDimensionAttributeValueId()).DimensionAttribute).Name;
                    //Get segment value (id of the dimension)
                    segmentValue        = segment.parmDisplayValue();
                    //Get segment value name (Description for dimension)
                    segmentDescription  = segment.getName();
                    info(strFmt("%1: %2, %3", segmentName, segmentValue, segmentDescription));
                }
            }
        }
    }
}


How to utilize Correspondence, function of Russia in AX 2012 for different countrys (Resolving problem with many–to–many transactions in AX 2012)

What is Correspondence?

Correspondence of accounts is an approach to continuous and interrelated registration of business transactions in corresponding general ledger accounts, based on the double-entry bookkeeping system. Ledger vouchers are represented by using the Russian accounting standards with corresponding accounts.




















1. Allow using Correspondence on GL parameter












How to active >> Add your country ISO code to extended data type LedgerBondUseCorrespondence_RU 
























2. Active Manual Correspondence : GL > Periodic > Manual correspondence











How to active >> Add your country ISO code >> follow path in below pic
























3. Do the same for base enum LedgerBondShowMode_RU
4. Modify project RU_GL_Correspondence and class SysCountryRegionCode to make your country Region is legal for these function  
5. Do a many-to-many journal in GL for testing
6. Have a look on GL > GL > Periodic > Manual correspondence










  


******* These are just a few simple steps to make it display and reference.
If you want to make this function working without using country code RUS, you have to work more customization on project RU_GL_Correspondence or contact me for a solution

How to pull out some hidden reports in AX

Sometimes in different countries, you cannot find some specific reports.
ex: i cannot see Balance sheet or Ledger statement in VN

In CEU demo data:

Follow these steps to pull out some hidden reports in AX:
Go to AOT > Menu > GL >Reports > Transactions 
You will see the hidden report here.
Go properties and see it from Output > LedgerStatement

Go to Menu Items > Output > LedgerStatement > Go properties > add your company country code to CountryRegionCodes node ---> in this case i add VN

Save and open AX again, you'll see your report


How to get query range value in Ctrl + G or standard filter on form in AX

After super() in excuteQuery() method in AX add this following code:
AX 2009:
info(YourDataSource_Ds.queryRun().query().dataSourceNo(1).toString());

AX 2012:
 info(YourDataSource_Ds.queryRunQueryBuildDataSource().toString());

or

q = YourDataSource_Ds.queryRun().query();
for (i = 1; i <= q.queryFilterCount(); i++)
{
    qf = q.queryFilter(i);
    info(strFmt("%1: %2", qf.field(), qf.value()));
}