Get combination method:
/// <summary>
/// for getting dimension id
/// </summary>
/// <param name="_dataRecord">
/// 2009 data record
/// </param>
/// <returns>
/// returns financial dimension
/// </returns>
public DimensionDefault findDefaultDimId(AxeDataRecord _dataRecord)
{
DimensionAttributeValue dimCostcenterVal,dimDepartmentVal,dimInternalOrderVal;
DimensionAttribute dimAttrCostcenter,dimAttrDepartment,dimAttrInternalOrder;
DimensionAttributeValueSetStorage davss;
boolean isValidDimension = true;
DimensionDefault DefaultDimension;
OMOperatingUnitNumber omDepatmentvalue,omCostcentervalue;
DimensionValue omInternalOrdervalue;
MSDimensions MSDimensions;// checking the Dimension2_ value is internal order or costcenter
NoYes isinternalOrder;
davss = DimensionAttributeValueSetStorage::find(DefaultDimension);
dimAttrCostcenter = DimensionAttribute::findByName('CostCenter');
dimAttrDepartment = DimensionAttribute::findByName('Department');
dimAttrInternalOrder = DimensionAttribute::findByName('InternalOrder');
select firstonly Num,mprInternal,Description,RecId from MSDimensions
where MSDimensions.Num == _dataRecord.value('Dimension2_');
isinternalOrder = MSDimensions.mprInternal;
if(_dataRecord.value('Dimension2_'))
{
if(isinternalOrder == NoYes::Yes)
{
omInternalOrdervalue = this.findorcreateInternalOrder(_dataRecord.value('Dimension2_'),MSDimensions.Description);
dimInternalOrderVal = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttrInternalOrder, omInternalOrdervalue, false , true);
}
else
{
omCostcentervalue = this.findorcreateCostcenter(_dataRecord.value('Dimension2_'));
dimCostcenterVal = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttrCostcenter , omCostcentervalue , false , true);
}
}
if(_dataRecord.value('Dimension'))
{
omDepatmentvalue = this.findorcreatedepartment(_dataRecord.value('Dimension'));
dimDepartmentVal = DimensionAttributeValue::findByDimensionAttributeAndValueNoError(dimAttrDepartment , omDepatmentvalue , false , true);
}
if(dimInternalOrderVal )
{
davss.addItem(dimInternalOrderVal);
}
if(dimCostcenterVal )
{
davss.addItem(dimCostcenterVal);
}
if (dimDepartmentVal)
{
davss.addItem(dimDepartmentVal);
}
if(dimCostcenterVal || dimDepartmentVal || dimInternalOrderVal)
{
DefaultDimension = davss.save();
return DefaultDimension;
}
else
return 0;
}
createorget inernal order , costcenter and department methods:
////////////////////////////////////////// to get or create internal order method \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/// <summary>
/// get the internal order value
/// </summary>
/// <param name="_DimensionValue">
/// passing internal order dimension value
/// </param>
/// <param name="_Description">
/// passing description
/// </param>
/// <returns>
/// returns internal dimesion value
/// </returns>
private DimensionValue findorcreateInternalOrder(DimensionValue _DimensionValue,Description _Description)
{
DimensionFinancialTag dimensionFinancialTag;
RefRecId dimensionAttribute = DimensionAttribute::findByName("InternalOrder").financialTagCategory();
ttsBegin;
select firstOnly dimensionFinancialTag where dimensionFinancialTag.Value == _DimensionValue
&& dimensionFinancialTag.FinancialTagCategory == dimensionAttribute;
if(!dimensionFinancialTag.RecId)
{
dimensionFinancialTag.initValue();
dimensionFinancialTag.FinancialTagCategory = dimensionAttribute;
dimensionFinancialTag.Value = _DimensionValue;
dimensionFinancialTag.Description = _Description;//_DimensionValue;
dimensionFinancialTag.insert();
}
ttsCommit;
return _DimensionValue;
}
////////////////////////////////////////// to get or create cost center method \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
private OMOperatingUnitNumber findorcreateCostcenter(OMOperatingUnitNumber _omCostcentervalue)
{
OMOperatingUnit OMOperatingUnit;
select OMOperatingUnit
where OMOperatingUnit.OMOperatingUnitNumber == _omCostcentervalue
&& OMOperatingUnit.OMOperatingUnitType == OMOperatingUnitType::OMCostCenter;
if(!OMOperatingUnit.OMOperatingUnitNumber)
{
ttsBegin;
OMOperatingUnit.OMOperatingUnitNumber = _omCostcentervalue;
OMOperatingUnit.OMOperatingUnitType = OMOperatingUnitType::OMCostCenter;//"Department";//
OMOperatingUnit.Name = _omCostcentervalue;
OMOperatingUnit.LanguageId = "en-us";
OMOperatingUnit.insert();
ttsCommit;
return OMOperatingUnit.OMOperatingUnitNumber;
}
else
{
return OMOperatingUnit.OMOperatingUnitNumber;
}
}
////////////////////////////////////////// to get or create department method \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
private OMOperatingUnitNumber findorcreatedepartment(OMOperatingUnitNumber _omDepatmentvalue)
{
OMOperatingUnit OMOperatingUnit;
select OMOperatingUnit
where OMOperatingUnit.OMOperatingUnitNumber == _omDepatmentvalue
&& OMOperatingUnit.OMOperatingUnitType == OMOperatingUnitType::OMDepartment;
if(!OMOperatingUnit.OMOperatingUnitNumber)
{
ttsBegin;
OMOperatingUnit.OMOperatingUnitNumber = _omDepatmentvalue;
OMOperatingUnit.OMOperatingUnitType = OMOperatingUnitType::OMDepartment;//"Department";//
OMOperatingUnit.Name = _omDepatmentvalue;
OMOperatingUnit.LanguageId = "en-us";
OMOperatingUnit.insert();
ttsCommit;
return OMOperatingUnit.OMOperatingUnitNumber;
}
else
{
return OMOperatingUnit.OMOperatingUnitNumber;
}
}