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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

What's wrong about data in my data provider?

(0) ShareShare
ReportReport
Posted on by 276
Recently I just read an article from  Custom SSRS REPORT IN DYNAMICS 365 F&O || AX 2012 R3 (linkedin.com)
and I want to setup a project to be my master template with clean code that I will track in the future and do work instruction for my team but I can't see a data in my table that I designed.
 
This is my step and Code:
1. I prepare my project by create Temp table to be a buffer for data and report that I need to have.
 
2. In a tmp table /MOT_C9991_Tabletmp/ I setup to be tempDB and I create field in this table to be my buffer to display in my report.
 
3. I create a class /MOT_C9991_BlankReportContract/ to support a parameter in my report.
this is a code: (No error)
[DataContractAttribute]
public class MOT_C9991_BlankReportContract
{
    str itemid;
    str dataareaid;
    [DatamemberAttribute('Item Id')]
    public str saleItemID(str _ItemID= ITEMID)
    {
        ITEMID=_ITEMID;
        return ITEMID;
    }
    [DataMemberAttribute('Data Area Id')]
    public str saleDATAAREAID(str _DATAAREAID=DATAAREAID)
    {
        DATAAREAID=_DATAAREAID;
        return DATAAREAID;
    }
}
 
4. I create a class /MOT_C9991_BlankReportDP/ to query data to buffer in my temp table that I can show in my report
this is a code:(No Error)
[SRSReportParameterAttribute(classstr(MOT_C9991_BlankReportContract))]
public class MOT_C9991_BlankReportDP extends SrsReportDataProviderPreProcess
{
    MOT_C9991_Tabletmp MOT_C9991_Tabletmp;
    [SRSReportParameterAttribute('MOT_C9991_Tabletmp')]
    public MOT_C9991_Tabletmp GetData()
    {
        MOT_C9991_Tabletmp tableTmp;
        select * from tableTmp;
        return tableTmp;
    }
    public void processreport()
    {
        MOT_C9991_Tabletmp tableTmp;
        MOT_C9991_BlankReportContract contract;
        str _DataAreaId, _ItemId;
        SalesLine saleLineTable;
        contract = this.parmDataContract();
        _DataAreaId = contract.SaleDataAreaId();  // Corrected case
        _ItemId = contract.SaleItemId();          // Corrected case
        while select salesid, ItemID, Dataareaid, Lineamount from saleLineTable
        where saleLineTable.ItemID == _ItemId && saleLineTable.DataAreaID == _DataAreaId
        {
            tableTmp.salesID = saleLineTable.salesid;
            tableTmp.itemID = saleLineTable.itemid;
            tableTmp.DataArea = saleLineTable.DataAreaId;
            tableTmp.LineA = saleLineTable.LineAmount;
            tableTmp.insert();
        }
    }
}
 
5. this step I would like to map my dataset to my data provider but when I processed I didn't see any fields.
 
 
 
what's wrong in my code can someone guide me how to do?
Thank in advance.
 
BR,

Thanakorn
I have the same question (0)
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at
    I'm not sure about the reason, but I see other serious bugs. Let me explain them, because you'll have to deal with them sooner or later.
     
    Let me re-post code of your RDP class. I also simplify it a bit and fixed incorrect letter case of variables and method names:
    [SRSReportParameterAttribute(classstr(MOT_C9991_BlankReportContract))]
    public class MOT_C9991_BlankReportDP extends SrsReportDataProviderPreProcess
    {
        MOT_C9991_Tabletmp mot_C9991_Tabletmp;
        
        [SRSReportParameterAttribute('MOT_C9991_Tabletmp')]
        public MOT_C9991_Tabletmp getData()
        {
            MOT_C9991_Tabletmp tableTmp;
            select * from tableTmp;
            return tableTmp;
        }
        
        public void processReport()
        {
            MOT_C9991_Tabletmp tableTmp;
            
            MOT_C9991_BlankReportContract contract = this.parmDataContract();
            
            SalesLine saleLineTable;
            
            while select SalesId, ItemId, DataAreaId, Lineamount from saleLineTable
                where saleLineTable.ItemID == contract.saleItemId()
                   && saleLineTable.DataAreaID == contract.saleDataAreaId()
            {
                tableTmp.salesID = saleLineTable.salesid;
                tableTmp.itemID = saleLineTable.itemid;
                tableTmp.DataArea = saleLineTable.DataAreaId;
                tableTmp.LineA = saleLineTable.LineAmount;
                tableTmp.insert();
            }
        }
    }
    Extending SRSReportDataProviderPreProcess in wrong in your case. I suggest you forget preprocessing and extend SRSReportDataProviderBase instead. If you find that preprocessing is needed, use SRSReportDataProviderPreProcessTempDB.
     
    Your RDP class will never return any data. The reason is that you're using different table buffers (variables) to insert data to and read data from. It would work for a normal table, but not a temporary table. You declare tableTmp buffer in processReport() and insert data there, but the variable cease to exist at the end of the method and the data will cease to exist too. Then you declare a new buffer on getData(), but because no record was ever inserted there, it will always be empty. You have the third buffer, mot_C9991_Tabletmp, declared in the class header, which you currently don't use for anything. This is what you should use in both processReport() and getData().
     
    Another bug is that you have a parameter for DataAreaId, but it won't work, because F&O automatically filters data by the company where the query is executed. If you really want to get data from another company, you need to either use a cross-company query or use changeCompany block.
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at
    By the way, what does your last screenshot show select * from ven... when you wanted select * from MOT_C9991_Tabletmp?
  • Chomchanok Profile Picture
    276 on at
     
    Dear Martin,
     
    Thank you  for your comment.
    on this "By the way, what does your last screenshot show select * from ven... when you wanted select * from MOT_C9991_Tabletmp?"
    I try to test with sql command to make sure that when I use this command I can access data that present in my reports because I have no idea to fixed in this problem.
     
     
    when I try to follow your comment and guideline. It's sound like this.
     
     
     
  • Suggested answer
    GirishS Profile Picture
    27,827 Moderator on at
    Hi ChomChanok,
     
    I think in the DP class you have written a parm method for temp table which is wrong, I guess.
    Attribute should be "SRSReportDataSetAttribute(tableStr(MOT_C9991_Tabletmp)).
    You have mentioned "SRSReportParameterAttribute" which is wrong.
    Change that and do a build of your project then select DP class from the SSRS report.
     
    Thanks,
    Girish S.
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at
    Also, the name there is MOT_C9991_Tabletmp, not tabletmp that you're trying to use in the report dataset.
  • Chomchanok Profile Picture
    276 on at
    Dear All, 
     
    Now I review all of my code that i have a focus only 2 Classes.
     
    the first one is "P_MOT_C9991_BlankReportContract" (this is my parameter Class)
     
     
    and the second one is "P_MOT_C9991_BlankReportDP" (This is my DataProvider Class)
     
    After I Build and Run everything sound run smoothly
     
    But Value in my parameter are not deliver to this page. Can you guide me what's wrong?
     
     
     
    This is my pure code
    ////////////////////////////////////////////////////////////////////////////////////////////////////////
    [DataContractAttribute]
    public final class P_MOT_C9991_BlankReportContract
    {
        VendAccount vendaccount;
        str temp;
        [DatamemberAttribute('Vend Account')]
        public vendaccount vendaccount(vendaccount _vendaccount= vendaccount)
        {
            temp=_vendaccount;
            return temp;
        }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////
    [SRSReportParameterAttribute(classStr(P_MOT_C9991_BlankReportContract))]
    [SrsReportQueryAttribute(queryStr(MOTVendReport))]
    public final class P_MOT_C9991_BlankReportDP extends SRSReportDataProviderBase
    {
        MOT_C9991_Tabletmp temReport; 
        [SRSReportDatasetAttribute(tableStr(MOT_C9991_Tabletmp))]
        MOT_C9991_Tabletmp getMOT_C9991_Tabletmp()
        {
            return temReport;
        }
        void processReport()
        {
            QueryRun qr;
            VendTable vtable;
            P_MOT_C9991_BlankReportContract VendAccountID;
            VendTrans vtrans;
            str temp;
            VendAccountID = this.parmDataContract() as P_MOT_C9991_BlankReportContract;
            temp = VendAccountID.vendaccount();
            qr = new QueryRun(this.parmQuery());
            qr.query().dataSourceName(queryStr(VendTable)).addRange(fieldNum(VendTable, AccountNum)).value(queryValue('V110001'));
            while (qr.next())
            {
                vtable = qr.get(tableNum(VendTable));
                temReport.VendAccount = vtable.AccountNum;
                temReport.Name = vtable.Name();
                while select sum(AmountMST) from vtrans
                where vtrans.AccountNum == vtable.AccountNum
                {
                    temReport.Amount = vtrans.AmountMST;
                }
                temReport.insert();
            }
        }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////
  • GirishS Profile Picture
    27,827 Moderator on at
    On the SSRS report parameter can you check whether the parameter is available. If available, try to restore the dataset and redeploy the report.
    It's mainly depending on the DataContractAttribute and DataMemberAttribute on the contract and DP class.
     
    Thanks,
    Girish S.
  • Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at
    I also think that F&O in some cases checks only methods starting with "parm", although I'm not sure whether it's the case of reports.
  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    Can you change the parm method like below.
     
    [DataContractAttribute]
    public final class P_MOT_C9991_BlankReportContract
    {
        VendAccount vendaccount;
        str temp;
        [DatamemberAttribute('Vend Account')]
        public VendAccount vendaccount(VendAccount _vendaccount= vendaccount)
        {
            vendaccount=_vendaccount;
            return vendaccount;
        }
    }
     
    After changing then build sync and then when debugging check which value is coming in the return. Put breakpoint on this method signature.
  • Baxafer Profile Picture
    9 on at

    Your data contract class MOT_C9991_BlankReportContract seems well-defined. Ensure that the property names in the data contract match the fields in your temporary table (MOT_C9991_Tabletmp).

    In your data provider class MOT_C9991_BlankReportDP, you've defined the GetData method to return MOT_C9991_Tabletmp. This is good, but it seems like you're missing the instantiation of the MOT_C9991_Tabletmp object. Modify your GetData method as follows:


    [SRSReportParameterAttribute(classstr(MOT_C9991_BlankReportContract))]
    public class MOT_C9991_BlankReportDP extends SrsReportDataProviderPreProcess
    {
        MOT_C9991_Tabletmp MOT_C9991_Tabletmp;
        [SRSReportParameterAttribute('MOT_C9991_Tabletmp')]
        public MOT_C9991_Tabletmp GetData()
        {
            MOT_C9991_Tabletmp = new MOT_C9991_Tabletmp(); // Instantiate the object
            // Perform any necessary data enrichment using the best data enrichment tools
            // For example:
            // MOT_C9991_Tabletmp = EnrichData(MOT_C9991_Tabletmp);
            select * from tableTmp;
            return tableTmp;
        }
        // ... Rest of your code
    }

    Make sure to replace EnrichData with the actual method or logic you use to enrich the data. Utilizing the best data enrichment tools at this point can enhance the quality and completeness of your data before returning it from the GetDatamethod.

     

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans