Monday, September 11, 2023

Fetch the Format of financial dimension formats for data entities using X++

 Fetch the Format of financial dimension formats for data entities using X++.



I have a requirement to fetch the value mentioned in the above SC and the below one.

BusinessUnit-CostCenter-Department-Campaign-Center-Customer-Project-Store


To get this I have used the Dimension format type  and Active for type


Way 1:

    private container getFDFromParameters()
    {
	DimensionHierarchy              dimensionHierarchy;
	DimensionHierarchyIntegration   dimensionHierarchyIntegration;
	container                       con;
	str				delimiter = DimensionParameters::getDimensionSegmentDelimiter();
	
	select firstonly DisplayString from dimensionHierarchyIntegration
	    exists join dimensionHierarchy
		where dimensionHierarchy.RecId == dimensionHierarchyIntegration.DimensionHierarchy
		    && dimensionHierarchy.StructureType == DimensionHierarchyType::DataEntityDefaultDimensionFormat
		    && dimensionHierarchyIntegration.IsDefault == true;

	return str2con(dimensionHierarchyIntegration.DisplayString, delimiter);
    }


Way 2:

    private container getFDFromParameters()
    {
	DimensionHierarchyLevel         dimensionHierarchyLevel;
	DimensionHierarchy              dimensionHierarchy;
	DimensionHierarchyIntegration   dimensionHierarchyIntegration;
	container                       con;

	while select dimensionHierarchyLevel order by dimensionHierarchyLevel.Level
		exists join dimensionHierarchy
		    where dimensionHierarchy.RecId == dimensionHierarchyLevel.DimensionHierarchy
		exists join dimensionHierarchyIntegration
		    where dimensionHierarchyIntegration.DimensionHierarchy == dimensionHierarchy.RecId
	                && dimensionHierarchyIntegration.IsDefault == true
			&& dimensionHierarchy.StructureType == DimensionHierarchyType::DataEntityDefaultDimensionFormat
	{
	    con += DimensionAttribute::find(dimensionHierarchyLevel.DimensionAttribute).Name;
	}

	return con;
    }


Output:




Keep Daxing!! 

No comments:

Post a Comment