Creating default dimension in AX 2012

/// <summary>
/// Create the Dynamic Default Financial Dimension on the basis of provided dimension values.
/// </summary>
/// <param name=”_dimensionColumnValue”>
/// Fill container variable with required Financial Dimension values.
/// </param>
/// <param name=”_dimensionColumnName”>
/// Fill container variable with the method getFinancialDimensionColumnNames
/// </param>
/// <returns>
/// Financial Dimension Rec ID.
/// </returns>
/// <remarks>
///
/// </remarks>

//Code written by Ahmed Alam on 30th December, 2013
//ReasonCode: To get the new default dimension value on the basis of provided dimension default value
//public Static RecId createDefaultDimensiononString( str 3 _branch, str 2 _dept, str 4 _CC, str 4 _brand, str 4 _emplid, str 15 _lc)
public static RecId createDefaultDimensionString(container _dimensionColumnValue, container _dimensionColumnName)
{
Struct struct;
int _counterDim, _counterValue;
DimensionValue _foundValue[];
Name _foundName[];
container ledgerDimension;
DimensionDefault DimensionDefault;
str _value;
;

struct = new struct();

_counterValue = 1;
for(_counterDim = 1; _counterDim <= conLen(_dimensionColumnValue); _counterDim++)
{
_value = conPeek(_dimensionColumnValue, _counterDim);
if(_value == ” )
{
_counterValue = _counterValue -1 ;
}
if(_value != ”)
{
_foundValue[_counterValue] = conPeek(_dimensionColumnValue, _counterValue);
_foundName[_counterValue] = conPeek(_dimensionColumnName, _counterValue);
struct.add(_foundName[_counterValue], _foundValue[_counterValue]);

ledgerDimension += struct.fields();
ledgerDimension += struct.fieldName(_counterValue);
ledgerDimension += struct.valueIndex(_counterValue);
_counterValue ++;
}
}

DimensionDefault = Dimensions::getDimensionAttributeValueSetId(ledgerDimension);
return DimensionDefault;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s