SQL Server Reporting Services - Microsoft Dynamics
SQL Server Reporting ServicesObjectivesThe objectives are:Describe the installation procedure and prerequisites.Identify the tools that are used to develop and deploy reports for Microsoft Dynamics? AX 2012.Explain the process for developing reports by using Visual Studio.Review the three options to deploy reports.Describe how SSRS reports can be used within Microsoft Dynamics AX 2012.IntroductionSQL Server Reporting Services (SSRS) is the primary framework for developing reports in Microsoft Dynamics AX 2012. The installation requirements include completing tasks such as verifying prerequisite components are installed, completing the installation setup wizard and deploying default reports. With SSRS, users can develop and deploy reports and integrate reports with Microsoft Dynamics AX 2012.SSRS provides data that can be displayed in many different clients including: Microsoft Dynamics AX clients, Enterprise Portal, and batch jobs.Figure 2.1 Microsoft Dynamics AX 2012 Reporting FrameworkUsing SSRS with Microsoft Dynamics AX 2012 provides users professional-looking reports, more export formats, and a more capable report designer. When you use SSRS for developing Microsoft Dynamics AX 2012 reports it results in the following benefits:Increased use of the Microsoft technology stack Business logic is kept in Microsoft Dynamics AX 2012 Smooth transition for X++ and C# developers to the new reporting architecture All the standard reports that are provided with Microsoft Dynamics AX 2012 use the SSRS reporting framework. When you upgrade from an earlier version of Microsoft Dynamics AX, legacy reports and cubes are not upgraded. Reports that use the X++ reporting framework and existing SQL Server Reporting Services reports will be copied to the Microsoft Dynamics AX 2012 system. However, they will not be upgraded. InstallationMicrosoft SQL Server Reporting Services (SSRS) is installed as part of the SQL Server installation. Microsoft Dynamics AX 2012 employs Reporting Services Extensions to make use of SSRS capabilities. The Reporting Services Extensions are installed and configured as part of the Business Intelligence installation during the Microsoft Dynamics AX 2012 installation. Refer to the Microsoft Dynamics AX 2012 Installation Guide for more information. The Business Intelligence components can be installed separately if they were not installed during the Microsoft Dynamics AX 2012 installation.PrerequisitesBefore you install the Business Intelligence components, check that the prerequisites are met. Run the Microsoft Dynamics AX prerequisite validation utility to determine whether a computer meets the requirements to install a Microsoft Dynamics AX component. Specific requirements for installing Reporting Services extensions include the following:Microsoft SQL Server 2008 Reporting Services Microsoft SQL Server 2008 R2, Cumulative Update 3 or a later version Windows PowerShell 2.0 Refer to the Microsoft Dynamics AX 2012 System Requirements document for more information.To install the Reporting Services Extensions, you must be a member of the System administrator role in Microsoft Dynamics AX. Reporting Services extensions must be installed on the computer that is running SSRS.InstallationTo install the Business Intelligence components, run the Microsoft Dynamics AX 2012 setup. Refer to the Microsoft Dynamics AX 2012 Installation Guide for more information. The installation setup wizard will perform the following actions:Verify that prerequisite software is installed on the server Install SQL Server Reporting Services extensions Deploy the default reports that are included with Microsoft Dynamics AX 2012 Configure SQL Server Analysis Services If the default reports are not deployed during the installation, they can be deployed later using Windows PowerShell. Deploy Default ReportsMicrosoft Dynamics AX 2012 includes default reports that must be deployed to Microsoft SQL Server before they can be used. The default reports can be deployed during the Reporting services installation by using the Microsoft Dynamics AX 2012 setup.If you did not deploy the reports when you installed the Reporting Services extensions, you can deploy them by using Windows PowerShell. The following procedures can help you deploy the reports:Open PowerShell and view a list of reports Filter the list of reports Deploy the reports Open PowerShell and View a List of ReportsComplete the following procedure to open PowerShell and view a list of the reports that are included with Microsoft Dynamics AX 2012.Open PowerShell as an administrator by clicking Start > Administrative Tools. Right-click the Microsoft Dynamics AX 2012 Management Shell option. Click Run as administrator. Retrieve default reports that are included with Microsoft Dynamics AX, and store the list in a local variable using the following command: $reports = Get-AXReport -ReportName * View the list of reports by entering the following command: $reportsFigure 2.2 Windows PowerShellFilter the List of ReportsTo modify and filter the list of default reports use the following commands:To modify the list so that only the Name and ChangedDate fields are displayed, enter the following command: $reports | Select-Object Name,ChangedDate To filter the list so that only specific reports are listed, enter keywords or report names. For example, to filter the list so that only reports that contain the word CustTrans are listed, enter the following command: $reports | Select-Object Name,ChangedDate | Where { $_.Name -like "CustTrans*" } Deploy the ReportsAfter you have retrieved a list of reports, you can deploy them. The Publish-AXReport command is used to deploy the reports. The following examples show how to use this command:To deploy a specific report, enter the name of the report. For example, to deploy the CustTransList report, enter the following command: Publish-AXReport -ReportName CustTransList To deploy two or more specific reports, enter the names of the reports. For example, to deploy the CustTransList and CustTransOpenPerDate reports, enter the following command: Publish-AXReport -ReportName CustTransList, CustTransOpenPerDate To deploy all reports, enter the following command: Publish-AXReport -ReportName * Report Development ToolsSeveral tools are available to help you create reports, configure data sources, and deploy and display report data in Microsoft Dynamics AX 2012. Integration between these tools makes report development more streamlined than ever and reduces the time that is required to create and modify reports.MorphX and the Application Object TreeMorphX is the integrated development environment that is included in Microsoft Dynamics AX 2012. The programming language X++ is used within the MorphX development environment. X++ is an object-oriented programming language that is used to develop the objects that are used in the Microsoft Dynamics AX application. The Application Object Tree (AOT) holds all the application objects that are used to build Microsoft Dynamics AX. The AOT contains objects that will be used to collect data for a report and objects that give users access to display reports.The objects in the AOT are grouped into nodes according to their type. The AOT objects include: Tables - made of fields that contain business data Views - grouped data from multiple tables Classes - source code for application logic Visual Studio Projects - report definitions copied from Visual Studio Queries - select data to display in a form or in a report Menu items - used to access reports and forms Menus - groups of menu items Other objects in the AOT are used to manage application processes and for various other functions. When you develop a report, objects from the AOT will be used to access data and to display the reports.Visual StudioMicrosoft Visual Studio is an integrated development environment that is used to develop applications. Development in Visual Studio can be done using Visual Basic, Visual C#, Visual C++, and other programming languages. Whereas many development tasks in Microsoft Dynamics AX 2012 can be completed by using X++ in the MorphX development environment or the Visual Studio development environment, report development can only be done in Visual Studio.Visual Studio consists of several features that support development of Microsoft Dynamics AX applications. Visual Studio Tools for Microsoft Dynamics AX is a collection of tools and functionality that allow you to manage code development for Microsoft Dynamics AX. Visual Studio Tools integrates Microsoft Dynamics AX with Visual Studio. Objects that are developed in Visual Studio can be saved to the AOT and AOT objects can be used in Visual Studio development projects.Figure 2.3 Visual StudioApplication Explorer is a tool in Visual Studio that provides a view into the AOT in Microsoft Dynamics AX. In Application Explorer, you can view and debug X++ code in the AOT.Solution Explorer displays a collection of items for a specific solution. A solution contains one or more projects, and a project contains one or more items. From Solution Explorer, you can open files for editing, add new files to a project, and view solution, project, and item properties.SQL Server Reporting ServicesSQL Server Reporting Services (SSRS) provides tools and services to help you create, deploy, and manage reports. SSRS also provides programming features that allow you to extend and customize your reporting functionality. Reporting Services is a server-based reporting platform that provides comprehensive reporting functionality for a variety of data sources. Reporting Services includes a complete set of tools for you to create, manage, and deliver reports, and provides APIs that enable developers to integrate or extend data and report processing in custom applications. Reporting Services tools work within the Microsoft Visual Studio environment and are fully integrated with SQL Server tools and components.With Reporting Services, you can create interactive, tabular, graphical, or free-form reports from relational, multidimensional, or XML-based data sources. You can publish reports or access reports on demand. Reporting Services also enables you to create customized reports based on predefined models, and to interactively explore data within the model. Additionally, you can select from a variety of viewing formats or export reports to other applications. The reports that you create can be viewed over a web-based connection or as part of a Microsoft Windows application or SharePoint site. SQL Server Analysis ServicesMicrosoft SQL Server Analysis Services (SSAS) delivers online analytical processing (OLAP) and data mining functionality for business intelligence applications. Analysis Services supports OLAP by letting you design, create, and manage multidimensional structures that contain data that is aggregated from other data sources, such as relational databases. For data mining applications, Analysis Services lets you design, create, and visualize data mining models that are constructed from other data sources by using a wide variety of industry-standard data mining algorithmsAnalysis Services helps you analyze large quantities of data. With it, you can design, create, and manage cubes that contain detail and aggregated data from multiple data sources. For more information, see Chapter 3: SQL Server Analysis Services of this manual. Business Intelligence Development StudioBusiness Intelligence Development Studio is Microsoft Visual Studio 2008 with additional project types that are specific to SQL Server business intelligence. Business Intelligence Development Studio is the primary environment that you will use to develop business solutions that include Analysis Services and Integration Services projects. Each project type supplies templates for creating the objects that are required for business intelligence solutions, and provides a variety of designers, tools, and wizards to work with the objects.Develop ReportsAll reports in Microsoft Dynamics AX 2012 are developed by using Visual Studio. Default reports that are installed with Microsoft Dynamics AX 2012 can be customized and new reports can be created by using Visual Studio. Create New ReportsTo create a new report, you must create a report project in Visual Studio, add a new report and report design to the project, and then define data and parameters. The report project is then imported in to Microsoft Dynamics AX 2012 and then the report is deployed to the Report Server. A menu item can then be created to launch the report, or the report can be added to a Role Center or Enterprise Portal web part.Create a Reporting ProjectTo create a new report, begin by creating a new reporting project in Visual Studio. Follow these steps to create a new reporting project:In Visual Studio, select File > New > Project from the menu. Select Microsoft Dynamics AX for the project template type and then select the report model template. Enter a project and solution name. Verify the path for the location where the project file will be saved. Click OK.Figure 2.4 Visual Studio New Project Dialog BoxTo add a new report to the project, select the Project in Solution Explorer in Visual Studio. Right-click the project and select Add > Report.Instead of creating a new Reporting Project, you might want to use an existing, pre-defined Reporting Project. Follow these steps to add an existing Reporting Project from another solution:Select the solution in Solution Explorer in Visual Studio. Right-click the solution and then click Add > Existing Project. Select the reporting project to add, and then click Open. When you add an existing reporting project from another solution, the project files are not copied to the directory that contains the files for the solution. Instead, the project files from the original solution are used. You can also add an existing report from the AOT that is displayed in the Application Manager in Visual Studio. Follow these steps to add an existing report to the current project: In Visual Studio, open a solution and select a project in the Solution Explorer. In Application Explorer, expand the SSRS Reports node and then expand the Reports node. Find the report that you want to add to the project. Right-click the report and select Add to Project. The report is added to the current project. Define a Data SourceTo add data for your reports, a data source must be added to the report project. An existing data source is used to connect to the Microsoft Dynamics AX 2012 application database. When the predefined Microsoft Dynamics AX data source is used, all data access requests go through the MorphX security system. If you want to use a database other than the Microsoft Dynamics AX 2012 application database, you must define a new data source to specify connection information and a provider type for that database. Follow these steps to define a report data source:In Visual Studio Solution Explorer, right-click the reporting project that you want to add a report data source to, select Add, and then click Report Data source. This is a model that contains a single report data source. Type a name for the model. The file name extension of a model is .moxl.Figure 2.5 Add New Data Source in Visual StudioDefine a DatasetA report dataset selects data from the data source to be displayed in a report. You can use a query, stored procedure, enum, or a data method to select data. Double-click the report in the project in Visual Studio Solution Explorer to open the report in the Model Editor. In the Model Editor, expand the node for the report that you want to work with. Right-click the Datasets node, and then click Add Dataset. Select the node for the dataset. In the Properties window, set the following properties. Data Source - Select the Microsoft Dynamics AX data source, or a new data source that was created. Data Source Type - Select the type of data source that you will use to select data. If the existing Microsoft Dynamics AX data source is selected, you can choose from the following: Query - use a query from the AOT Business Logic - use a data method from the report project Report Data Provider - use the results of an X++ class AX Enum Provider - use an enum from the AOT Name - Enter a name for the dataset. Query - Select a query, method, class or enum to use to retrieve the data from the data source. Default Layout - default layout to be used for Auto Design reports. Dynamic Filters - enables filters to be used in the report dialog.Figure 2.6 Dataset Properties in Visual StudioDefine a Data RegionA data region is an area in a report that displays data from a dataset. To add a data region to an auto design report, drag a dataset onto a report design. A data region can also be added manually. Follow these steps to add a data region to an auto design report:In the Visual Studio Model Editor, select the dataset for the report where you want to create a data region. In the Properties window, verify the appropriate Default Layout property is selected. To create a new auto design, drag the dataset onto the Designs node for the report. To add the data region to an existing auto design, drag the dataset onto the node for the auto design. A node for the data region is created under the Designs node. Select the new data region. In the Properties window, specify a style template. Preview the report to verify the data region is correct. Right-click the design and select Preview. Follow these steps to manually add a data region:In the Visual Studio Model Editor, select the auto design for the report that you want to create a data region. Right-click the auto design, click Add, and select a data region type. Select from: List, Matrix, Pie or Doughnut Chart, Table, or XY Chart. Select the new data region. In the Properties window, specify a dataset and a style template. Preview the report to verify the data region is correct. Right-click the design and select Preview. Define a Report FilterFilters are used to filter data that is displayed in a report. Set ranges can be defined to filter data on a report. If the Dynamic Filter property on the dataset is set to True, the report user will identify the ranges when he or she views the report. If the Dynamic Filter property on the dataset is set to False, the report developer must specify the data ranges. Use the following procedure manually define a filter for a data region:In the Visual Studio Model Editor, select the design to modify in the Design node under the report to edit. Expand the node for the auto design to view its data regions. Select the Filter node under the data region. Right-click the Filters node, and then click Add Filter. Select the new filter and specify the following properties: Expression - select an expression or select <Expression...> to open an Edit Expression dialog box Name - enter a name for the expression Operator - select an operator for the expression Value - enter a value for the filterFigure 2.7 Report Filter PropertiesDefine a Sorted Data RangeTo control the sort order in a report data region, define a sort order. A sort order is set when the report is built. For example, you might want to display customer data alphabetically by last name or numerically by account number. To sort data in a data region:In the Visual Studio Model Editor, select the data region in the design node for the report to sort. To define a sort order outside a grouping, right-click the Sorting node, and then click Add Sort. To define a sort order within a grouping expand the node for the grouping, right-click the Sorting node, and then click Add Sort. Select the new sort order. In the Properties window, specify the following properties: Name - name for the sort Sort By - select an expression or select <Expression...> to open an Edit Expression dialog box Sort Order - select Ascending or DescendingFigure 2.8 Report Sort Order PropertiesDisplay Images in a ReportSeveral scenarios are available that allow you to display images in a report. Some reports can include a specific image for each record in the report, whereas others might include a few standard images that are used each time the report is used. The following are ways to reference an image in a report:Embedded - the image is added directly to the reporting project External - the image is store outside the project, referenced by a URL Database - the image is stored with a record in the database External images can only be used for Precision Reports. Precision Reports are developed using SQL Report Designer to allow for precise layouts, such as for invoices or checks. The following procedure shows how to add an embedded image: To add an image and make it available to all reports in the model, select Image from the Add Element drop-down menu on the toolbar of the Visual Studio Model Editor. To add the image directly to a report, right-click the desired report, click Add, and then click Image. When you add an image directly to a report, it is available to that report only. Select the new image node. In the Properties window select the image file in the Image Source field. Valid file types for image files are: .bmp, .gif, .jpeg, .png, and .xpng. Build a Reporting ProjectAfter the report is developed, the reporting project needs to be built. When you build a reporting project, the report is updated in the model store. Projects with business logic will build the assembly and add it to the output path for the project. You can build a solution or a project. When you build a solution, all projects in the solution are built. When you build a project, the project and any nested projects are built. To build a solution by using Microsoft Visual Studio, in Solution Explorer, right-click the solution, and then click Build Solution. To build a project using Microsoft Visual Studio, in Solution Explorer, right-click the project, and then click Build. Edit Existing ReportsWhen a specific report is being developed, there is often an existing report that will meet many of the report requirements. The existing report can be modified to add fields, change parameters or change the report layout. When reports in Microsoft Dynamics AX 2012 are modified, changes are stored in the development layer in the MorphX development environment that the developer is logged into. A copy of the reporting project is created and opened in Microsoft Visual Studio where it can be edited and then imported back into the AOT in the layer that the developer is currently working in. Before making changes to a report, make sure that you are working in the correct development layer. Follow these steps to edit an existing report: In the AOT, open Visual Studio Projects and then open Microsoft Dynamics AX Model Projects. Find the project that contains the report to edit, right-click the project and then click Edit. This opens the project in Visual Studio. In the project in Visual Studio, use the Solution Explorer to find the report to edit. Double-click the report to open the report in Model Editor. Use the Model Editor to make changes to the report data, parameters or design.Figure 2.9 Visual Studio Model EditorTo preview the report changes, expand the Designs node for the report. Right-click the design that you want to preview, and then click Preview. After the report is modified in Visual Studio, the report project can be imported back into Microsoft Dynamics AX 2012. Follow the procedure that is described in the "Integrate SSRS with Microsoft Dynamics AX 2012" lesson of this manual to import a Report Project into Microsoft Dynamics AX 2012.Deploy ReportsAfter a report is developed in Visual Studio, it must be deployed to the SQL Reporting Server to be used. Reports can be deployed from Visual Studio, from the AOT, or by using Windows PowerShell. When a report is deployed, the following occurs: The Report Definition Language (RDL) is uploaded to Reporting Services. The business logic assemblies are copied to the Reporting Services server. Any reports and business logic assemblies that are referenced in the report are verified. Deploy Reports with Visual StudioIf a new report is developed in Visual Studio, the report can be deployed directly from Visual Studio. In the Visual Studio Solution Explorer, right-click the reporting project that contains the reports that you want to deploy and then click Deploy. Reports are deployed for the neutral language only. Deploy Reports with Microsoft Dynamics AX 2012 Development WorkspaceExisting reports in Microsoft Dynamics AX 2012 can be re-deployed if needed. If changes are made to a report, or new reports are developed and imported into Microsoft Dynamics AX 2012, they will need to be deployed before they can be used. The following procedure outlines how to deploy reports from Microsoft Dynamics AX 2012:Press SHIFT+CTRL+W to open the development workspace. In the AOT, expand the SSRS Reports node. Expand the Reports node. Right-click the report that you want to deploy, and then click Deploy Element.Figure 2.10 Deploy Reports from AOTDeploy Reports with Windows PowerShellTo deploy reports using Windows PowerShell, follow the procedure listed in the "Installation" lesson of this manual.Integrate SSRS with Microsoft Dynamics AX 2012After reports are created in Visual Studio 2010 and deployed to SSRS, users must be able to view them. An advantage of reports that are built in Visual Studio is that they are very flexible in the formats in which they can be rendered. While paper reports are still necessary for some occasions, publishing reports digitally, or making reports available for subscription, is becoming a widely popular alternative.Import a Report Project to Microsoft Dynamics AX 2012Before a new report can used in Microsoft Dynamics AX 2012, it must be imported from Visual Studio. To import report projects to Microsoft Dynamics AX 2012, right-click the reporting project in the Visual Studio Solution Explorer, and then click Add Report to AOT. Create a Menu ItemAfter the report is imported to Microsoft Dynamics AX 2012, a menu item can be created to provide access to the reports. An output menu item is created from the Menu Items node in the AOT and references the imported report. Follow these steps to create a menu item for a report:1. In the AOT, expand the Menu Items node.2. Right-click the Output node, and click New Menu Item.3. Select the new menu item.4. In the Properties window enter a name of the report menu item, enter a label for the report title, set the ObjectType property to SQLReportLibraryReport, and then select the report from the drop-down menu for the Object property.Figure 2.11 Microsoft Dynamics AX 2012 AOT Menu Item PropertiesAdd a Report to a Role Center PageThe Microsoft Dynamics AX report web part is used to display reports in Role Centers and the Enterprise Portal. There are two options for Role Center modifications: a user-specific personalization, called the Personal Version, or a modification by the administrator, called the Shared Version, that can be viewed by all users with that role center profile.When the Role Center is displayed as the Home page in the Microsoft Dynamics AX client, the user can make personal modifications to the role center for their own use only. To do that, the user clicks "Personalize this page". This displays the SharePoint personal version of the page. In the Infolog Web Part, a message informs the user that "You are editing the Personal Version of this page". The user can click "Add a Web Part" to add a new report web part to any region of the page. When the Role Center is displayed in the Enterprise Portal, an administrator can click "Site Actions" and select "Edit Page". This displays the SharePoint shared version of the page. The Administrator can click "Add a Web Part" to add a new report web part to any region of the page.In both cases, there is a region displayed that is labeled "Categories" that contains a link to the "Microsoft Dynamics AX" web parts. When that link is selected, the adjacent "Web Parts" region, displays all the options available. Use the right arrow to scroll down through the list to find the Report web part. In the "About the Web Part" region, the drop-down list labeled "Add Web Part to:" allows the user to select the region of the page. Click the Add button. The following step show how to choose the specific report to display for the web part: Under the label "Microsoft Dynamics AX report" a message is displayed providing an instruction. Click on the unlabeled down arrow in the upper-right above the message. Choose "Edit Web Part" if you are editing the Shared View. Choose "Edit My Web Part" if you are editing a Personal View. This displays the properties pane as a vertical pane in the rightmost part of the SharePoint page. In the properties of the web part, choose the desired report from the list displayed under "Select a report". If the SSRS report uses parameters, you can see what parameter values can be set for the report under the "Report parameters" section of the properties. Under the Report toolbar section of the properties, you can specify the Toolbar Size property to indicate whether a toolbar should be displayed for the web part. Under the "Appearance" section of the properties, enter an appropriate title for the report. This title will be displayed in the Microsoft Dynamics AX Report Server Report web part. Set the Width and Height properties to the desired values. Batch IntegrationReports can be printed using a batch job to print on a recurring schedule, or to print during off hours. To print a specific report on a recurring basis: Click the menu item for the report that you want to print. Enter parameters in the print dialog form. Click the Destinations button to display the Print destination settings form. Select a print destination. Click the Batch tab. Select the Batch processing check box. Enter a task description. Select the batch group that this batch job will be a part of. Click Recurrence to display the Recurrence form. Specify how often you want the report to be printed. Then click OK to close the Recurrence form. Click Alerts. Specify how and when you want to receive alerts for the batch job. Click OK to close the form. Click OK to print the report to the selected destination on a recurring basis.Figure 2.12 Microsoft Dynamics AX 2012 Report Batch SetupLab 2.1 - Create a Simple ReportThis lab will focus on how to develop a simple report. Topics include using free text and query bound report parameters, sorting and filtering report data, and applying report templates to produce uniform views of Microsoft Dynamics AX data.ScenarioIsaac, the Developer, wants to create an SSRS report to expose customer transaction data.Challenge Yourself!Use the provided information to create a query bound report that exposes Customer Transaction data. Need a Little Help?Create a Microsoft Dynamics AX Query Add field data to the Query. Create a new report model in Visual Studio. Create a report data set. Create a report design. Apply Style Templates. Save and deploy the report. View the report in Microsoft Dynamics AX 2012. Step by Step: Create an AX QueryOpen Microsoft Dynamics AX. Press Ctrl+Shift+W to enter the development environment. In the AOT, right-click the Queries node, and then click New Query. Right-click the node for the query, click Rename, and then type "CustTrans_W1". Expand the CustTrans_W1 node. Right-click the Data Dictionary node, and then click Open New Window. In the new window, expand the Tables node. Locate the CustTrans table and drag it onto the Data Sources node for the CustTrans_W1 query. Expand the CustTrans_1 Data Source node. Select and drag the following fields from the Fields node under CustTrans table to the Field node under CustTrans_1 data source: AccountNum AmountMST TransDate TransType Txt Right-click the Fields node of the query, click Properties. Set the Dynamic property to No so fields can be removed from the view. Save the query.Figure 2.13 Microsoft Dynamics AX 2012 Dataset FieldsStep by Step: Create a New Report in Visual StudioOpen Microsoft Visual Studio. If Visual Studio is run for the first time, select General Development Settings for the default environment setting and click Start Visual Studio. On the File menu, point to New, and then click Project. The New Project dialog box is displayed. In the Installed Templates pane, click the Microsoft Dynamics AX node, and in the Templates pane, click Report Model. In the Name box type SSRSDemo, and in the Location box, type a file path. Click OK. In Solution Explorer, select the SSRSDemo project, right-click, select Add and click Report. An empty report model named Report1 is created. In Model Editor, right-click the Report1 node and then click Rename. Type "CustTransList_WS1" as the name. Expand the CustTransList_WS1 node if it is not already expanded. Right-click the Datasets node and then click Add Dataset. Select the node for the dataset. In the Properties window, specify the following properties. Data Source: Dynamics AX Data Source Type: Query Name: CustTransListDS Query: Select * from CustTrans_W1 (or use the ellipsis button to use the wizard to select the query and choose the desired fields to display).Figure 2.14 Visual Studio Dataset PropertiesIn Model Editor, select the CustTransListDS node and drag it onto the Designs node. An auto design named AutoDesign1 is created for the report. Step by Step: Apply Layout TemplateIn Model Editor, select the AutoDesign1 node. In the Properties window, set the Layout Template property to "ReportLayoutStyleTemplate". Also, type "Customer Transaction List" for the Title property. In Model Editor, expand the AutoDesign1 node, and then select the node for the CustTransListDSTable. In the Properties window, set the Style Template property to TableStyleTemplate. Step by Step: Add Column SortingIn Model Editor, expand the AutoDesign1 node, and then select the Sorting node under the CustTransListTable data region. Right-click the Sorting node and then click Add Sort. Type AccountNum as the name. In the Properties window, set the Sort By property to =Fields!AccountNum.Value. Save the report. In Model Editor, expand the AutoDesign1 node, and then select the AccountNum field under the Data node. In the Properties window, set the Interactive sorting property to "True". Repeat this step for the AmountMST, TransDate, and TransType1 columns. Save the report. Step by Step: Group Report DataIn Model Editor, expand the AutoDesign1 node. Right-click the Groupings node under the CustTransListTable data region, and then click Add Grouping. Type Group1 as the name. In the Properties window, set the Label property to "=Fields!AccountNum.Value".Figure 2.15 Visual Studio Group PropertiesRight-click the Group on node, and then click Add Group on. Type "AccountNum" as the name. In the Properties window, set the Expression property to "=Fields!AccountNum.Value". In Model Editor, expand the AutoDesign1 node, and then select the AccountNum field under the Data region. Right-click the Group1 node and then click Properties. In the Properties window, expand the Instance Aggregates, and set Render Location to "GroupFooter". Select the AmountMST field under the Data node. In the Properties window, expand the Aggregation item, and set Aggregate Function to "Sum". Step by Step: Filter Report DataOpen Microsoft Dynamics AX. In the AOT, expand the Queries node, and then locate the CustTrans_W1 query. Expand the CustTrans_W1 node and expand the Data Sources node. Right-click the Ranges node and then click New Range. A default range using the AccountNum field is created for you by AX. Save the query. In Visual Studio Model Editor, select the CustTransListDS node. Right-click the node and select Refresh to reflect changes that you make to the AX Query. Expand the Parameters node for the report (that is not the Parameters node for the dataset) to display the list of report parameters. Right-click the node and select Add > Parameter. Type "AccountParam" as the name. In the Properties window, enter Account for the Prompt String property. Save the report. In Model Editor, expand the nodes of AutoDesign1 to see the Filters node. Right-click the Filters node and select Add Filter. Type "AccountFilter" as the name. Set the following properties in the Properties window Expression: =FieldsAccountNum.Value Operator: Like Value: =Parameters!AccountParam.Value Save the report. Step by Step: Add a Dynamic ParameterOpen Microsoft Dynamics AX. Press Ctrl+Shift+W to enter the development environment. In the AOT, right-click the Queries node and then click New Query. Rename the query to CustTable_W1. Expand the CustTable_W1 node. Locate the CustTable table and drag it onto the Data Sources node for the CustTable_W1 query. Locate the AccountNum field under CustTable and drag to the Fields node under the CustTrans_W1 Data Source node. Save the query. In Model Editor, right-click the Datasets node, and then click Add Dataset. Type "CustomersDS" as the name. Select the node for the dataset. In the Properties window, set the following properties. Data Source: Dynamics AX Data Source Type: Query Default Layout: Table Name: CustomersDS Query: Select * from CustTable_W1 In Model Editor, select the AutoDesign1 node. Expand the Parameters node to display the list of report parameters. Select the AccountParam node. In the Properties window, click the button in the Values property. Select From Dataset option button and set the following properties: Dataset: CustomersDS Value Field: AccountNum Label Field: AccountNum Click OK. Save the report. Step by Step: Save and Deploy the ReportRight-click the SSRSDemo project in Solution Explorer, and select Rebuild. Verify that you have no build errors. Right-click the SSRSDemo project in Solution Explorer, and select Add SSRSDemo to AOT. Verify that you can add to the AOT. Right-click the SSRSDemo project in Solution Explorer, and select Deploy. Navigate to the Report Manager to view the report. Step by Step: View the Report in Microsoft Dynamics AXOpen Microsoft Dynamics AX. In the AOT, expand the Menu Items node and select the Output node. Right-click the Output node and then click New Menu Item. Type "CustTransList_WS1" as the name. Right-click the CustTransList_WS1 and select Properties set the following: Object Type: SSRSReport Object: CustTransList_WS1 Label Field: AutoDesign1 Save the AX Menu Item. Right-click the CustTransList_WS1 menu item and select Open. Lab 2.2: Create a Report with X++ Business LogicIn this lab you will 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.ScenarioDevelop a report to display customer data with parameters for account number, account statement and whether to include tax.Challenge Yourself!Use the information that is provided in the scenario to develop the report.Need a Little Help?Create a temporary table Define a report data provider class Define the report parameters Define a method to return data to Reporting Services Add business logic for the report Create a reporting project Bind a report to a report data provider class Step by Step: Create a Temporary TableOpen Microsoft Dynamics AX. Press Ctrl+Shift+W to enter the development environment. In the AOT, expand the Data Dictionary node, right-click the Tables node, and then click New Table. Right-click the table and click Properties. 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. Expand the node next to the TmpCustTableSample table so that you can see the Fields node. Press Ctrl+D to open another AOT window and move the window so that you can see both AOT windows. In the second AOT, expand the Data Dictionary node, expand the Extended Data Types node, and drag the following types to the Fields node in the first AOT window: AccountNum CustName LogisticsAddressing CustGroupID Phone CustInvoiceAccount Action Days 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. Step by Step: Define a Report Provider ClassIn the AOT, right-click the Classes node, and then click New Class. Right-click the new class, click Rename, and then enter "SrsRDPSampleClass". Expand SrsRDPSampleClass, right-click classDeclaration, and then click View Code. In the code editor, edit the class so that it contains the following code.[SRSReportQueryAttribute (querystr(Cust)),SRSReportParameterAttribute(classstr(SrsRDPContractSample))]public class SrsRdpSampleClass extends SRSReportDataProviderBase{TmpCustTableSample tmpCust;} Save the class and close the editor. Step by Step: Define a Data Contract ClassIn the AOT, right-click the Classes node, and then select New Class. Right-click the new class, click Rename, and then enter "SrsRDPContractSample". Expand SrsRDPContractSample, right-click classDeclaration, and then click View Code. In code editor, enter the following code in the class declaration to define the class.[DataContractAttribute]public class SrsRDPContractSample{AccountNum accountNum;CustAccountStatement accountStmt;Boolean inclTax;} Save the class and close the editor. Step by Step: Define a Data Contract MethodRight-click SrsRDPContractSample, point to New, and then click Method. Edit the method so that it contains the following code.[DataMemberAttribute("AccountNum")]public AccountNum parmAccountNum(AccountNum _accountNum = accountNum){accountNum = _accountNum;return accountNum;} Save the method and close the editor. Right-click SrsRDPContractSample, point to New, and then click Method. Edit the method so that it contains the following code.[DataMemberAttribute("CustAccountStatement")]public CustAccountStatement parmAccountStmt(CustAccountStatement _accountStmt = accountStmt){accountStmt = _accountStmt;return accountStmt;} Save the method and close the editor. Right-click SrsRDPContractSample, point to New, and then click Method. Edit the method so that it contains the following code.[DataMemberAttribute("InclTax")]public boolean parmInclTax(boolean _inclTax = inclTax){inclTax = _inclTax;return inclTax;} Save the method and close the editor. Step by Step: Define a Method to Return the Data to Reporting ServicesRight-click SrsRdpSampleClass, point to New, and then click Method. Edit the method so that it contains the following code.[SRSReportDataSetAttribute("TmpCust")]public TmpCustTableSample getTmpCustTable(){select * from tmpCust;return tmpCust;} Save the method and close the editor. Step by Step: Add Business Logic for the ReportRight-click SrsRdpSampleClass, point to Override method, and then click processReport. Edit the method so that it contains the following code.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 SSRS ReportQueryAttribute 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; } Save the method and close the editor. Step by Step: Create a Reporting ProjectOpen Microsoft Visual Studio. On the File menu, point to New, and then click Project. The New Project dialog box is displayed. In the Installed Templates pane, click Microsoft Dynamics AX. In the Templates pane, click Report Model. In the Name box, type SampleRDPReport, and in the Location box, type a location. Click OK. Step by Step: Bind a Report to a Report Data Provider ClassIn Solution Explorer, right-click the SampleRDPReport node, point to Add and then click Report. In Model Editor, right-click the Report1 node, and then click Rename. Type "CustomerReport" as the name. Right-click the Datasets node, and then click Add Dataset. In the Properties window, specify the following values. Data Source: Dynamics AX Data Source Type: Report Data Provider Default Layout: Table Name: Customer Dynamic Filters: True 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. For the Query property, 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 check boxes selected, and then click OK. In Model Editor, select the Customer node and drag it onto the Designs node. An auto design named AutoDesign1 is created for the report. Based on what you select, the Query property value is updated. In this case, the query is SELECT * FROM SrsRDPSampleClass.TmpCust. SummaryReports in Microsoft Dynamics AX 2012 are developed using SQL Server Reporting Services and Visual Studio instead of X++. The move to SSRS puts Microsoft Dynamics AX reports on Microsoft's preferred reporting platform providing users professional-looking reports, more export formats, and a more capable report designer. Test Your KnowledgeTrue or False. Reports are not fully-integrated into the Microsoft Dynamics AX security system. ( ) True( ) FalseWhat tool can be used to deploy Microsoft Dynamics AX 2012 reports? (Select all that apply)( ) Windows PowerShell( ) Microsoft Dynamics AX 2012 Installation( ) Microsoft SQL Server Reporting Services( ) Microsoft Visual StudioTrue or False. The new Report Data Provider classes let you build reports that use data from an X++ class as the source.( ) True( ) FalseWhat are some advantages of the new SSRS reporting architecture over X++ reports? (Select all that apply)( ) Professional-looking reports( ) More flexible architecture( ) More supported export formats( ) Better report designerWhat are some options for upgrading existing Microsoft Dynamics AX 2009 SQL Server Reporting Services (SSRS) reports?( ) Rewrite the SSRS report using the X++ reporting framework( ) Do not upgrade the reports. Use a SQL Server Reporting Services template and customize it to meet your needs.( ) Deploy the SSRS report using the deployment wizard.( ) Use the Report Upgrade Tool to upgrade the reports so that they are compatible with the Microsoft Dynamics AX 2012 schema. Quick Interaction: Lessons LearnedTake a moment and write down three key points you have learned from this chapter1.2.3.SolutionsTest Your KnowledgeTrue or False. Reports are not fully-integrated into the Microsoft Dynamics AX security system. ( ) True() FalseWhat tool can be used to deploy Microsoft Dynamics AX 2012 reports? (Select all that apply)() Windows PowerShell() Microsoft Dynamics AX 2012 Installation( ) Microsoft SQL Server Reporting Services() Microsoft Visual StudioTrue or False. The new Report Data Provider classes let you build reports that use data from an X++ class as the source.() True( ) FalseWhat are some advantages of the new SSRS reporting architecture over X++ reports? (Select all that apply)() Professional-looking reports() More flexible architecture() More supported export formats() Better report designerWhat are some options for upgrading existing Microsoft Dynamics AX 2009 SQL Server Reporting Services (SSRS) reports?( ) Rewrite the SSRS report using the X++ reporting framework() Do not upgrade the reports. Use a SQL Server Reporting Services template and customize it to meet your needs.( ) Deploy the SSRS report using the deployment wizard.( ) Use the Report Upgrade Tool to upgrade the reports so that they are compatible with the Microsoft Dynamics AX 2012 schema. ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- prashanth jayaram db technology enthusiast cloud sql
- united states environmental protection agency
- powershell study notes amr eldib
- sql server reporting services microsoft dynamics
- vbscript function microsoft
- windows management framework 5 0 preview february 2015
- deploying and monitoring applications in windows azure
Related searches
- microsoft dynamics crm server 2016
- sql server data classification
- sql server data classification tool
- sql server data types
- azure sql server hyperscale
- sql server 2016 string functions
- sql server connection strings
- sql server localhost connection string
- sample sql server connection string
- sql server trusted connection string
- sql server trusted connection true
- sql server connection string trusted connection