Remove a Financial Dimension Value

Here is a job that can help you remove or blank out a financial dimension.

Note the Dimensions before executing this job



static void sgxRemoveWorkerDimension(Args _args)



     * We will Remove a worker dimension in this example


    CustTable                       custTable = CustTable::find(‘CUS-00004’); //Customer Record containing Financial Dimension

    DimensionSHA1Hash               hash; //To store the calculated hash for DimensionAttributeValueSet

    DimensionAttribute              dimAttr; // Contains the financial dimensions records

    DimensionAttributeValue         dimAttrValue; // Contains used financial dimension values

    DimensionAttributeValueSet      dimAttrValueSet; //Contains default dimension records

    DimensionAttributeValueSetItem  dimAttrValueSetItem; //Contains individual records for default dimensions

    DimensionAttributeSetItem       dimAttrSetItem; // Contains the number of dimensions active for a account structure ledger


    HashKey     valueKeyHashArray[]; //To store the has key of dimension in question

    Map         dimAttrRecId, dimAttrStr; //To store the dimension attribute recid and dimension attribute value display value

    Set         dimAttrValueRecId;

    SetEnumerator   setEnum;

    int dimAttrCount, i;



    //Initialize the map to store the backing entity types

    dimAttrRecId = new Map(Types::Int64, Types::Integer);

    dimAttrValueRecId = new Set(Types::Int64);

    dimAttrStr = new Map(Types::Int64, Types::String);


    //Find all the active dimensions for current ledger except main account and store there

    //backing entity type in the map

    while select RecId from dimAttr

            order by Name

            where dimAttr.Type != DimensionAttributeType::MainAccount

            join RecId from dimAttrSetItem

                where dimAttrSetItem.DimensionAttribute == dimAttr.RecId &&

                      dimAttrSetItem.DimensionAttributeSet == DimensionCache::getDimensionAttributeSetForLedger()



        dimAttrRecId.insert(dimAttr.RecId, dimAttrCount);



    //initialize hash key array to null

    for (i = 1; i<= dimAttrCount; i++)

        valueKeyHashArray[i] = emptyGuid();


    //Get individual dimension attribute records and display values except worker dimension

    //Store them in sets

    while select DisplayValue, DimensionAttributeValue from dimAttrValueSetItem

            where dimAttrValueSetItem.DimensionAttributeValueSet == custTable.DefaultDimension

            join DimensionAttribute, HashKey from dimAttrValue

                where dimAttrValue.RecId == dimAttrValueSetItem.DimensionAttributeValue

                join RecId from dimAttr

                    where dimAttr.RecId == dimAttrValue.DimensionAttribute

                       && dimAttr.BackingEntityType != tableNum(DimAttributeHcmWorker) //As we ignore worker dimension, its hash key remains blank



        dimAttrStr.insert(dimAttrValueSetItem.DimensionAttributeValue, dimAttrValueSetItem.DisplayValue);

        valueKeyHashArray[dimAttrRecId.lookup(dimAttrValue.DimensionAttribute)] = dimAttrValue.HashKey;



    //Calculate the hash for the current values

    hash = DimensionAttributeValueSetStorage::getHashFromArray(valueKeyHashArray, dimAttrCount);


    //Null hash indicates no values exist, which may occur if the user entered an invalid value for one dimension attribute

    if (hash == conNull())


        throw error(“Wrong value for Dimensions”);



    // Search for existing value set

    dimAttrValueSet = DimensionAttributeValueSet::findByHash(hash);


    // This value set does not exist, so it must be persisted

    if (!dimAttrValueSet)



        // Insert the value set with appropriate hash

        dimAttrValueSet.Hash = hash;



        // Insert only specified set items use this

        setEnum = dimAttrValueRecId.getEnumerator();


        while (setEnum.moveNext())



            dimAttrValueSetItem.DimensionAttributeValueSet = dimAttrValueSet.RecId;

            dimAttrValueSetItem.DimensionAttributeValue = setEnum.current();

            dimAttrValueSetItem.DisplayValue = dimAttrStr.lookup(setEnum.current());








    custTable.DefaultDimension = dimAttrValueSet.RecId;





Result After Job Run


4 thoughts on “Remove a Financial Dimension Value

Leave a Reply

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

You are commenting using your 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