Skip to main content

Notifications

Microsoft Dynamics AX forum

Auto Calculate Costing Version

Posted on by Microsoft Employee

I'm looking to automate the creation of a costing version.  I'm able to create a costing version and "Copy Last Cost" but unable to perform the "Calculation" process.  Can anyone assists?

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto Calculate Costing Version

    I'm not getting any errors.  This is what I did to achieve my task.

    //Create new costing version record

    costingVersion = null;

    costingVersion.initValue();

    costingVersion.BlockActivation = NoYesCombo::Yes;

    costingVersion.AllowPurch = NoYes::No;

    costingVersion.AllowSales = NoYes::No;

    costingVersion.BOMCostPriceModel = BOMCostPriceModel::ItemCostPrice;

    costingVersion.BOMCalcRun = NoYes::Yes;

    costingVersion.LastUpdate = today();

    costingVersion.InventSiteId = strUpr(curext());

    costingVersion.PurchCalcRun = NoYes::No;

    costingVersion.PurchPriceModel = PurchPriceModel::PurchPrice;

    costingVersion.Name = strName;

    costingVersion.VersionId = strVersionId;

    costingVersion.insert();

    //Add items to new costing version

    psd_AddtoCostVersion = new PSD_AddtoCostVersion();

    psd_AddtoCostVersion.parmCostVersion(strVersionId);

    psd_AddtoCostVersion.parmEffectivityDate(today());

    psd_AddtoCostVersion.run();

    //Calculating the costing version

    costingVersion = null;

    select firstOnly costingVersion where costingVersion.VersionId == strVersionId;

    bomCalc = BOMCalcJob::newAll(costingVersion);

    bomCalc.parmBOMCalcExplosionMode(BOMCalcExplosionMode::MultiLevel);

    bomCalc.parmCostPriceTransfer(NoYes::Yes);

    bomCalc.parmCalcDate(today());

    bomCalc.run();

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto Calculate Costing Version

    Please update if you are getting any error...

    I suggest if you can review the copied costing version if its having any difference with Costing version  which gets calculation done with out any error..

    Please verify and let us know with your findings...

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto Calculate Costing Version

    Hi Joe,

    My task was to automate the process for creating a new costing version.

    I was able to accomplish this by creating a new costing version via x++ and using a couple of classes to copy and calculate items to the new costing version.

  • Joe Tews Profile Picture
    Joe Tews 10 on at
    RE: Auto Calculate Costing Version

    Hi Derrick,

    Can you give me a little more information about what you're trying to accomplish? Are you looking for a way for AX to automatically run the Calculation for the costing version? Or are you just having troubles with running a cost calculation? Thanks!

    Joe

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Give Back to the Community this Month

Quick Links

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,807 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,135 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans