Aug 25, 2016

Create custom dimension and Value ledger (커스텀 디멘션 생성 및 컴퍼니 정보 생성)

static void createCustomDimension(str _Value, str _Description, str DimensionAttributeName)
{
    DimensionAttribute                  _DimensionAttribute;
    DimensionAttributeValue             _DimensionAttributeValue;
    DimensionAttributeDirCategory       _DimensionAttributeDirCategory;
    DimensionFinancialTag               _DimensionFinancialTag;
    DimensionAttrValueLedgerOverride    _DimensionAttrValueLedgerOverride;
    RecId                               _DirCategory;
    ;
    try
    {
        ttsBegin;          
        _DimensionAttribute = dimensionAttribute::findByName(DimensionAttributeName);
       
        if (_DimensionAttribute.Type == DimensionAttributeType::CustomList)
        {
            select firstonly DirCategory from _DimensionAttributeDirCategory where _DimensionAttributeDirCategory.DimensionAttribute == _DimensionAttribute.RecId;
             _DirCategory = _DimensionAttributeDirCategory.DirCategory;
           
            if (_DirCategory)
            {
                _DimensionFinancialTag.clear();
                _DimensionFinancialTag.Value = _Value;
                _DimensionFinancialTag.Description = _Description;
                _DimensionFinancialTag.FinancialTagCategory = _DirCategory;
                _DimensionFinancialTag.insert();
                if (_DimensionFinancialTag)
                {
                    _DimensionAttributeValue.clear();
                    _DimensionAttributeValue.DimensionAttribute = _DimensionAttribute.RecId;
                    _DimensionAttributeValue.EntityInstance = _DimensionFinancialTag.RecId;
                    _DimensionAttributeValue.insert();     
                }
       
                if (_DimensionAttributeValue)
                {
                    _DimensionAttrValueLedgerOverride.clear();
                    _DimensionAttrValueLedgerOverride.DimensionAttributeValue = _DimensionAttributeValue.RecId;
                    _DimensionAttrValueLedgerOverride.Ledger = Ledger::current();
                    _DimensionAttrValueLedgerOverride.insert();
                }
            }
        }
        ttsCommit;
    }
    catch
    {
        ttsAbort;  
    }
}

No comments:

Post a Comment