Quantcast
Channel: AX Developer Forum
Viewing all articles
Browse latest Browse all 9880

CacheLookup while loop delete

$
0
0

Hello,

Am having trouble with a while loop on a table buffer that uses caching.  Essentially, we used the Copy Item Prices function in AX2012 to copy standard costs from a legacy costing version to our new version for 2014.

This copied over all prices however, so if a product had many activations in a given costing version, all were brought over.  We would like to only activate the latest price per product.  

A product may have more than one valid record for Product Master configurations ( we use Revisions A, B, C, etc. ).  So item #001 may have a cost for A, B, C.  If "C" had 2 prices in legacy costing version, we want to delete the one with the oldest date.

Unfortunately, with my job, if we have two "C" prices, they both are deleted...it seems the cache is not updated upon delete?

Here is my job:

    InventItemPriceSim  pendingPricesBase,pendingPricesCompare;

 

    ttsBegin;

    pendingPricesBase.disableCache(true);

    while select pendingPricesBase

        order by pendingPricesBase.FromDate desc

        where pendingPricesBase.VersionId == '2013'

    {

        ttsBegin;

        pendingPricesCompare.disableCache(true);

        delete_from pendingPricesCompare

            where pendingPricesCompare.VersionId == pendingPricesBase.VersionId

            && pendingPricesCompare.ItemId == pendingPricesBase.ItemId

            && pendingPricesCompare.InventDimId == pendingPricesBase.InventDimId

            && pendingPricesCompare.RecId != pendingPricesBase.RecId;

        ttsCommit;

 

    }

    ttsCommit;

    info('done');


Viewing all articles
Browse latest Browse all 9880

Trending Articles