Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Rows are not populated in SSRS report after adding codes.

Posted on by 1,879

Hello Experts,

In RDP some piece of code are given here:

    while select salesLine
        where salesLine.ItemId == queryInventTable.ItemId &&
        salesLine.createdDateTime >= DateTimeUtil::addMonths(DateTimeUtil::utcNow(), -12)
    {
        avgAnnualSales += salesLine.QtyOrdered ;
    }

    if(avgAnnualSales > 0)
        avgAnnualSales = avgAnnualSales/12;
    else
        avgAnnualSales = 0;   
    tReOrderReportTmp.AnnualAvgSalesQty = avgAnnualSales;
 tReOrderReportTmp.MinStockQty = minStock;

 if(tReOrderReportTmp.CurrentStock > 0 && tReOrderReportTmp.AnnualAvgSalesQty > 0)
        tReOrderReportTmp.MonthCoverSales = tReOrderReportTmp.CurrentStock / tReOrderReportTmp.AnnualAvgSalesQty;
    else
        tReOrderReportTmp.MonthCoverSales = 0;
   
    tReOrderReportTmp.MinStockQty = (tReOrderReportTmp.AnnualAvgSalesQty/30) * tReOrderReportTmp.LeadTime  ;
    
    tReOrderReportTmp.insert();
Report Output
 
7723.Before.jpg
 
 
After Added some code to get data for BOMQty column and modified codes here
 

 while select salesLine
        where salesLine.ItemId == queryInventTable.ItemId &&
        salesLine.createdDateTime >= DateTimeUtil::addMonths(DateTimeUtil::utcNow(), -12)
    {
        avgAnnualSales += salesLine.QtyOrdered ;
    }

    if(avgAnnualSales > 0)
        avgAnnualSales = avgAnnualSales/12;
    else
        avgAnnualSales = 0; 
 tReOrderReportTmp.MinStockQty = minStock;  
    tReOrderReportTmp.AnnualAvgSalesQty = avgAnnualSales;

// Added Codes Start
 
  while select inventTrans
    join salesLine where inventTrans.ItemId == salesLine.ItemId && salesLine.createdDateTime >= DateTimeUtil::addMonths(DateTimeUtil::utcNow(), -12)
       join  queryInventTable where inventTrans.ItemId == queryInventTable.ItemId
       join  inventTransOrigin where inventTrans.ItemId == inventTransOrigin.ItemId && inventTrans.InventTransOrigin==inventTransOrigin.RecId && inventTransOrigin.ReferenceCategory == InventTransType::BOMLine
    {
        BOMQty1 += inventTrans.Qty;
        tReOrderReportTmp.BOMQty = BOMQty1;
    }
 
 //Added Codes End

 if(tReOrderReportTmp.CurrentStock > 0 && tReOrderReportTmp.AnnualAvgSalesQty > 0)
        tReOrderReportTmp.MonthCoverSales = tReOrderReportTmp.CurrentStock / tReOrderReportTmp.AnnualAvgSalesQty;
    else
        tReOrderReportTmp.MonthCoverSales = 0;
   
    tReOrderReportTmp.MinStockQty = (tReOrderReportTmp.AnnualAvgSalesQty/30) * tReOrderReportTmp.LeadTime  ;
    
    tReOrderReportTmp.insert();
 
Report Output
 
3513.After.jpg
 
Report showing only one record while pervious have 5 records.
 

*This post is locked for comments

  • Verified answer
    faiz7049 Profile Picture
    faiz7049 1,879 on at
    RE: Rows are not populated in SSRS report after adding codes.

    Thanks to all. Problem was not in design only it was is code logic.

    //Add Code Start

      while select inventTrans  where inventTrans.ItemId==queryInventTable.ItemId &&  inventTrans.DateFinancial >= prevYr(today())
         join  inventTransOrigin where inventTrans.ItemId == inventTransOrigin.ItemId && inventTrans.InventTransOrigin==inventTransOrigin.RecId
         && inventTransOrigin.ReferenceCategory == InventTransType::BOMLine

        {
            BOMQty1 +=inventTrans.Qty;
        }
        if (BOMQty1 < 0)
        BOMQty1 = BOMQty1/12;
        else
        BOMQty1 = 0;
     tReOrderReportTmp.BOMQty = (BOMQty1)*(-1);
    //Added Code End
    6523.123.jpg
  • Rati Sharabidze Profile Picture
    Rati Sharabidze 612 on at
    RE: Rows are not populated in SSRS report after adding codes.

    Hello,

    In addition to what Soahib said, check also the report design if there is any condition set on row visibility.

    BR

  • Sohaib Cheema Profile Picture
    Sohaib Cheema 46,610 User Group Leader on at
    RE: Rows are not populated in SSRS report after adding codes.

    Number of records depend upon the way you join the tables.

    It is hard to say which join types you want to use as it depends upon the requirement. With given information I can doubt where inventTrans.ItemId == salesLine.ItemId

    You may want to change this as following

    1) Join InventTrans to InventTransOrigin

    2) Join InventTransOrigin with SalesLine

    Please note that Relationship between the sales order line and the InventTransOrigin is also located in InventTransOriginSalesLine

  • faiz7049 Profile Picture
    faiz7049 1,879 on at
    RE: Rows are not populated in SSRS report after adding codes.

    Please help me on above 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans