(For more resources related to this topic, see here.)
The Report data provider class
A Report data provider class is commonly known as RDP. RDP is the data source type which is available when we add a new dataset to the report in Visual Studio. RDP is a class which resides inside AX and executes the business logic, processes the data, and returns a dataset which is rendered in the report. A Report data provider class should be ideally used in the following cases:
- We cannot directly use a query to access the data from the database
- The data has to prepare on the basis of business logic
To define a Report data provider class, we use the following syntax:
Sample RDP
The Report contract class
Report contracts in AX 2012 are used for defining parameters to the SSRS report. We can define any number of parameters using X++ statements of any data type, which can be passed on to the RDP class. And then, we can use the same contracts to query data from the database engine which will decrease an overhead on execution of a query in SQL.
To define a Report contract class we use the following syntax:
Report Contract
Walkthrough – Creating an Auto Design report using the RDP class
Scenario
Matt, a Sales manager, needs a report to analyze total sales for customers.
This walkthrough illustrates the following tasks:
- Creating a Report data provider class
- Creating a Report Model project
- Creating a Table report using Auto Design
- Saving to AOT, deploying, and running the report
Prerequisites
To learn and implement the following walkthrough, you must have:
- Microsoft Dynamics AX 2012 with sample data
- Microsoft Visual Studio 2010 with Microsoft Dynamics AX reporting extension
- Microsoft Dynamics AX 2012 SQL Server Reporting Services
Creating a Report data provider class
- Open Microsoft Dynamics AX 2012 from the Start menu.
- Open the development workspace. You can do it in either of the following ways:
- Press Ctrl + D to open AOT in Development Workspace.
- Press Ctrl + Shift + P to open Projects in Development Workspace.
- Press Alt + W to open windows and select New Development Workspace.
- Press Ctrl + Shift + W to open New Development Workspace.
- Navigate to the AOT | Classes node.
- Right-click on the Classes node, and click on New | Class.
- Double-click on the class created and change the class declaration, as shown in the following code:
class SrsRDPSample extends SRSReportDataProviderBase{ CustTransTotalSales custTransTotalSales; }
- Right-click on the SrsRDPSample class and select New | Method.
- Modify the method, as shown in the following code:
[SRSReportDataSetAttribute('CustSales')] public CustTransTotalSales getTmpCustTable(){ return custTransTotalSales; }
- Right-click on the SrsRDPSample class and navigate to Override method | processReport.
- Modify the method, as shown in the following code:
public void processReport(){ select * from custTransTotalSales; }
Creating a Report Model project
- Start Visual Studio and press Ctrl + N to create a new project.
- Select Microsoft Dynamics AX under Installed Templates from the left pane, and select Report Model.
- Provide a name for the project as CustomerTotalSales_Autodesign.
New project
Creating a Table report using Auto Design
- Right-click on Solution, select Report under the Add submenu. Select the report and rename it to CustTotalSales_Autodesign.
- Right-click on Datasets and click on Add dataset.
- Modify the following properties for the newly added dataset:
- Data source to Microsoft Dynamics AX.
- Data source type to Query.
- Default Layout to Matrix.
- Name to CustTotalSalesDS.
- Switch to the Query property, and click on the button besides the name of the entity button to open the Query dialog.
- Select SrsRDPSample from the list and click on the Next button.
New dataset: CustTotalSalesDS
- Select all fields from CustSales.
- Drag-and-drop CustTotalSalesDS to the Design section of the report. This will create a new Auto Design named as AutoDesign1.
- Select AutoDesign1, go to Properties, and set the following properties:
- LayoutTemplate to ReportLayoutStyleTemplate
- Title to Customer sales.
- Select CustTotalSalesDS under AutoDesign1, and set the following properties:
- StyleTemplate to TableStyleAlternatingRowsTemplate.
- Title to Customer sales.
- Drag the AccountNum field from the Data node to Groupings.
- Drag the TransDate field to the Sorting node.
- Under the Data node, select only the TransDate, AmountMST, CurrencyCode, DocumentDate, DueDate, LastSettleDate, PaymMode, and TransType1 fields.
Report design
Saving to AOT, deploying, and running the report
Save the report to AOT and Deploy to the Report Server, and then run the report.
Summary
In this article we covered Report data provider (RDP) class and Report contract class. We also learned how to implement these classes for our reporting needs. We learned creating an Auto Design report using the RDP class by following the step-by-step walkthrough.
Resources for Article:
Further resources on this subject:
- Testing Workflows for Microsoft Dynamics AX 2009 Administration [Article]
- Types of services in Microsoft Dynamics AX 2012 [Article]
- Installing the Dynamics AX Base Server Components for Microsoft [Article]