Vous êtes sur la page 1sur 18

My Collection

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

How to: Use a Report Data Provider Class in a


Report [AX 2012]
Updated: February 1, 2013
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
A report data provider (RDP) class is an X++ class that is used to access and process data for a report. An RDP class is an
appropriate data source type when the following conditions are met:

You cannot query directly for the data you want to render on a report.

The data to be processed and displayed is from Microsoft Dynamics AX.

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.

Data Contract Class defines the parameters in the report.

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.

To define a data contract class


A data contract is an X++ class that has getters, setters and the DataContractAttribute attribute. You create the RDP and data
contract classes in the MorphX code editor. For information about how to create an X++ class, see Declaration of Classes.
The following example illustrates the code to declare a data contract class.
[DataContractAttribute]
public class SrsRDPContractSample
{
AccountNum accountNum;
CustAccountStatment accountStmt;
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. 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;
}

Add a method named parmAccountStmt in code editor.

The following example illustrates the code for the parmAccountStmt method.
[DataMemberAttribute("CustAccountStatement")]
public CustAccountStatement parmAccountStmt(CustAccountStatement _accountStmt = accountStmt)
{
accountStmt = _accountStmt;
return accountStmt;
}

Add a method named parmInclTax in code editor.


The following example illustrates the code for the parmInclTax method.
[DataMemberAttribute("InclTax")]
public boolean parmInclTax(boolean _inclTax = inclTax)
{
inclTax = _inclTax;
return inclTax;
}

To define a report data provider class


An RDP class extends the SRSReportDataProviderBase class. You set the SRSReportParameterAttribute attribute to the data
contract you created for the RDP class. The data contract defines the parameters that the report uses. You set the
SRSReportQueryAttribute attribute to the query specified in the parmQuery method in the RDP class.
The following example illustrates an RDP class declaration that uses the SrsRDPContractSample data contract class and the Cust
query.
[
SRSReportQueryAttribute('Cust'),
SRSReportParameterAttribute(classstr(SrsRDPContractSample))
]
public class SrsRdpSampleClass extends SRSReportDataProviderBase
{
TmpCustTableSample tmpCust;
}

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.

You can have one or more methods return tables.


Note

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.

The following example illustrates an RDP class method named getTmpCustTable.

[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;

// Get the query from the runtime using a dynamic query.


query = this.parmQuery();

// Get the parameters passed from runtime.


dataContract = this.parmDataContract();
accntNum = dataContract.parmAccountNum();
custAcctStmt = dataContract.parmAccountStmt();
boolInclTax = dataContract.parmInclTax();

// Add parameters to the query.


queryBuildDataSource = query.dataSourceTable(tablenum(CustTable));

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));
}

// Run the query with modified ranges.


qr = new QueryRun(query);
ttsbegin;
while(qr.next())
{
tmpCust.clear();
queryCustTable = qr.get(tablenum(CustTable));
tmpCust.AccountNum = queryCustTable.AccountNum;
tmpCust.Name = queryCustTable.name();
tmpCust.Address = queryCustTable.address();
tmpCust.CustGroup = queryCustTable.CustGroup;
tmpCust.Phone = queryCustTable.phone();
tmpCust.InvoiceAccount = queryCustTable.InvoiceAccount;
tmpCust.AccountStatement = queryCustTable.AccountStatement;
tmpCust.InclTax = queryCustTable.InclTax;
tmpCust.insert();
}
ttscommit;
}

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

How to: Group and Order Report Parameters by


Using a Data Contract Class [AX 2012]
Updated: October 18, 2011
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
This topic describes how to specify the grouping and order of parameters for a report. Report parameters let an end user of a
report select or enter the values that are used when the report is printed. A data contract class defines the parameters for a
report that is bound to a report data provider (RDP) class. You can specify one or more groups of report parameters, the order
of the groups, and the order in which the report parameters appear in a print dialog box. For information about data contracts,
see How to: Use a Report Data Provider Class in a Report.
You can also define report parameter groups by using Microsoft Visual Studio. The grouping and order of report parameters that
you specify in Visual Studio take precedence over the grouping and order that are defined in the data contract. For more
information, see How to: Group and Order Report Parameters by Using Visual Studio.
You use Visual Studio to define the grouping and order of report parameters when the scenario is complex, such as when you
want to use multiple nested groups. The benefit of using a data contract class to define the grouping and order of report
parameters is that you maintain consistent formatting when you reuse the data contract in another report or in a SysOperation
service.

Defining the Grouping and Ordering of Report Parameters


You use two constructs to define the grouping of report parameters:

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.

Defining a Data Contract Class


Groups are defined in a data contract class. A data contract class is an X++ class to which getters, setters, and the
DataContractAttribute attribute are attached. By grouping two or more report parameters, you indicate that the parameters are
related to each other. To define a group, attach the SysOperationGroupAttribute attribute to a data contract class.
A data contract class defines the following properties of a group:

The group name

The label that is displayed for the group

The order of the group relative to other groups

The arrangement, either vertical or horizontal of 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.

Expand SrsRDPContractSample, right-click classDeclaration, and then click Code.

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;
}

Defining the Order of Report Parameters in a Data Contract Method


A data contract method defines a report parameter. Each report parameter requires a separate data contract method. You can
use a data contract method to indicate that a report parameter belongs to a group. You can also specify the order in which the
parameter is displayed relative to the other report parameters in the group.
This section describes how to create a data contract method and configure it in the following ways:

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.

To define the order of report parameters in a data contract method


1.

Right-click the SrsRDPContractSample class, point to New, and then click Method.

2.

Edit the method so that it contains the following code.


[
DataMemberAttribute("AccountNum"),
SysOperationGroupMemberAttribute("AccountsGroup"),
SysOperationDisplayOrderAttribute("1")
]
public AccountNum parmAccountNum(AccountNum _accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}

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

How to: Configure the Debugger to Debug a


Report Data Provider Class [AX 2012]
Updated: February 1, 2013
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
This topic provides steps to configure the debugger before you debug a report data provider (RDP) class. This scenario requires
special setup because it involves X++ code and code that is managed by the .NET Framework.
By using the Visual Studio reporting tools for Microsoft Dynamics AX, you can bind a report to an X++ RDP class. This allows you
to process data using X++ business logic that executes on the Application Object Server (AOS). X++ code is debugged using the
MorphX debugger. The RDP class is called with a service that is compiled into Microsoft Intermediate Language (MSIL). MSIL is
debugged and managed by the .NET Framework.
The debug process must occur in X++ code and managed code because of the following two conditions:
1.

The X++ code, that is not managed, runs on the AOS.

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

SQL Server Reporting Services (SSRS) Report Manager

Microsoft Dynamics AX client

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.

To determine the AOS service account


1.

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.

To add the AOS service account to the debug group


1.

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.

Restart the machine.

To configure for debugging


1.

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

How to: Define a Nested Data Contract [AX 2012]


Updated: January 21, 2012
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
Create a nested data contract class when you have a parameter that you want to reuse on many reports that are bound to a
report data provider (RDP) class. An RDP class is an X++ class that is used to access and process data for a report. X++ classes are
created in the AOT and an RDP class will be bound to a report by using the Visual Studio tools for Microsoft Dynamics AX.
The following two classes are required to use Report Data Provider as your data source type:

Data contract class defines the parameters in the report.

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.

Defining a Nested Data Contract Class


An RDP class must have a data contract if the report has one or more report parameters. This example defines one report
parameter to prompt the user whether to include tax. A data contract is an X++ class that has getters, setters, and the attribute
DataContractAttribute. The data contract defines the parameters that the report uses. The following example illustrates defining
a data contract class that will be nested and reused.

To define a data contract class


1.

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.

Expand SrsRDPNestedContractSample, right-click classDeclaration, and then click View Code.

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.

To define data contract methods


1.

Right-click SrsRDPNestedContractSample, point to New, and then click Method.

2.

Edit the method so that it contains the following code.

[DataMemberAttribute(InclTax)]
public boolean parmInclTax(boolean _inclTax = inclTax)
{
inclTax = _inclTax;

return inclTax;
}

Use the Nested Data Contract


Next, use the nested data contract that you defined. By using the nested data contract, you will add the parameter that
determines whether to include tax that is defined in the nested data contract. The following example illustrates a data contract
class declaration that adds the SrsRdpNestedContractSample nested data contract.

To use the nested data contract


1.

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.

Expand SrsRDPContractSample, right-click classDeclaration, and then click View Code.

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.

To define data contract methods


1.

Right-click SrsRDPContractSample, point to New, and then click Method.

2.

Edit the method so that it contains the following code.


[DataMemberAttribute(AccountNum)]
public AccountNum parmAccountNum(AccountNum _accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}

3.

Right-click SrsRDPContractSample, point to New, and then click Method.

4.

Edit the method so that it contains the following code.


[DataMemberAttribute("CustAccountStatement")]
public CustAccountStatement parmAccountStmt(CustAccountStatement _accountStmt = accountStmt)
{
accountStmt = _accountStmt;
return accountStmt;
}

5.

Right-click SrsRDPContractSample, point to New, and then click Method.

6.

Edit the method so that it contains the following code.


[DataMemberAttribute]
public SrsRdpNestedContractSample parmNestedContract(SrsRdpNestedContractSample _nestedContract = nestedContract)
{
nestedContract = _nestedContract;
return nestedContract;
}

Create a Temporary Table


Data for an RDP report is preprocessed and then stored in a temporary table. The temporary table is used by Reporting Services
when the report is displayed. A table that is returned by a method can be a temporary table (InMemory or TempDB) or a regular
table. You can have one or more methods return tables. When the data that is returned is used for reporting only, it is a best
practice to use a temporary table because the data in the tables will are cleaned after the report is run.

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.

To create a temporary table


1.

In the AOT, expand the Data Dictionary node, right-click the Tables node, and then click New Table.

2.

Right-click the table, and then click Properties.

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.

Define a Report Data Provider Class

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.

To define a report data provider class


1.

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.

Expand SrsRDPSampleClass, right-click classDeclaration, and then click Code.

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.

To define a method to return data to Reporting Services


1.

Right-click SrsRdpSampleClass, point to New, and then click Method.

2.

Edit the method so that it contains the following code.

[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.

To add business logic for the report

Right-click SrsRdpSampleClass, point to New, and then click Method.

public void processReport()


{

AccountNum

accntNum;

CustAccountStatement custAcctStmt;
boolean
Query

boolInclTax;
query;

QueryRun

qr;

QueryBuildDataSource queryBuildDataSource;
QueryBuildRange
CustTable

queryBuildRange;
queryCustTable;

SrsRdpContractSample dataContract;

// Get the query from the runtime using a dynamic query.


query = this.parmQuery();

// Get the parameters passed from runtime.


dataContract = this.parmDataContract();
accntNum = dataContract.parmAccountNum();
custAcctStmt = dataContract.parmAccountStmt();

// Get the parameters from the nested contract.


nestedDataContract = dataContract.parmNestedContract();
boolInclTax = nestedDataContract.parmInclTax();

// Add parameters to the query.


queryBuildDataSource = query.dataSourceTable(tablenum(CustTable));

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));
}

// Run the query with modified ranges.


qr = new QueryRun(query);
ttsbegin;
while(qr.next())
{
tmpCust.clear();
queryCustTable = qr.get(tablenum(CustTable));
tmpCust.AccountNum = queryCustTable.AccountNum;
tmpCust.CustName = queryCustTable.name();
tmpCust.LogisticsAddressing = queryCustTable.address();
tmpCust.CustGroupId = queryCustTable.CustGroup;
tmpCust.Phone = queryCustTable.phone();
tmpCust.CustInvoiceAccount = queryCustTable.InvoiceAccount;
tmpCust.CustAccountStatement = queryCustTable.AccountStatement;
tmpCust.InclTax = queryCustTable.InclTax;
tmpCust.insert();
}
ttscommit;
}

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

Vous aimerez peut-être aussi