web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Sales Order CreateLine() Optimization

(0) ShareShare
ReportReport
Posted on by 928

Dear all,

I am using SalesTable's createline() method but it is taking too much time (around 10 mins for adding 600 lines). Is there any way to optimize it?

I am adding sales line from CSV file

Here is my method call

objSalesLine.createLine(true,true , true, true, true, true);

trace parser result.

1050.Untitled.jpg

Thanks,

Khurshid Wali

*This post is locked for comments

I have the same question (0)
  • Verified answer
    axk Profile Picture
    925 on at
    RE: Sales Order CreateLine() Optimization

    When creating sales line, a lot of other stuff is happening with trade agreements, inventory transactions, credit limit etc.. You can bypass some business logic by passing arguments, for example:

    - don't look for a price in trade agreements,

    - don't calc invent quantity if you can set it,

    - don't init from sales order if you know all data...

  • Khurshid Wali Profile Picture
    928 on at
    RE: Sales Order CreateLine() Optimization

    Thank you @a-kow for replying.

    Check this.

    1643.2.JPG

    It is not price or quantity that is taking time.. it is insert method which takes most of the time.

  • axk Profile Picture
    925 on at
    RE: Sales Order CreateLine() Optimization

    Ah, okay. Do you have any customizations at SalesTable & SalesLine?

    What can we find if we expand SalesLine.insert()?

  • Khurshid Wali Profile Picture
    928 on at
    RE: Sales Order CreateLine() Optimization

    When I go deep into salesline.insert().

    3264.4.JPG

    Here the load is divided into two.

    Here is the first one.

    3264.4.JPG

    Here is the Second one.

    7776.5.JPG

  • Verified answer
    Martin Dráb Profile Picture
    236,499 Most Valuable Professional on at
    RE: Sales Order CreateLine() Optimization

    In both cases, the database time is to blame, therefore you should focus on the queries.

    If you run them in SQL Server Management Studio, you can see execution plans, statistics and suggested indexes.

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Sales Order CreateLine() Optimization

    If that simple SQL statement takes over one second to complete, you have to optimize something in the database. To me it looks like it's most likely not about missing indexes, but out of date indexes or statistics.

    Do you have any index maintenance plan in use? Are you updating the statistics?

    You could try to update the statistics for InventTrans and InventDim tables and see if it helps.

    And / or rebuild indexes.

  • Khurshid Wali Profile Picture
    928 on at
    RE: Sales Order CreateLine() Optimization

    a-kow tricks work out and my insertion time is cut to half.

    objSalesLine.createLine(true,true , true, true, true, false);

    Where we are skipping the time-consuming query which is not the best solution.

    Thank you @Martin Dráb, @Nikolaos Mäenpää I will work on this solution and discuss with senior developers about indexing and index maintenance plains. So that I can include the skipped query.

    My second problem is still there.

    8130.6.JPG

    What is the problem with this build in ax2012 methods?

  • Verified answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Sales Order CreateLine() Optimization

    From the screenshot we don't see what exactly takes so much time. But most likely it's a SQL statement again. The problem is not in the ax2012 methods, it seems to be in the setup / maintenance of your database.

  • Khurshid Wali Profile Picture
    928 on at
    RE: Sales Order CreateLine() Optimization
    [quote user="nmaenpaa"]

    From the screenshot we don't see what exactly takes so much time. But most likely it's a SQL statement again. The problem is not in the ax2012 methods, it seems to be in the setup / maintenance of your database.

    [/quote]

    Here is the final Method deep down the trace parser which is causing the problem.


    public void initFromPriceDisc(PriceDisc_Price _priceDisc, PriceDiscPolicyCheckPolicy _checkPolicy = null, boolean _initDateFields = true, RetailSalesOrderCalculator _retailCalculator = null) { // SalesLine_IN salesLine_IN; if (TaxParameters::checkTaxParameters_IN()) { salesLine_IN = this.salesLine_IN(); salesLine_IN.MaximumRetailPrice_IN = _priceDisc.maxRetailPrice_IN(); this.packSalesLine_IN(salesLine_IN); } // if (!this.RecId || !this.ShippingDateRequested || !this.ReceiptDateRequested) { if (!this.ShippingDateRequested) { this.ShippingDateRequested = this.salesTable().ShippingDateRequested; } if (!this.ReceiptDateRequested) { this.ReceiptDateRequested = this.salesTable().ReceiptDateRequested; } } if (_initDateFields) { SalesCalcAvailableDlvDates::initDateFields(this,_priceDisc); _priceDisc.parmPriceDate(this.priceDate()); } // Updating price after PriceDate is updated. this.SalesPurchLine::setPriceDiscPriceUnitMarkup(_priceDisc, _checkPolicy, _retailCalculator); }
  • Khurshid Wali Profile Picture
    928 on at
    RE: Sales Order CreateLine() Optimization

    Thank you Nikolaos Maenpaa.. Sorry for the unformated post..

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

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans