The current version of Axapta, namely Dynamics AX 2012 (the AX2012) all reporting is built on MS Sql Server Reporting Services (SSRS), the use of old technology reporting is possible, but not desirable, and create reports in AX2012-based SSRS not quite trivial . To help new developers, we decided to write a short article describing the minimum necessary steps to create a report based on the SSRS.
In addition to creating report using Visual Studio, you need to create a set of classes at AX2012 for the report. After creating a new report in Visual Studio, determine the type of data source. Data sources, mainly use two types of Query – Query AX2012 and ReportDataProvider. Using the Data Source Query does not involve any additional actions other than to the query, if you want the data set does not meet any of the existing queries. When using the type of data source ReportDataProvider everything is not so transparent, it’s about this implementation we describe below.
For the implementation of the report with the data source type ReportDataProvider, create a class inherits interface from a class SysOperationValidatable and fill out the necessary attributes for this class. Class attributes and methods, this new designs in AX2012, they are indicated before the definition of a class or method. In addition to this class to create a class of “controller” of our report, he should be the heir class SRSReportRunController.
Example for our case
1. First, we define a class for the parameters of our report with attributes (attributes are specified in the construction of “[ ]”, separated by commas), a new class to inherit the interface of the system class «SysOperationValidatable». With the class parameters and attributes of the class, you can specify the parameters of the report, and their location within the options dialog, in addition you can write methods for the parameters that return a s set of parameter values.
SysOperationGroupAttribute(“Customer”,”Настройки клиента”, “1”, FormArrangeMetod::Vertical);
Class NewReportParams implements SysOperationValidatable
2. The method described by the parameter «CustAccount»
SysOperationHelpTextAttribute("Укажите код клиента")
Public CustAccount parmCustAccount(CustAccount _custAccount = custAccount)
custAccount = _custAccount;
3. Class provider of our report:
Class NewReportDataProvider extends SrsReportDataProviderPreProcess ;
To determine the class of providers, you can also use the class SrsReportDataProviderBase. Debug class inherits from SrsReportDataProviderBase not possible, this is our recommendation to use the class SrsReportDataProviderPreProcess, because it possible to debug AX2012, except for debugging, data on the use of different classes within them to work with sets of data.
SrsReportDataProviderBase class allows you to work with temporary tables in SrsReportDataProviderPreProcess to use regular tables with the included properties CreatedBy and CreatetransactionId, as temporary. First we create a table with the included properties NewReportTableTmp CreatedBy and CreatedTransactionID.
4. Class Definition provider with attributes (attributes are specified in the construction of “[ ]”, separated by commas).
SRSReportQueryAttribute(queyStr(QFromNewReport)), // request for the data set
SRSReportParameterAttribute(classStr(NewReportParams)) // Class of report parameters
Class NewReportDataProvider extends SrsReportDataProviderPreProcess
5. The method returns a data source, you must mark the following attribute:
Public NewReportTableTmp NewRecord()
Select NewReportTableTmp where NewReportTableTmp.custAccount == ‘000022’;
6. Further close the provider method processReport (), it is used to fill we created a “temporary” table data is necessary for us, that is, in this method, we can determine the appropriate algorithm for our data sample.
public void processReport()
contract = this.parmDataContract() as NewReportParams;
q = this.parmQuery();
qr = new QueryRun(q);
while ( qr.Next() )
// We fill our table NewReportTableTmp
7. Creating a class report (previously in AX2012 in Visual Studio report was created «NewReport» in which the data source is created by our selected provider):
Class NewReportControl extends SRSReportRunController
8. The main method of this class:
Public static void main (Args _args)
Controller = new NewReportControl();
Controller.parmreportName(SsrsReportStr(NewReport, Report)); //which report call
Controller.parmShowDialog(true); // Report Parameters dialog
Controller.parmDialogCaption(“Cap dialog”); // label in the header of the dialog
Controllrt.startOperation; // run a Report
Using the above described techniques, you can create very flexible options for reporting and to use the data sets produced “on the fly.” In comparison with the standard platform to generate reports MS Dynamics AX previous versions, the design process began reporting simpler and more flexible, reducing the development of a new report, do not waste time on the development and design of the fit of the report itself.