Académique Documents
Professionnel Documents
Culture Documents
This document is provided "as-is". Information and views expressed in this document, including URL and other Internet Web site
references, may change without notice. This document does not provide you with any legal rights to any intellectual property in
any Microsoft product or product name. You may copy and use this document for your internal, reference purposes. You may
modify this document for your internal, reference purposes. 2015 Microsoft. All rights reserved. Terms of Use
Table of Contents
RDP Classes
Using Report Data Provider Classes to Access Report Data
RDP Classes
Using Report Data Provider Classes to Access
Report Data [AX 2012]
Updated: November 15, 2011
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
This section provides an overview of reports bound to a report data provider class. A report data provider (RDP) class is an X++
class that is used to access and process data for a report. The following topics describe how to use a report data provider for a
report.
In This Section
How to: Use a Report Data Provider Class in a Report
How to: Group and Order Report Parameters by Using a Data Contract Class
How to: Configure the Debugger to Debug a Report Data Provider Class
How to: Define a Nested Data Contract
You cannot query directly for the data you want to render on a report.
For more information, see Guidance for Choosing the Data Source Type.
A report parameter provides a way to choose report data, connect related reports together, and vary the report presentation. It
is used when generating the report data set. The parameters that an RDP class will reference are defined in a data contract class.
The following two classes are required to be able to set Report Data Provider as your data source type on a report with
parameters.
Report Data Provider Class processes business logic based on a query and parameters defined in the data contract
class, and then returns the tables as a dataset for the report.
A data contract class has methods with the DataMemberAttribute attribute. The name that follows the attribute is the
parameter name that displays in Visual Studio when you bind a report data set to the RDP class. Add a method named
parmAccountNum in code editor.
The following example illustrates the code for the parmAccountNum method.
[DataMemberAttribute("AccountNum")]
public AccountNum parmAccountNum(AccountNum _accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}
The following example illustrates the code for the parmAccountStmt method.
[DataMemberAttribute("CustAccountStatement")]
public CustAccountStatement parmAccountStmt(CustAccountStatement _accountStmt = accountStmt)
{
accountStmt = _accountStmt;
return accountStmt;
}
Your code will get parameters from the end user, process business logic to generate data in a table and then return the table to
render in the report. You will define a method that returns a table of the data that you process in the RDP class.
A table returned by a method can be a temporary table (InMemory or TempDB) or a regular table. When the data returned is
used for reporting only, it is a best practice to use a temporary table.
Use an InMemory temporary table if the data set is small, like 1000 records.
Use a TempDB temporary table for large data sets to improve performance.
If the data returned depends on the company context the report is run from, then the tables returned by the RDP class must have the table property
SaveDataPerCompany set to Yes.
[SRSReportDataSetAttribute('TmpCust')]
public TmpCustTableSample getTmpCustTable()
{
select * from tmpCust;
return tmpCust;
}
You will provide the report business logic in the processReport method. Override the processReport method to provide business
logic for your report.
The following example illustrates how the processReport method computes data and populates the data tables that will be
returned to Reporting Services.
public void processReport()
{
AccountNum
accntNum;
CustAccountStatement custAcctStmt;
boolean
Query
boolInclTax;
query;
QueryRun
qr;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange
CustTable
queryBuildRange;
queryCustTable;
SrsRdpContractSample dataContract;
if(accntNum)
{
queryBuildRange = queryBuildDataSource.findRange(fieldnum(CustTable, AccountNum));
if (!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable, AccountNum));
}
// If an account number has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
queryBuildRange.value(accntNum);
}
if(custAcctStmt)
{
if(boolInclTax)
{
queryBuildRange = queryBuildDataSource.findRange(fieldnum(CustTable, InclTax));
if (!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable, InclTax));
}
// If flag to include tax has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
queryBuildRange.value(int2str(boolInclTax));
}
The next step is to create a report using the Visual Studio tools for Microsoft Dynamics AX. For more information, see Creating
Reports Overview. For the complete steps to bind a report data provider class to a report, see Walkthrough: Creating a Report
Bound to a Report Data Provider Class (X++ Business Logic).
See also
How to: Group and Order Report Parameters by Using a Data Contract Class
Guidance for Choosing the Data Source Type
A data contract class is used to define the groups, the order of the groups, and alignment in the groups.
A data contract method is used to specify the group that a report parameter belongs to, and the order of the report
parameter relative to the other report parameters in the group.
To define groups, the order of groups, and the alignment of groups in a data contract class
1.
In the Application Object Tree (AOT), right-click the Classes node, and then click New Class.
2.
Right-click the new class, click Rename, and then enter SrsRDPContractSample.
3.
4.
Enter the following code in the class declaration to define the class.
[
DataContractAttribute,
SysOperationGroupAttribute("AccountsGroup", "@SYS313802", "1", FormArrangeMethod::Vertical),
SysOperationGroupAttribute("TaxGroup", "@SYS130006", "2")
]
public class SrsRDPContractSample
{
AccountNum accountNum;
CustAccountStatement accountStmt;
boolean inclTax;
}
Use the DataMemberAttribute attribute to indicate that the method is a data contract method, and to specify the
parameter name, AccountNum, that is displayed in Visual Studio when you bind a report data set to an RDP class.
The name that follows the attribute is the parameter name that is displayed in Visual Studio when you bind a report
data set to the RDP class.
Use the SysOperationGroupMemberAttribute attribute to indicate that the parameter belongs to the AccountGroup
group.
Use the SysOperationDisplayOrderAttribute attribute to indicate that the parameter is displayed first in the group.
Right-click the SrsRDPContractSample class, point to New, and then click Method.
2.
Next Steps
To use the report parameter groups in the data contract class, define an RDP class. A data contract class defines the report
parameters that an RDP class references. For the complete procedure, see How to: Use a Report Data Provider Class in a Report.
You then use the Visual Studio Reporting Tools for Microsoft Dynamics AX to define a report that has a dataset that is bound to
the RDP class. For information about how to bind an RDP class to a report, see Walkthrough: Creating a Report Bound to a
Report Data Provider Class (X++ Business Logic).
Note
The Visual Studio Report Viewer does not display the grouping and order that you specified in the data contract class. To see the report that has the
grouping and order of parameters that you specified in the data contract class, you must deploy and run the report from Microsoft Dynamics AX.
See also
How to: Group and Order Report Parameters by Using a Data Contract Class
Guidance for Choosing the Data Source Type
Creating Reports Overview
Controls Used to Render Report Parameters
How to: Define a Report Parameter
How to: Group and Order Report Parameters by Using Visual Studio
2.
The X++ code is called using a service and the service is compiled into MSIL.
These steps apply to debug a Microsoft Dynamics AX report executing in the following environments:
Visual Studio
For more information on debugging, see Microsoft Dynamics AX Debugger. For information on when and how to use an RDP
class, see Defining Report Data.
In the following sections, you determine which AOS service account to debug the RDP class in and add the account to the
Microsoft Dynamics AX Debugging Users group. You create a server configuration with debug enabled and then you can add
breakpoints in your code.
From the Start menu, point to All Programs, click Administrative Tools, and then click Services.
2.
In Services, right-click the Microsoft Dynamics AX Object Server service and then click Properties.
3.
In the Properties window, on the Log On tab, the AOS service account is specified in the This account field.
From the Start menu, point to All Programs, click Administrative Tools, click Computer Management, and then click
Local Users and Groups.
2.
In Local Users and Groups, double-click Groups, right-click Microsoft Dynamics AX Debugging Users and click Add to
Group.
3.
In the Properties window, click Add and add the AOS service account to the group.
4.
From the Start menu, point to Administrative Tools and then click Microsoft Dynamics AX Server Configuration.
2.
In Microsoft Dynamics AX Server Configuration Utility, click the Manage button, and then click Create configuration.
3.
In the Create Configuration window, enter a Configuration name like Debug and then click OK.
4.
On the Application Object Server tab, select Enable breakpoints to debug X++ code running on this server and Enable
global breakpoints to debug X++ code running in batch jobs.
5.
Click OK and when prompted to restart the AOS service click Yes.
6.
From the Start menu, point to All Programs, click the Microsoft Dynamics AX folder, and then click the Microsoft
Dynamics AX Debugger.
7.
From the Microsoft Dynamics AX Development Workspace, from the Tools menu, click Options. On the Development
tab, click the Debug mode dropdown, and then select When Breakpoint.
To add a breakpoint
In Code Editor, in the processReport method of the RDP class to debug, add the breakpoint; keyword.
Note
To stop at the breakpoint you set, AX Debugger must be running when you run the report.
See also
Allow debugging
RDP class processes business logic based on a query and parameters that are defined in the data contract class, and
then returns the tables as a dataset for the report.
A data contract class is an X++ class that has getters, setters, and the DataContractAttribute attribute. A nested data contract is
defined the same as other data contract classes. It is a nested data contract when it is used by another class. After you define
the nested data contract, you can reuse it in your code where those parameters are appropriate. In the following example you
will define a nested data contract class. The example that is used creates a Boolean parameter that determines whether to
include tax.
In the AOT, right-click the Classes node, and then select New Class.
2.
Right-click the new class, click Rename, and then enter SrsRDPNestedContractSample.
3.
4.
In code editor, enter the following code in the class declaration to define the class.
[DataContractAttribute]
public class SrsRDPNestedContractSample
{
boolean inclTax;
}
A data contract class has methods with the DataMemberAttribute attribute. The name that follows the attribute is the
parameter name that displays in Visual Studio when you bind a report data set to the RDP class. The following example
illustrates a data contract method for the nested data contract example.
2.
[DataMemberAttribute(InclTax)]
public boolean parmInclTax(boolean _inclTax = inclTax)
{
inclTax = _inclTax;
return inclTax;
}
In the AOT, right-click the Classes node, and then select New Class.
2.
Right-click the new class, click Rename, and then enter SrsRDPContractSample.
3.
4.
In code editor, enter the following code in the class declaration to define the class.
[DataContractAttribute]
public class SrsRDPContractSample
{
AccountNum = accountNum;
CustAccountStatment accountStmt;
SrsRdpNestedContractSample nestedContract;
}
A data contract class has methods with the DataMemberAttribute attribute. In this section, add a method for each report
parameter and name them parmAccountNum, parmAccountStmt, and parmNestedContract. The following example illustrates a
data contract method named parmAccountNum.
2.
3.
4.
5.
6.
Use an InMemory temporary table if the data set is small, such as 1000 records.
Use a TempDB temporary table for large data sets to improve performance.
Note
For more information, see Temporary Tables and the TableType Property. In this section you will create a temporary table to
store the data for the report.
In the AOT, expand the Data Dictionary node, right-click the Tables node, and then click New Table.
2.
3.
In the Properties window, set the Name property to TmpCustTableSample and set the Table Type property to
TempDB. This will define the table as a SQL Server temporary table. Set the SaveDataPerCompany property to Yes if
the data that is returned depends on the company context from which the report is run.
4.
Expand the node next to the TmpCustTableSample table so that you can see the Fields node.
5.
Press Ctrl+D to open another AOT window and move the window so that you can see both AOT windows.
6.
In the second AOT, expand the Data Dictionary node, expand the Extended Data Types node, and drag the following
types to the Field node in the first AOT window:
7.
AccountNum
CustName
LogisticsAddressing
CustGroupId
Phone
CustInvoiceAccount
ActionDays
InclTax
In the second AOT window, expand the Base Enums node and drag the CustAccountStatement enumeration to the
Fields node of the first AOT window.
In this section you define an RDP class that uses the nested data contract. The RDP class is a data provider that lets you add
business logic for the data that is displayed on a report. An RDP class is an X++ class that extends the
SRSReportDataProviderBase class. The following list describes the attributes that are attached to the RDP class for this example:
Attach the SRSReportQueryAttribute attribute to the query specified in the parmQuery method in the RDP class. For
this example, set the attribute to the Cust query.
Attach the SRSReportParameterAttribute attribute to specify the data contract class that defines the report parameters
for the report. For this example, set the attribute to the SrsRDPContractSample data contract.
In the AOT, right-click the Classes node, and then click New Class.
2.
Right-click the new class, click Rename, and then enter SrsRDPSampleClass.
3.
4.
In code editor, enter the following code in the class declaration to define the class.
[
SRSReportQueryAttribute(querystr(Cust)),
SRSReportParameterAttribute(classstr(SrsRDPContractSample))
]
public class SrsRdpSampleClass extends SRSReportDataProviderBase
{
TmpCustTableSample tmpCust;
}
Your code gets parameters from the end user, processes business logic to generate data in a table, and then returns the table to
display in the report. You define a method that returns a table of the data that you process in the RDP class to Reporting
Services. In this section, add a method named getTmpCustTable and attach the SRSReportDataSetAttribute attribute to indicate
the dataset for the report.
2.
[SRSReportDataSetAttribute(TmpCust)]
public TmpCustTableSample getTmpCustTable()
{
select * from tmpCust;
return tmpCust;
}
You will provide the report business logic in the processReport method. The processReport method computes data and
populates the data tables that are returned to Reporting Services. Override the processReport method to provide business logic
for your report. The following example gets the value of the boolInclTax parameter from the nested data contract.
AccountNum
accntNum;
CustAccountStatement custAcctStmt;
boolean
Query
boolInclTax;
query;
QueryRun
qr;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange
CustTable
queryBuildRange;
queryCustTable;
SrsRdpContractSample dataContract;
if(accntNum)
{
queryBuildRange = queryBuildDataSource.findRange(fieldnum(CustTable, AccountNum));
if (!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable, AccountNum));
}
// If an account number has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
queryBuildRange.value(accntNum);
}
if(custAcctStmt)
{
queryBuildRange = queryBuildDataSource.findRange(fieldnum(CustTable, AccountStatement));
if (!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable, AccountStatement));
}
// If an account statement has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
queryBuildRange.value(int2str(custAcctStmt));
if(boolInclTax)
{
queryBuildRange = queryBuildDataSource.findRange(fieldnum(CustTable, InclTax));
if (!queryBuildRange)
{
queryBuildRange = queryBuildDataSource.addRange(fieldnum(CustTable, InclTax));
}
// If flag to include tax has not been set, then use the parameter value to set it.
if(!queryBuildRange.value())
queryBuildRange.value(int2str(boolInclTax));
}
The next step is to create a report bound to the RDP class by using the Visual Studio tools for Microsoft Dynamics AX.
For more information, see Creating Reports Overview. For the complete steps to bind an RDP class to a report, see Walkthrough:
Creating a Report Bound to a Report Data Provider Class (X++ Business Logic).
See also
How to: Group and Order Report Parameters by Using a Data Contract Class
Guidance for Choosing the Data Source Type
Creating Reports Overview