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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

SSRS Report: The Loading Time is Too Long and Then It Shows an Error Lost Connection

(0) ShareShare
ReportReport
Posted on by 1,036

Hello awesome community! :)

I'm still a newbie in AX so please bear with me explaining haha.

I've created a report that shows the expired items.

My query is :

InventTrans > InventDim > InventBatch

So, I want to check all the transaction of the items to look for expired items that is still remaining.

The data is big so it takes a long time in Loading screen and then it gives me an error saying that "connection is lost"

But If I used a filter like for example: item number, it will work fine. So my problem is when I want to get all the data.

I used a query Object in AOT with a DP Class.

Here is my prcoessReport method code:

 qr = new QueryRun(query);

    while(qr.next()){
        invTrans    = qr.get(tableNum(InventTrans));
        InvDim      = qr.get(tableNum(InventDim));
        InvBatch    = qr.get(tableNum(InventBatch));

        if(InvBatch.expDate < today() || InvBatch.expDate - InventTable::find(invTrans.ItemId).NearExpiry < today()){
                reportLine.ItemId           = invTrans.ItemId;
                reportLine.ItemName         = invTrans.itemName();
                reportLine.Qty              = invTrans.Qty;
                reportLine.inventBatchId    = InvDim.inventBatchId;
                reportLine.InventLocationId = InvDim.InventLocationId;
                reportLine.expDate          = InvBatch.expDate;
                reportLine.insert();
        }
}

Please, if you can advice it would be appreciated :)

Maybe using a select and a while select is faster and better than using a "query object"?

NOTE*: I check if the items still remaining or not in the design. If the Sum of quantity in the batch id is "0 Zero" that means no items are remaining so I will hide the records from the table. Maybe there is a better work around? since it will fetch un-needed data.

Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Momochi Profile Picture
    1,036 on at

    Hello Mr. Crispin!

    First thank you for your time to help.

    I changed the query to a while select in the DP processReport() method instead of using a query object in AOT, here:

    while select * from invTrans join InvDim join InvBatch
                where invTrans.inventDimId == InvDim.inventDimId &&
                InvDim.inventBatchId == InvBatch.inventBatchId && 
                InvBatch.expDate < today(){
                    
                            reportLine.ItemId           = invTrans.ItemId;
                            reportLine.ItemName         = invTrans.itemName();
                            reportLine.Qty              = invTrans.Qty;
                            reportLine.inventBatchId    = InvDim.inventBatchId;
                            reportLine.InventLocationId = InvDim.InventLocationId;
                            reportLine.expDate          = InvBatch.expDate;
                            reportLine.insert();
     }

    I still got the same error unfortunately :(
    a picture of an error:

    032172.Capture.PNG

    Sorry but if there are more advices, please enlighten me.

    Thanks again!

  • udaY-ch Profile Picture
    5,133 on at

    Hi,

    Can you try using field list instead of querying all the fields from the table likely

    While select itemId from inventTrans and you use find method to get the itemname, likewise use field list in all the buffers.

    Best,

    Uday.

  • Momochi Profile Picture
    1,036 on at

    Thank you Udhaya for time to help!

    I tried it and still got the same error :(

    Thanks again!

  • Momochi Profile Picture
    1,036 on at

    Is it possible to do that with the same requirements?

    They asked me to show the warehouse id and quantity.

    Is it possible to get the same information with avoiding the InventTrans?

    Thanks!

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    I suggest you forget reports for a moment and focus on the query. How long does it take to execute it? If too long, there is probably no point in using it in a report, because that won't make it any better. You should optimize the query first.

    And I would start by reviewing your requirements. If you want only a warehouse ID and quantity, there is no point in returning all the other fields. Also, don't you actually want to summarize quantity (grouped by warehouse ID) instead of returning every individual transaction.

    There is also a way how you can execute long-running queries without running into the timeout (by using pre-processing), but in this case, it seems that you really should improve your query instead.

    By the way, a select statement and a Query object producing the same SQL code will take the same time to execute, so there is no point in changing that.

  • Prasad.V Profile Picture
    185 on at

    Momochi,

    Try to use SrsReportDataProviderPreProcess class if you are not using it already and change the query to use bulk insert statement instead of looping through the result set.

  • Momochi Profile Picture
    1,036 on at

    Thanks Mr. Martin for your time to help!

    It does take too long like 10 minutes and then a time out occurs.

    My requirements are to show:

    Item Id, Item Name, Quantity, Batch Id, Warehouse Id, Expiration Date.

    And yes, you are correct it should be grouped by the warehouse with summing the quantity for each warehouse.

    Please, suggest me to how I should modify the query?

    Thanks again!

  • Suggested answer
    Sheikh Sohail Profile Picture
    6,125 on at

    Hi Momochi,

    As we all knows that invent trans contain huge amount of transaction so it will take time. what I can suggest you for improvement.

    Improve your query performance by selecting only required column instead of selection of all.

    Create staging table and keep cook data(Already prepared data) in staging table using Batch Job and run your report from staging table with minimum column.

    Use Record inserted list instead of direct insertions.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans