>

Category Archives: Reporting

Troubleshooting Report Issues -AX 2012

All of us facing many issues while installing, deployment and customize AX 2012 reports. the Table below include most of troubleshooting of AX reports.
Source : https://technet.microsoft.com/en-us/library/gg731894.aspx

Issue Additional information for troubleshooting
The report is broken for any reason and the data source is a query. Execute the query outside of the report. Confirm that the query returns expected results.Use a form, job, or Query Services to test the query. For more information, see Query Service.
The report is broken and the data source is a report data provider (RDP) class. Debug the class. For more information, see How to: Configure the Debugger to Debug a Report Data Provider Class.
When you preview the report you receive the following error:No report data table with name <dataset table name> exists in report schema for data provider <RDP name>. Verify that the report is bound to tables that exist and do not bind multiple datasets to a single report data provider class. Instead, define the report to have the multiple tables pointing to the same dataset.
No data was returned in the report. Verify you have the right company, that there is data entered for that company, and that the user has access to the expected data.
The report has a rendering error. When you try to run the report, you receive an error like the following:An error has occurred during report processing. The SSRS Execution Account password could be invalid.

  1. From the Start menu, point to All Programs, click the Microsoft SQL Server folder, click the Configuration Tools folder, and then click Reporting Services Configuration Manager.
  2. In Reporting Services Configuration Manager, click Connect and then click Execution Account.
  3. Set the password and then click Apply. The account and password should be the same as the Microsoft Dynamics AX proxy account. For more information, see Before you install the Reporting Services extensions.
  4. Click the ServerName/MSSQLSERVER and then click Stop. Then click Start to restart the server. Always check with the SQL administrator and make sure no other users are connected to the server before you restart the server.
The report labels do not display, or the report shows label IDs, like Labels!@SYS24426 instead of the label values. The SSRS Service Account password could be invalid.

  1. From the Start menu, point to All Programs, click the SQL Server folder, click the Configuration Tools folder, and then click Reporting Services Configuration Manager.
  2. In Reporting Services Configuration Manager click Connect and then click Service Account.
  3. Set the password and then click Apply. The account and password should be the same as the Microsoft Dynamics AX proxy account. For more information, see Before you install the Reporting Services extensions.
  4. Click the ServerName/MSSQLSERVER and then click Stop. Then click Start to restart the server. Always check with the SQL administrator and make sure no other users are connected to the server before you restart the server.
When running a report that uses an enumeration value as a multi-value parameter of a report, you get an error like the following:The ‘ParameterName’ parameter is missing a value. Set the Data Type property of the enumeration parameter to Integer.This is because the label value of enumeration items are converted to name values in theSrsReportDataContractUIBuilder.getMultiSelectFromDialogField method.
When building a report project that uses a SQL report data source, you receive the following error:The report does not have the mandatory framework parameter AX_ReportContext. Manually create the AX_ReportContext report parameter. For more information, see Walkthrough: Creating a Report with Parameters.
Time values in a report bound to an AOT query are displayed as h:mm:ss tt in Visual Studio preview and the Microsoft Dynamics AX client instead of the actual time. Select the field in the report design and set the following properties:

  • Expression property to=Microsoft.Dynamics.Framework.Reports.BuiltInMethods.ConvertAXTimeToDateTime(Fields!timefield.Value)
  • Format String property to hh:mm:ss
An AOS connection error message indicates you cannot establish a connection to the AOS. To delete, rename, save, or restore a report model element, you must have a connection to the Application Object Server (AOS). If the AOS is disconnected or stops running after a reporting project is opened, an AOS connection error message will display. To continue, restart or restore the connection to the AOS, and then repeat the command that failed.
The Undo command is not functioning in the report model. In Model Editor, only unsaved commands can be undone. Once a command is saved, it cannot be undone by using the Undo command. To revert a saved command, you must manually modify the report element. If you are using source code control, another option is to discard the file that is checked out if no other changes have been made.
The saved report model customization is not visible in Application Explorer. Application Explorer does not automatically refresh as Model Editor saves changes to the model store database. To view changes in Application Explorer, right-click the model element, and then click Refresh.
The saved report model customization is not visible in the AOT. The AOT does not automatically refresh as Model Editor saves changes in the model store database. To view changes in the AOT, in the Development Workspace Tools menu, click Development tools, Application objects, and then Refresh runtime model data.
When previewing a report in Visual Studio you receive the following error:The %0 parameter is missing a value %1 Verify that you did not create a report with a Labels expression in the Values property of the report parameter. This is not supported because Reporting Services resolves parameter labels after the parameter evaluation and execution occur.–or–Verify that you did not set the Allow Blank property to True to make the parameter optional. This is not supported for dataset bound parameters by the reporting framework. The following items identify the alternative approaches for OLTP and OLAP reports:

  • OLTP reports – use an extended data type (EDT) to add a null-value string variable to the drop-down list as a default. When running the report, you can set the parameter value to NULL by not selecting anything from the drop-down list.
  • OLAP reports – add a value All to the drop-down list to indicate that no filtering is to be done by the parameter.
The query for the report was changed but the report does not reflect the change. After you run the report, the query and ranges are cached in the SRSReportQuery table. To refresh the cache, you must manually delete all records in the SRSReportQuery table for any reports or report parameters that use the query that was changed.
Locking or hiding a range for a report parameter is not working. At runtime, the parameter is enabled and the user is able to filter on the range. This occurs when a report is bound to a query that has a range value with a Status property value of Locked or Hidden. SQL Server Reporting Services does not honor the query range Status property.
The Label reference does not display properly. The Value property is set to theParameters!MyParm.Value parameter. The parameter must be explicitly bound to data using a dataset in the Visual Studio Tools for Microsoft Dynamics AX report model.
The parameter is explicitly bound to datasets with two columns, label and value. The value displays properly. The Label reference displays properly everywhere except in the client. The report viewer control does not support the ability to specify report parameter labels, only values.
When you build a Visual Basic project for a report, the project does not build.-or-You receive the error “The business logic assembly ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null does not contain a class for report Report1.” You must clear out the namespace setting of the Visual Basic project. In Solution Explorer, right-click the project, and then clickProperties. In the Application area, delete the text in the Root namespace field.
In Visual Studio, you build a project and receive the error, “System.InvalidOperationException: Object is currently in use elsewhere.” This error indicates a synchronization issue. Close the solution and then rebuild the report.
When you debug a C# data method, the SQL Server Reporting Services server crashes. This is a known issue if you are debugging a C# data method on a machine that is running a 64 bit operating system. To work around this issue, open Visual Studio 2008, load the C# file, set the break point, and then attach to the Reporting Services process. For more information, see Debugging Managed Code in Microsoft Dynamics AX.
Reports that run for more than ten minutes time out. For example:

  • If you are previewing a report in Visual Studio and a timeout occurs, you will receive the following error:

Timeout error occured when calling AOS service. Use Dynamics AX Client Configuration Utility to change WCF configuration values. Exception details: The request channel timed out while waiting for a reply after 00:00:59.9449945. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

  • If a user is trying to view a report in the Microsoft Dynamics AX client and a timeout occurs, the user will receive the following error in the InfoLog:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

See Tips to help prevent long-running reports from timing out.
Errors are generated when reports are saved to a file, printed to a printer, or emailed. View the detailed error messages that are recorded for the Reporting module in the Exceptions form. Click System administration > Periodic > Services and Application Integration Framework > Exceptions.
The same report contains different information when saved to different file formats.For example, a sales invoice report that is saved to an .HTML file may contain header information, line items, and totals. When the same report is saved to an .XML file, it may contain only the line items and totals. This is by design. For more information about how reports are rendered in the available file formats, see Exporting Reports (Report Builder 3.0 and SSRS) in the SQL Server documentation.
Users receive the following error when clicking on a drill-through link on a report in Enterprise Portal:[CompanyName] is not a valid company. Check the value and try again. This situation may occur when Reporting Services 2008 or Reporting Services 2008 R2 is running in SharePoint integrated mode. To resolve this issue, install Reporting Services 2008 R2 with Service Pack 2.Note: SharePoint integrated mode is supported if you are using Microsoft Dynamics AX 2012 R2 or later.
Tables are not aligned correctly when viewing reports in right-to-left (RTL) languages. This is a known issue with the Reporting Services tablix control. For more information about the issue, see Known Issue: Dynamic Precision designs spacing issues in RTL languages in the Microsoft Dynamics AX Business Intelligence blog.
The Reporting Services extensions become unusable when additional Reporting Services instances are installed on the same computer. As a result:

  • Reports cannot be deployed.
  • Reports cannot be displayed.
To resolve this issue, configure all the Reporting Services instances on the computer. For more information about how to install and configure multiple instances of Reporting Services on the same computer, see Install multiple instances of Reporting Services on the same computer (for use with Microsoft Dynamics AX).
When printing a report that has been saved as a PDF file, the printer page size does not correspond to the PDF page size. To resolve this issue, select the Choose paper source by PDF page size check box in the Print window that is displayed when printing the report to the printer.
When using an environment that includes a hardware load balancer, such as F5, reports that run for more than five minutes time out. To resolve this issue, adjust the timeout period specified in the hardware load balancer. For example, if you are using F5, set theIdle Timeout field to 7200 seconds or higher. For more information, see the F5 Knowledge Base.
You need to adjust the alignment of a report. For tips on adjusting the alignment, see this blog post: SSRS report tips to adjust alignment for pre-formatted print stock (i.e. 1099-MISC form).

Running AX report through batch job in AX2009 (batch printing)

Running batch report in AX2009 (batch printing)

Since the change of AX2009 batch framework, printing of report through batch can be done through two methods:
– Printing from server (to printer or file)
– Printing from client (the legacy batch processing)
Prerequisites: For both of the method, there’re some mandatory setup:

  1. Enable any of the AOS that you want to make it as batch AOS
    (Administration -> Setup -> Server configuration)
  2. Create batch group for printing.
    Eg. One for client printing and one for server printing.
    (Administration -> Setup -> Batch groups)
  3. Add the batch group created in #2 into the AOS enabled for batch processing (in #1)

complete article available here

Walkthrough: Creating a Report Bound to a Report Data Provider Class (X++ Business Logic) [AX 2012]

In this walkthrough, you use a report data provider (RDP) class with business logic to process data and then display the outcome of the business logic on a report.

An RDP class is an X++ class that is used to access and process data for a Reporting Services report. The options for a data source type for a Microsoft Dynamics AX report are query, business logic, and RDP. An RDP class is an appropriate data source type when the following conditions are met.

  1. You cannot query directly for the data you want to render on a report.
  2. The data to be processed and displayed is from Microsoft Dynamics AX.

The following illustration is a preview of the report that you create in this walkthrough.

clip_image001Note

The data that displays in your report may vary depending upon the sample data that is available to you.

The following elements are required to set RDP as your data source type.

  • Temporary table – RDP class fills a temporary table with data that will be used by Reporting Services to display the report.
  • Data contract class – defines the parameters in the report.
  • Report data provider class – processes business logic based on parameters and a query, and then returns the tables as a dataset for the report.

This walkthrough illustrates the following tasks:

  • Creating a temporary table
  • Defining a report data provider class
  • Defining the report parameters
  • Defining a method to return data to Reporting Services
  • Adding business logic for the report
  • Creating a reporting project
  • Binding a report to a report data provider class

Creating 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 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 dataset is small, for reports that will display fewer than 1000 records.
  • Use a TempDB temporary table for large datasets to improve performance.

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 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.
  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 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:
    • AccountNum
    • CustName
    • LogisticsAddressing
    • CustGroupId
    • Phone
    • CustInvoiceAccount
    • ActionDays
    • InclTax
  7. In the second AOT window, expand the Base Enums node and drag the CustAccountStatement enumeration to the Fields node of the first AOT window.

Defining a Report Data Provider Class

The RDP class is a data provider that allows you to add business logic for the data that is displayed on a report. The business logic for this example prompts the end user for parameter values, processes business logic to generate data in a table, and then returns the table to render in the report. In this section, you define the RDP class by extending the SRSReportDataProviderBase class. Then add the TmpCustTableSample table as a global variable. The following list describes the attributes that are attached to the RDP class for this example:

  • Attach the SRSReportQueryAttribute attribute to specify the query to use to get the data for the report.

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 SrsRDPContractSampledata 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 View Code.
  4. In code editor, enter the following code in the class declaration to define the class.

X++

[

SRSReportQueryAttribute (querystr(Cust)),

SRSReportParameterAttribute(classstr(SrsRDPContractSample))

]

public class SrsRdpSampleClass extends SRSReportDataProviderBase

{

TmpCustTableSample tmpCust;

}

Defining a Data Contract Class

An RDP class must have a data contract if the report has one or more report parameters. This example defines three report parameters for account number, account statement, and whether to include tax. When you print the report, you can specify which data to print based on the report parameters. For example, you can specify to only print transactions for account number 4000.

A data contract is an X++ class with getters, setters, and the DataMemberAttribute attribute. The data contract defines the parameters that the report uses.

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

X++

[DataContractAttribute]

public class SrsRDPContractSample

{

AccountNum accountNum;

CustAccountStatement accountStmt;

boolean inclTax;

}

A data contract class has methods with the DataMemberAttribute attribute. The name that follows this attribute is the parameter name that displays in Visual Studio when you bind a report data set to the RDP class. In this section, add a method for each of the report parameters and name them parmAccountNum, parmAccountStmt, and parmInclTax.

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.

X++

[DataMemberAttribute("AccountNum")]

public AccountNum parmAccountNum(AccountNum _accountNum = accountNum)

{

accountNum = _accountNum;

return accountNum;

}

  1. Right-click SrsRDPContractSample, point to New, and then click Method.
  2. Edit the method so that it contains the following code.

X++

[DataMemberAttribute("CustAccountStatement")]

public CustAccountStatement parmAccountStmt(CustAccountStatement _accountStmt = accountStmt)

{

accountStmt = _accountStmt;

return accountStmt;

}

  1. Right-click SrsRDPContractSample, point to New, and then click Method.
  2. Edit the method so that it contains the following code.

X++

[DataMemberAttribute("InclTax")]

public boolean parmInclTax(boolean _inclTax = inclTax)

{

inclTax = _inclTax;

return inclTax;

}

Defining a Method to Return Data to Reporting Services

A method to return the processed data in the temporary table to Reporting Services is needed. 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 the 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.

X++

[SRSReportDataSetAttribute("TmpCust")]

public TmpCustTableSample getTmpCustTable()

{

select * from tmpCust;

return tmpCust;

}

Adding Business Logic for the Report

The business logic for this example prompts the end user for parameter values, processes business logic to generate data in a table, and then returns the table to render in the report.

The report business logic is provided in the processReport method. This method is called by Reporting Services at runtime. The following example illustrates how the processReport method computes data and populates the data table that is returned to Reporting Services. In this section, override the processReport method to provide business logic for your report.

To add business logic for the report

  1. Right-click SrsRdpSampleClass, point to Override method, and then click processReport.
  2. Edit the method so that it contains the following code.

X++

public void processReport()

{

AccountNum accountNumber;

CustAccountStatement custAcctStmt;

boolean boolInclTax;

Query query;

QueryRun queryRun;

QueryBuildDataSource queryBuildDataSource;

QueryBuildRange queryBuildRange;

CustTable queryCustTable;

SrsRdpContractSample dataContract;

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

// This base class method reads the query specified in the SRSReportQueryAttribute attribute.

query = this.parmQuery();

// Get the parameters passed from runtime.

// The base class methods read the SRSReportParameterAttribute attribute.

dataContract = this.parmDataContract();

accountNumber = dataContract.parmAccountNum();

custAcctStmt = dataContract.parmAccountStmt();

boolInclTax = dataContract.parmInclTax();

// Add parameters to the query.

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

if(accountNumber)

{

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(accountNumber);

}

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.

queryRun = new QueryRun(query);

ttsbegin;

while(queryRun.next())

{

tmpCust.clear();

queryCustTable = queryRun.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;

}

Creating a Reporting Project

Next, create a reporting project in Microsoft Visual Studio. When you create a reporting project, you use the Report Model to create a Reporting Services report.

To create a reporting project

  1. Open Microsoft Visual Studio.
  2. On the File menu, point to New, and then click Project. The New Project dialog box displays.
  3. In the Installed Templates pane, click Microsoft Dynamics AX. In the Templates pane, click Report Model.
  4. In the Name box, type SampleRDPReport, and in the Location box, type a location.
  5. Click OK.

A reporting project contains a report model where you can add a report to the model.

Binding a Report to a Report Data Provider Class

Now that you have created a reporting project, you are ready to define an auto design report that displays data from the Cust query. The following procedure explains how to create an auto design report that uses the RDP class as the data source.

To create an auto design report

  1. In Solution Explorer, right-click the ReportModel node, point to Add and then click Report.
  2. In Model Editor, right-click the Report1 node, and then click Rename.
  3. Type CustomerReport as the name.
  4. Right-click the Datasets node, and then click Add Dataset.
  5. In the Properties window, specify the following values.

Property

Value

Data Source

Dynamics AX

Data Source Type

Report Data Provider

Default Layout

Table

Dynamic Filters

True

clip_image001[1]Note

This setting is for dynamic parameters on the report. Setting the property to True allows you to filter the report by setting a range on any fields from the data source table.

Name

Customer

Query

Click the ellipsis button (…). A dialog box displays where you can select an RDP class that is defined in the AOT and identify the fields that you want to use. Select the SrsRDPSampleClass class and click Next. In the Select Fields dialog box, keep all the checkboxes selected, and click OK.

clip_image001[2]Note

Based on what you select, the Query property value is updated. In this case, the query is SELECT * FROM SrsRDPSampleClass.TmpCust.

  1. In Model Editor, select the Customer node and drag it onto the Designs node. An auto design named AutoDesign1 is created for the report.

clip_image001[3]Note

If you expand the Parameters node you see the parameters that you defined in the data contract class. When you define nested data contract parameters, they are listed under the Parameters node also.

Select the SrsRDPSampleClass_DynamicParameter parameter. In the Properties window, the AOT Query property is set to the query specified in the parmQuery method in the RDP class.

  1. Select AutoDesign1 and then click the Preview button.
  2. Enter a value for Account number and Account statement that returns data and then click the Report tab to preview the report.

clip_image001[4]Note

You can use * to display all of the account numbers on the report. Account statement is an enumeration and there is no wild card value for enumerations. Check your sample data to determine a valid enumeration value for Account statement.

The Select button displays because you set the Dynamic Filters property to True on the dataset. You have the option to click the Select button to specify a range to filter the report and limit the data that displays on the report.

The next steps are to add layout and style templates, deploy, and add the report to a menu item so you can see it in Microsoft Dynamics AX.

Developing RDP (Report data provider) based SSRS reports – AX 2012

RDP (Report data provider) based reports are developed, when reports has a complex logic that cannot be achieved by just using an AOT query. In RDP based reports, in addition to an AOT query, an RDP class is developed which contains the report logic. After processing all the report logic, the data is filled into the temporary table which is used as a data source for SSRS report. Now, I am going to describe about how to build an RDP based report. We will modify the previous AOT query for this example to add the CustTrans data source. The query will now look like as shown below:

image

Now create a new RDP class and name it SampleReportDP. To create RDP based report, following objects needs to be created:

  • An RDP class.
  • An AOT query.
  • A temp table.

The query has been modified for this example and now RDP class and temp table needs to be created. Just for a demo purpose, I have thought of a requirement where we need to display the transaction amount based on the customer group. The logic is as follows:

· If (customer group is 20) then multiply the transaction amount by 20

· If (customer group is 40) then multiply the transaction amount by 40

· If (customer group is 60) then multiply the transaction amount by 60

Create a new class and name it SampleReportDP. In class declaration extend the class from SRSReportDataProviderBase class. Add the following line before class declaration:

[SRSReportQueryAttribute(querystr(SampleQuery))]

This attribute specifies the AOT query which is used by this SSRS report. Also declare some class variables which are needed to store the values, retrieved after running the report query. The class declaration should look like as shown below:

image

The second step is to create a temp table which is used to store the report data. Create a new table and name it SampleReportTmp. Set the TableType property of the new table to InMemory. Create four fields in the temp table as shown below:

image

Create a new method in RDP class which will select the temp table records and return it afterwards to be used by the SSRS report. The new method should look like as shown below:

image

Now we are going to implement the logic discussed above in RDP class processReport method. The processReport method in RDP class is the point where the report processing begins. This method is called by the reporting framework. Actual report logic needs to be written in this method. In our case, the code for processReport method is as follows:

public void processReport()
{
    QueryRun queryRun;

    queryRun = new QueryRun(this.parmQuery());

    while (queryRun.next())
    {
        custTable = queryRun.get(tablenum(CustTable));
        custTrans = queryRun.get(tablenum(CustTrans));

        amountCur = custTrans.AmountCur;
        voucher   = custTrans.Voucher;
        custGroup = custTable.CustGroup;
        transDate = custTrans.TransDate;

        switch (custGroup)
        {
            case ’20’:
                amountCur = amountCur * 20;
            break;

            case ’40’:
                amountCur = amountCur * 40;

            case ’60’:
                amountCur = amountCur * 60;
            default:
                amountCur = custTrans.AmountCur;
        }

        this.insertSampleReportTmp();
    }
}

 

code for insertSampleReportTmp method is as follows:

private void insertSampleReportTmp()
{
    ;
    sampleReportTmp.AmountCur   = amountCur;
    sampleReportTmp.Voucher     = voucher;
    sampleReportTmp.TransDate   = transDate ;
    sampleReportTmp.CustGroup   = custGroup ;

    SampleReportTmp.insert();
}

Create a new Microsoft Dynamics AX reporting project from VS 2010 and name it RDPBasedReport. Add a report item to the project by right clicking on the Project. Change the report name to RDPBasedReport. Create a new data set and name it SampleRDPReportDS. Now open the properties page for the newly created dataset by clicking Ctrl + Enter. Set the data source type to ‘Report Data Provider’. Select the query property and click the ellipses to open the RDP class selection window. From the list of classes, select your RDP class which was SampleReportDP and then click next. Afterwards, select all the fields and then click OK. You report should match with the following screen shot:

image

Notice the query mentioned in the Query property of dataset. It is the syntax for mentioning RDP class and temp table in the query property whenever you use the report data provider as data source type. Add the new report to AOT by right clicking on the report project. Now deploy the report by right click on the report solution and select deploy solution to deploy the SSRS report on report server.

Create a new output menu item, and name it RDPBasedReport. Set its properties as shown below:

image

Now right click on the menu item and select Open to launch the SSRS report we have just developed. The report output should match with the below screen shot:

image

Developing Query Based SSRS reports using VS – AX 2012

1- Developing a new SSRS report:

Before start developing SSRS reports for Dynamics AX, you must have installed BI Components and Visual Studio tools from AX setup. After installation of both these additional components, open Visual Studio, click on File -> New Project. New Project dialog is open as shown below:image

From the above dialog select Microsoft Dynamics AX in Project types and select Report Model under templates section. The SSRS reports needs a data source from where the report can grab the data and displayed it on the report. There are three types of data source available to be used in SSRS report which is as follows:

  • Query
  • RDP (Report data provider).
  • Business Logic.

When you use query as a data source type for SSRS report then the report is called Query based report. Now, I am going to explain you that how we develop SSRS reports based on Query.

2. Developing Query Based SSRS reports using VS

Before you can start developing query based reports in VS, you need an AOT query to be created in Dynamics AX. Suppose you want to show all the records form CustTable table in an SSRS report. This can be achieved through query based report. Create an AOT query in Dynamics AX as shown below:

image

The Query name is SampleQuery. Add CustTable under the data sources node of the query. All the fields of the CustTable are included in the AOT query. Now you need to create an SSRS report which used this query as a data source and display all the fields of CustTable on SSRS report. Open Visual Studio and goto File -> New Project. New Project dialog form will be opened as shown below:

image

Select Microsoft Dynamics AX under Project types and Report Model under Templates section. Specify the name of the report as ‘QueryBasedReporrt’ and press OK button. A new SSRS project will be created as shown below:

image

Now you need to add a report under the above project. Right click on the project, select Add and then select Report. A report will be added to the project with the name Report1. Change the report name to QueryBasedReport. Now the solution explorer should look like as shown below:

image

Double click on the newly created report. You will see report items on the left side in Visual Studio as shown in the below screen shot:

image

The purpose of each report items is described below:

Ø Datasets: The report dataset retrieves data from the AOT query. All fields which are available in AOT query are shown in the report dataset which can be referred in the report design later on.

Ø Designs: The design or layout of the report on which the data would be displayed after retrieving from AX.

Ø Images: Any embedded images that you want to display on SSRS report.

Ø Data Methods: Business logic written in C#. Data methods are no more recommended.

Ø Parameters: Report parameters which are to be displayed on SSRS report and user can filter the report based on those parameters.

You first need to create a dataset that will refer to an AOT query created earlier. Right click on Datasets node and click ‘Add Dataset’. A dataset will be created with name ‘DataSet1’. Rename it to ‘QueryBasedReportDS’. The newly created dataset should refer to the AOT query from where the data can be picked. Right click on the newly created dataset and select ‘Properties’. Set the data source type to ‘Query’ and click on the ‘Query’ property. An ellipses button appears, click on it. A new window will open which shows the entire AOT queries present in Dynamics AX. Select the query ‘SampleQuery’ which you have created earlier as shown below:

image

Select All Fields from the right column to show all fields on the report dataset and then click ‘OK’ button. All the fields which are added on AOT query are now showing on the report dataset. You can see all the fields by expanding the Fields node under the dataset. You can refer to any of these fields on the report design. Now we have created a dataset which provides the data to the report, the next step is to create a report design.

There are two types of report designs available in SSRS report i.e. AutoDesign and PrecisionDesign. First preference when developing reports is to use AutoDesign unless you need a custom placement of fields in a report and in that case you have to use PrecisionDesign. Generally for complex report designs, we use PrecisionDesign. For the sake of simplicity, we will use AutoDesign here for our first SSRS report.

Right click on the Designs node, click on Add-> AutoDesign. An auto design is created with the name AutoDesign1. Change its name to ‘Report’ by right clicking on the AutoDesign1 and click Rename. It is recommended that you set the name of the Design to either ‘Design’ or ‘Report’. Now drag the data set of the report ‘QueryBasedReportDS’ on Report Design named ‘Report’. A table will be created which contains all the fields that are shown in the report dataset. The value of these fields will be shown on the report output in the same order as it is showing in the data table. The final report design should look like as shown below:

image

Now we execute the report to see the output. The records will be fetched from Customer table so make sure that the CustTable has some records in it before opening the report otherwise a blank output will be shown. There are three ways of opening an SSRS report which are as follows:

1) From Visual Studio which is actually the preview of the report.

2) From Browser by opening the URL http://localhost/reports.

3) From Dynamics AX through output menu item.

2.1. Previewing SSRS reports from Visual Studio

You can easily preview SSRS reports by right clicking on the design and select Preview option. For our example right click on the Design ‘Report’ and select Preview as shown in the below screen shot:

image

A separate preview page is open which will show the report output. If your report has some parameters then the parameters will be shown first and then the output will be shown based on the values of the parameters. Following report output will be shown when you preview the report from VS:

image

2.2. Viewing SSRS report on browser

Before viewing report on browser you need to deploy report on the report server. You can deploy SSRS reports in two ways, first way is to right click the solution in Visual Studio and select deploy solution option and the second way is to go to SSRS Reports/Reports node under AOT, right click on the report you want to deploy and then select Deploy. To deploy SSRS report from AX, you need to first add the report project to AOT. Following screen shot shows how to do this:

image

Now right click the report solution in VS and select deploy solution as shown below:

image

To view SSRS report from browser, go to URL http://localhost/reports. When the page is open you will see the Dynamics folder link shown on the page. By clicking on the Dynamics folder you can see the list of all SSRS reports deployed on the report server as shown below:

image

Click on the report which you want to preview on browser. In our case, click on the SSRS report QueryBasedReport.Report to view it on browser. Following output will be shown when you view the report from browser:

image

Opening SSRS report from AX

To open SSRS report from AX, you first need to create an output menu item which refers to the SSRS report you have created earlier. Below screen shot shows how to do this:

image

Step 1: Create an output menu item Step 2: Set the object type and object properties as shown in the above screen shot.

Now right click on the output menu item QueryBasedReport and select Open to launch the report. Following output will be shown when you run the report from AX:

image

2.3. Filtering a report with an specific parameter

Suppose you want to filter the report we have developed earlier by customer group. In that case you need to show the parameter customer group on the report dialog so that user can run the report for a specific customer group. Steps are shown below:

image             image

Step 1: Adding range in a report query. Step 2: Add CustGroup field under the Ranges node.

Now compile the query ‘SampleQuery’ to save the changes. Run the report by right clicking the output menu item and select Open. Following report dialog will be shown:

image

You can see the customer group parameter in the above dialog which we have added through report query. Another parameter customer account is shown on the above dialog. Just ignore this parameter, it is showing here because this field is the part of unique index on CustTable. Now click on the select button to specify a value for customer group parameter shown above. Following screen shot will be shown:

image

Select the customer group 30 and click OK button. Customer group 30 will be shown selected on the report dialog as shown below:

image

Again click the OK button on the report dialog to open the report filtered by customer group 30. Following output will be shown:

image

As you can see that, only those records are shown, which have customer group 30. In the same way you can apply as many filters as you want on the report AOT query to filter the report based on that field’s value.

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers:

error: Content is protected !!