Month: December 2014

Creating Customer/Vendor Ledger Dimension

/// <summary>
/// To get the Ledger Dimension Value [RecId] for all listed items in LedgerJournalACType
/// </summary>
/// <param name=”_CustVendAccountId”>
/// Must provide the CustID or VendID
/// </param>
/// <param name=”_accountType”>
/// Must define the Ledger Journal Account Type
/// </param>
/// <returns>
/// Record ID
/// </returns>
/// <remarks>
///
/// </remarks>

public static LedgerDimensionAccount getDynamicLedgerDimension(str _CustVendAccountId, LedgerJournalACType _accountType)
{
LedgerDimensionAccount _ledgerDim;

_ledgerDim = DimensionStorage::getDynamicAccount(_CustVendAccountId, _accountType);

return _ledgerDim;
}

Creating Dimension Attribute Value Set ID

//Code written by Ahmed Alam on 19th Dec, 2012
//ReasonCode: To save the dimension value from container variable and return the RecId
private static recId getDimensionAttributeValueSetId(container _dimensionValue, dataAreaId _dataAreaId = curext())
{
recId dimensionId;
DimensionAttributeValueSetStorage storage;
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimensionAttributeValue;
int attributeCount, attributeIndex;
str attributeName, attributeValue;
int containerElementIndex, counter;

changecompany(_dataAreaId)
{
containerElementIndex = 1;

storage = new DimensionAttributeValueSetStorage();
for(Counter = 1; counter <= conLen(_dimensionValue); counter+= 3)
{
// Get attribute count
attributeCount = conPeek(_dimensionValue, containerElementIndex);
containerElementIndex++;

// Get attribute name
attributeName = conPeek(_dimensionValue, containerElementIndex);
containerElementIndex++;

// Validate the Financial Dimenion that was passed in.
dimensionAttribute = AxdDimensionUtil::validateFinancialDimension(attributeName);

// Get attribute value
attributeValue = conPeek(_dimensionValue, containerElementIndex);
containerElementIndex++;

// Validate the Financial Dimenion Value that was passed in.
dimensionAttributeValue = AxdDimensionUtil::validateFinancialDimensionValue(dimensionAttribute, attributeValue);

// Add attribute
storage.addItem(dimensionAttributeValue);
}
dimensionId = storage.save();
}

return dimensionId;
}

Creating Default Dimension

//Code added by Ahmed Alam on 6th Oct, 2013
//ReasonCode: User can get the specific dimension value on the basis of provided Financial Dimension
public static RecId createDefaultDimension(container defaultDim, container dimValue)
{
container ledgerDimension;
DimensionDefault DimensionDefault;
int _counter;
DimensionValue _foundValue[];
Name _foundName[];
Struct struct;
;

struct = new Struct();
for(_counter = 1; _counter <= conLen(defaultDim); _counter++)
{
_foundValue[_counter] = conPeek(defaultDim, _counter);
_foundName[_counter] = conPeek(dimValue, _counter);
struct.add(_foundName[_counter], _foundValue[_counter]);

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

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