Clear the dimension set balance ledger dimension cache

The dimension set balance (DSB) rebuild and update will generate the ledger dimensions specific to the dimension set from the ledger dimensions in the GL. The dimension set ledger dimensions that are generated are cached to increase the performance of the DSB rebuild and update.

The most common use of the DSB is in the trial balance list page and report. If you have problems with either of these and performing a DSB rebuild does not resolve the problem, clearing the dimension set ledger dimension cache before performing another DSB rebuild for that dimension set is a logical next step.

Use the following job (also attached) to clear the dimension set ledger dimension cache for the specified dimension set.

Don't forget to rebuild the DSB for the dimension set after running the job.

 

static void DimSet_ClearLedDimCache(Args _args)
{
    DimensionHierarchy dh;
    DimensionFocusLedgerDimensionReference dimSetLedDimRef;
    boolean doSave;
    Name dimSetName;

    // enter the dimension set name
    dimSetName = '';

    // change to true to commit the changes
    doSave = false;

    if (strLen(dimSetName) == 0)
    {
        throw error('Dimension set name not specified.');
    }

    dh = DimensionHierarchy::findByTypeAndName(DimensionHierarchyType::Focus, dimSetName);
    if (dh == null)
    {
        throw error(strFmt('Dimension set %1 does not exist.', dimSetName));
    }

    if (dh.FocusState == DimensionFocusBalanceInitializationState::NotInitialized)
    {
        info(strFmt('The balances for dimension set %1 are not initialized.', dimSetName));
    }

    ttsBegin;

    delete_from dimSetLedDimRef
        where dimSetLedDimRef.FocusDimensionHierarchy == dh.RecId;

    info(strFmt('Removed: %1', dimSetLedDimRef.RowCount()));

    if (doSave)
    {
        info('comitted');

        ttsCommit;
    }
    else
    {
        info('aborted');

        ttsAbort;
    }
}

 

Job_DimSet_ClearLedDimCache_2.xpo