Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

SSRS Report not fetching all records for given date range

Posted on by 1,877

Hello Experts,

I developed custom SSRS report but report not working properly.

Insert method as given below:

private void insertintotmp()
{

    InventDim   inventDim;
    InventTable inventTable;
    InventTransOrigin inventTransOrigin;
    SalesLine       salesLine;
    InventTableModule inventTableModule;
    ;
 
   inventTable =InventTable::find(inventTrans.ItemId);

  select firstOnly inventDim where inventDim.inventDimId == inventTrans.inventDimId;
    select firstOnly inventTransOrigin where inventTransOrigin.ItemId == inventTable.ItemId && inventTransOrigin.RecId == inventTrans.InventTransOrigin;
  
    {
    weekTmp.ItemId = inventTrans.ItemId;
    weekTmp.PQty    =   inventTrans.Qty;
    weekTmp.PAmount =   inventTrans.CostAmountPhysical;
    weekTmp.FAmount =   inventTrans.CostAmountPosted;
    weekTmp.FQty    =   inventTrans.Qty;
    weekTmp.Location = InventDim::find(inventTrans.inventDimId).InventLocationId;
    weekTmp.Site     = inventDim.InventSiteId;

       select firstOnly inventTrans where inventTrans.DateFinancial >= prevMth(today());
              
     {
 
        weekTmp.PQtypre    =   inventTrans.Qty;
    weekTmp.PAmountPre =   inventTrans.CostAmountPhysical;
    weekTmp.FAmountPre =   inventTrans.CostAmountPosted;
    weekTmp.FQtyPre    =   inventTrans.Qty;
 
    }
    weekTmp.PAmountVar = ((weekTmp.PAmount) - (weekTmp.PAmountPre));
    weekTmp.PQtyVar =   (weekTmp.PQty   -   weekTmp.PQtyVar);
    weekTmp.FQtyVar = (weekTmp.FQty  -   weekTmp.FQtyVar);
    weekTmp.FAmountVar  =   (weekTmp.FAmount    -   weekTmp.FAmountPre);
   
    weekTmp.insert();

}
}

Generated report:

7418.21.jpg

While I check in InventTransItem form for same date range there are lot of transaction as given while in my report any showing first record.

211.jpg

*This post is locked for comments

  • Verified answer
    faiz7049 Profile Picture
    faiz7049 1,877 on at
    RE: SSRS Report not fetching all records for given date range

    Thnaks all, I change some come now it works

    private void insertintotmp()

    {

       InventDim   inventDim;

       InventTable inventTable;

       InventTransOrigin inventTransOrigin;

       SalesLine       salesLine;

       InventTableModule inventTableModule;

       ;

      inventTable =InventTable::find(inventTrans.ItemId);

       {

     select firstOnly inventDim where inventDim.inventDimId == inventTrans.inventDimId;

       select firstOnly inventTransOrigin where inventTransOrigin.ItemId == inventTrans.ItemId && inventTransOrigin.RecId == inventTrans.InventTransOrigin;

       {

       weekTmp.ItemId = inventTransOrigin.ItemId;

       weekTmp.PQty    =   inventTrans.Qty;

       weekTmp.PAmount =   inventTrans.CostAmountPhysical;

       weekTmp.FAmount =   inventTrans.CostAmountPosted;

       weekTmp.FQty    =   inventTrans.Qty;

       weekTmp.Location = InventDim::find(inventTrans.inventDimId).InventLocationId;

       weekTmp.Site     = inventDim.InventSiteId;

       weekTmp.PQtypre    =   inventTrans.Qty;

       weekTmp.PAmountPre =   inventTrans.CostAmountPhysical;

       weekTmp.FAmountPre =   inventTrans.CostAmountPosted;

       weekTmp.FQtyPre    =   inventTrans.Qty;

       weekTmp.PAmountVar = ((weekTmp.PAmount) - (weekTmp.PAmountPre));

       weekTmp.PQtyVar =   (weekTmp.PQty   -   weekTmp.PQtyVar);

       weekTmp.FQtyVar = (weekTmp.FQty  -   weekTmp.FQtyVar);

       weekTmp.FAmountVar  =   (weekTmp.FAmount    -   weekTmp.FAmountPre);

       }

       weekTmp.insert();

    }

    }

  • Suggested answer
    Sheikh Sohail Profile Picture
    Sheikh Sohail 6,125 on at
    RE: SSRS Report not fetching all records for given date range

    Faiz,

    Job getting hang because there is enough data in invent trans table, Will recommend you to write your complete query in SQL and optimize 1st, implement indexes where required..

    I am not aware about your business requirement, So i will not comment anything on syntax of query  but right now your issue is FirstOnly Keyword...

  • faiz7049 Profile Picture
    faiz7049 1,877 on at
    RE: SSRS Report not fetching all records for given date range

    Sohail, if I removed firstOnly I will not get even any single record and SSRS report/job will be hang.

  • Suggested answer
    Sheikh Sohail Profile Picture
    Sheikh Sohail 6,125 on at
    RE: SSRS Report not fetching all records for given date range

    Have check the firstOnly attribute in your query? kindly remove that and verify again

    select firstOnly inventDim where inventDim.inventDimId == inventTrans.inventDimId;
        select firstOnly inventTransOrigin where inventTransOrigin.ItemId == inventTable.ItemId && inventTransOrigin.RecId == inventTrans.InventTransOrigin;

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans