Você está na página 1de 18

Chapter 4: Report Adjustments

CHAPTER 4: REPORT ADJUSTMENTS


Objectives
The objectives are: Design reports using the visual report designer in Microsoft Dynamics AX 2009 Design reports effectively using standard report elements Design reports using different methods Create report and section templates Describe how best practices are used when creating reports

Introduction
A report presents information from a database as a printed document. Use reports to print invoices or complex summaries. All reports in Microsoft Dynamics AX 2009 are located in the AOT, where report elements can be accessed and adjusted. Several tools are designed to help perform adjustment tasks. MorphX helps to design reports that present information by using a graphical tool named the Visual Report Designer. This tool can combine many different design elements into one report, such as: Labels Data from the database Lines Graphics

The Visual Report Designer is located under the reports node in the AOT. The Visual Report Designer will be reviewed first, followed by the two types of report designs Auto Design and Generated Design. Lastly, reusable templates will be examined for both reports and sections. See the Appendix topic, "Case Study".

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

4-1

Development I in Microsoft Dynamics AX 2009

The Visual Report Designer


The Visual Report Designer is located under the reports node in the AOT.

Demonstration: Working with the Visual Report Designer


This demonstration will show all the components of the Visual Report Designer. 1. Locate the existing report named CustRevenue in the AOT and expand it. The three major components of the report are as follows: Methods, Data Sources, and Designs. 2. Expand the Designs node and the ReportDesign subnode; now an AutoDesignSpecs node exists. Double-click the AutoDesignSpecs icon to start the Visual Report Designer. o In the Visual Report Designer, the report is supplied with a horizontal and vertical ruler to help position report elements exactly as possible. Use this tool to change the units of measure. 3. Right-click the ruler to select the measuring unit of Inches. o The vertical margin is divided into sections of the report such as Header, Body, Prolog, and Page. The CustRevenue report only contains a body section. 4. Each element on the report has individual properties that can be viewed in the properties sheet like all other objects.

FIGURE 4.1 REPORT VISUAL DISIGNER

Working with Report Element Properties


Many elements on a report can be edited using the report's property sheet. Many properties have default or auto values and do not need to be changed unless they do not match the needed preferences. A default value is a system-generated value that does not have to be specified before a report is completed.

4-2

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 4: Report Adjustments


Demonstration: Modifying Report Properties
The demonstration shows some of the common properties that are edited in the Visual Report Designer. 1. Open the CustRevenue report in the Visual Report Designer, click the Body section, and then click the Properties button to display the Properties sheet. o The properties for columns are set to the default value of Auto. o This indicates that the report designer arranges the fields on the page to allow for the most number of columns per page. 2. Activate the Columns property and then click the Toggle button.

FIGURE 4.2 COLUMN PROPERTY FOR THE BODY

Use this to override the default value and specify the number of columns viewed on the report. By clicking the toggle button again, it returns to the default value.

3. Add a field to the body of the report by right-clicking in the body and selecting New. There are several options available, but for now focus on the option Field from CustTable. 4. Select this option to display the list of fields from the data source.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

4-3

Development I in Microsoft Dynamics AX 2009


5. To add a new field, drag the field from the list and drop it on the report. o To change the position, drag the element and drop it in another location. o Notice the Left and Top properties on the Properties sheet. o As the position changes on the report, the properties change to reflect the current position. The Left property indicates the distance from the left margin whereas the Top property indicates the distance from the top margin.Label Properties on a Report Element Labels on a report describe the fields and do not have a value. Labels have the following characteristics: Several properties governing the look, position, and size of the label can be specified. The ChangeLabelCase property changes the case of the label text on the report. The LabelTabLeader property inserts a series of dots between the label and the field value, similar to a table of contents in a book. Every element displayed in the Visual Report Designer is also located in the Designs node of the report in the AOT.

Reporting Best Practices


When designing a report, many details about the environment in which the report is executed are not known. Common factors to consider: The size of the paper in the printer The length or the contents of the labels used in the user's language The length of the fields and extended data types at the user's installation The number of dimensions at the user's installation How dates and numbers are formatted The size of amounts in the user's system The sort order of the data sent to the report If the user wants to print only the totals or subtotals What font and size the user has set up as report defaults

NOTE: Learning best practices means to become aware of all the things to do, and then being able to distinguish which of these can be realistically accomplished.

4-4

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 4: Report Adjustments

Report Design
A report in the AOT resembles a form. They both contain Methods, Data sources, and Designs. An important difference is that the data source element in reports consists of a query not a table. Microsoft Dynamics AX 2009 enables reports to have designs generated automatically so that the developer does not have to specify a report layout. The design of a report is controlled from the Designs node. Within the Designs node there are two types of design specifications: AutoDesignSpecs GeneratedDesign

Using Auto Design Specifications


When using AutoDesignSpecs, the report layout is generated when the report is run. Its content and layout is based on the query used for the report.

Demonstration: Using the Auto Design Specs


This demonstration creates a new report using the Auto Design Specifications. The design structure of the report is not generated until runtime, where it is generated based on the information entered in the query and the layout of the Report Template. One of the first things to do is to add data sources to the query of the report. 1. Create a report. Name the report MyReport by right-clicking the Report node in the AOT and selecting New > Report. 2. Expand this report in the AOT until it is possible to view the Data Sources node of the Query. 3. Drag the CustTable table onto this node to add this as a data source. Then drag the CustTrans table onto the data sources node of the CustTable_1 data source. 4. Create a relation between the two data sources. Right-click the Relations node of the CustTrans data source and select New Relation. Confirm that this relation is on the AccountNum fields of both tables. Also confirm that the JoinMode property of the CustTrans_1 data source is set to InnerJoin.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

4-5

Development I in Microsoft Dynamics AX 2009


At this point, the report resembles the following figure.

FIGURE 4.3 THE FINAL LAYOUT OF THE REPORT

NOTE: Instead of using a table in the report datasource, a Query may also be used by dragging and dropping the Query from the AOT to the Report Datasource. Now a Design for MyReport must be created. 1. Right-click the Designs node and select New Report Design. 2. Expand the ReportDesign1 node to reveal the AutoDesignSpecs node. Right-click this node and select Generate Specs From Query. The nodes created under this one correspond to the tables within the query. 3. Add fields to these groups in the design. On the CustTable_Body node, right-click and select the new control Field from CustTable. Drag the AccountNum, Name, and Address fields onto this node. 4. Repeat this process for the CustTrans_Body node by using the new control Field from CustTrans to add TransDate, Voucher and AmountMST. 5. Save the report.

4-6

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 4: Report Adjustments


6. View this report by right-clicking it in the AOT and selecting Open. 7. Specifying criteria to view the report is not needed. Click OK on the inquiry screen. Make sure that the report is printing to the screen and then click OK again. The report looks similar to the following figure.

FIGURE 4.4 DEMONSTRATION REPORT OUTPUT

Generated Design Specs


Use the GeneratedDesign option to design custom reports. In a GeneratedDesign, the layout is dictated by the design structure created in the Visual Report Designer and not by a query or report template. A report that is created by using the GeneratedDesignSpecs option has several differences from one created by using AutoDesignSpecs. One main difference is that a custom design is not affected by the structure of the underlying query. The design is defined by the developer and not generated automatically. Another difference is that changes made to the standard report template, if it is used do not affect the design of a report using the GeneratedDesignSpec option.

This is the recommended method to use if a specific format and look is required.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

4-7

Development I in Microsoft Dynamics AX 2009


Demonstration: Create a Custom Report Design
This demonstration creates a report that contains a list of items belonging to a particular asset group. 1. Create a new report by right-clicking the Reports node and selecting New Report. Name the new report AssetGroupListing. 2. Right-click Designs and select New Report Design from the menu. 3. Right-click the ReportDesign1 branch and select the Generate Design command. a. This generates an empty container named GeneratedDesign that can be used to build a custom report.

Demonstration: Create a Custom Report Layout


Add a data source to this report. 1. Expand the Reports Data Source node and the Query branch of the report to expose the Data sources of the query. This Data Sources branch is used to create the queries that provide the data for the report. 2. Drag the AssetTable table onto the Data Sources node of this query. 3. Drag the AssetGroup table onto the Data Sources node of the AssetTable data source. The report layout looks as follows:

FIGURE 4.5

4-8

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 4: Report Adjustments


For data to appear correctly on the report, the data sources in the query must be joined correctly. A relationship must be created between data sources. 1. Locate the Relations branch on the AssetGroup data source node of the report. 2. Right-click the Relations node and select New Relation. a. By default, Microsoft Dynamics AX 2009 tries to create a logical relationship between data sources. Because in this case, the default selection is incorrect; modify the properties of this relation. 3. Open the properties sheet for this relation. a. The Table property is assigned to AssetTable. This is the parent table for the report, and the RelatedTable property is assigned to the AssetGroup table. b. An appropriate relationship must be made between the tables. 4. Select AssetGroup for the Field property and GroupID for the RelatedField property. In the underlying data, both GroupID and AssetGroup contain the same information. This makes a logical relationship.

Sections within a Report


Creating a custom generated report requires adding and organizing sections. This is true for both AutoDesign and GeneratedDesign reports. The main difference is that the AutoDesign report always has a Body section created based on the query associated with the report. When designing a report in Microsoft Dynamics AX 2009 with data organized into a logical presentation, use sections. Sections are organizational containers that hold different information to be included in a report. The different section types that can be used are as follows: Prolog - The Prolog appears at the start of a report. It is printed before the page header on the first page of the report. Use it to display elements such as a logo, a report title, and current date. PageHeader - The PageHeader appears at the top of every page in the report. Use it to display for example page number, date, and time. Header - The Header appears at the start of a new group of records. Use it to display information such as group name. Section Group - The Section Group appears in the middle of the report. A section group can contain a Header, Body, or a Footer section. The structure of the data sources is reflected in the structure of the section groups.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

4-9

Development I in Microsoft Dynamics AX 2009


Footer - The Footer appears at the end of a group of records. Use it to display information such as sub totals. PageFooter - The PageFooter section appears at the bottom of every page in a report. Use it to display information such as page numbers, if the page numbers are not already inserted in the PageHeader. Epilog - The Epilog appears at the end of the report. Use it to display information such as disclaimers and general statements. The Epilog is printed just after the page footer on the last page in the report. ProgrammableSection - The ProgrammableSection contains any kind of customized information.

FIGURE 4.6 REPORT SECTIONS

Demonstration: Building a Custom Generated Report


To start designing a custom generated report, highlight the GeneratedDesign icon of the AssetGroupListing report and add relevant sections: 1. Add a PageHeader section. Right-click the Generated Design node and select New > Page Header. 2. Add a Section Group to the report. 3. Within the Section Group, add a Header, Body, and a Footer. 4. Add a Footer section to the Generated Design. Now add relevant controls and fields to the sections of the report. 5. The demonstration shows how to modify the PageHeader by adding a heading that appears in every page that has a line under it and a page number. a. Set the LineBelow property on the PageHeader section to Solid. b. Right-click the PageHeader node and select New Control > Text. Then, modify a property on this control. Set the Text property to Asset Table.

4-10

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 4: Report Adjustments


c. Create the page number field by right-clicking the PageHeader node and selecting New Control > Integer. Set the Left property to Right Edge. Set the DataMethod property to page. This data method returns the current page number on each page of the report. d. Notice when the data method is set, the icon for the control changes from red to green indicating the control compiles successfully. HINT: Another useful DataMethod on reports is the pages Total data method. This returns the total number of pages in the report. This is useful to display the page number as Page of Total Pages. For example, 3 of 10.

Demonstration: Building a Custom Generated Report


1. Add fields to the Body of the Section Group from the AssetTable table and one from the AssetGroup table. Add a new control type Field from AssetTable. a. Fields from AssetTable: AssetID, Name, InsuredValue 2. The SumAll property on the InsuredValue field must be set to Yes.Add the AssetType field from the AssetGroup table to the Body between Name and Insured Value. 3. Add a sum control to the Footer of the Section Group. The DataFieldName property on this control must match the Name property for the InsuredValue field in the body of the section group. Also, add a solid line above this field. 4. Add a sum control to the Footer of the report. This should also be a sum for the InsuredValue field by setting the Data Field Name property. Change the LineAbove property to Double for this field.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

4-11

Development I in Microsoft Dynamics AX 2009


5. Now that the report design is complete, view the report by rightclicking on the report in the AOT and selecting Open. The criteria for this report does not need to be specified. Verify the report is printing to the Screen and click OK.

FIGURE 4.7

Report Templates
When designing reports, the option is available to work from several templates in the standard Microsoft Dynamics AX 2009 application or to create a new template. When applying a template to a report design, several layout elements built into the template are automatically received. A template can include the following: Page numbers on each page A specific company logo A specific disclaimer required for all reports

If reports share the same template, apply changes to the report template. The changes are inherited by the reports using this template. Inheritance of report elements is a significant advantage for report design because many elements of a report are repetitive. Using a report template eliminates redesigning report sections as headers, disclaimers, and other typically used elements.

4-12

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 4: Report Adjustments


Only reports based on an auto design specification inherit changes that are made to a report template. If a report uses a custom design, it does not inherit changes, even though the report is based on a template. When creating the custom design, MorphX took a snapshot of the template and copied it to the Design node of the report. Therefore, a custom designed report cannot be created and a report template cannot be attached to it.

Creating a Report Template


Create a new report template for displaying the name of a company. The best way to accomplish this is to use a Prolog section within a report template.

Demonstration: Create and Attach a Report Template


After creating the template, have the MyReport report use it. This gives it the same properties and methods as the template. 1. Create a new report template by right-clicking the Report templates icon in the Reports branch, and selecting New Report Template. Rename this new template MyProlog. 2. Next, add a Prolog section to the new template. Because a prolog is a section that prints before the page header of the first page of the report, the company name is displayed at the start of the report. Right-click the MyProlog template and select a new Prolog. 3. Add a company name by adding a string control to the Prolog. Rename this new control CompanyName. 4. To view the Company Name, create a display method on this report. 5. Right-click the Methods node and select New Method. 6. This opens the Code Editor where all X++ code is written. Type code in the Code Editor.

FIGURE 4.8 CODE EDITOR

7. Save the method and close the Code Editor. 8. To view the value returned from the display method, attach the method to the CompanyName control on the Prolog by assigning the DataMethod property the value of CompanyName. 9. Because this is on the front of the report, make the font size of this control larger. Set the FontSize property to 20.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

4-13

Development I in Microsoft Dynamics AX 2009


This process has now successfully created a report template that can be used by other reports for adding a prolog to display the company's name. The next step is to extend the template properties to a report. To accomplish this step, attach the MyProlog report template to the MyReport report. 1. Locate the ReportDesign1 node under the MyReport report node in the AOT. 2. In the properties sheet, set the value of the Report Template property to MyProlog. The AutoDesignSpec inherits the properties of the MyProlog template. This means that any time the auto generated report runs for AssetGroupListing, it contains a Prolog section that shows the CompanyName field. Test by opening MyReport from the AOT. The company's name should now appear at the top of the page. NOTE: This Demonstration requires more complex programming knowledge with X++; this exercise gives enough information to continue with the exercise. Writing display methods and other X++ code are covered in more advanced X++ programming courses.

Section Templates
Section Templates make it possible to define sections one time and reuse them many times. Typically this is used for elements appearing in more than one report. For example, a customer wants to customize the layout of all checks printed from Microsoft Dynamics AX 2009. Instead of changing all the reports that print a check, change only the check section template.

Demonstration: Create and Attach a Section Template


The following demonstration shows the steps to create a new section template. 1. Create a new section template by right-clicking the Section Templates node and selecting New Section Template. Rename this section template MyContactSectionTemplate. 2. Add a new body to the section template by right-clicking it and selecting New. The body contains all the changes to the section of the report being modified. 3. Set the Map property of the Section Template Body to CustVendTable.

4-14

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 4: Report Adjustments


4. Add a new field by right-clicking the section template body and clicking New Control then Field from CustVendTable. 5. Add the fields Currency and CreditMax to the Section Template Body. The section template is now defined; link it to a report. 1. Locate the AutoDesignSpecs node under the MyReport report in the AOT and link this section template. Right-click this node and select New > Section Template. 2. Assign the correct properties to the Section Template Pointer. Set the Section Template property to MyContactSectionTemplate and the Table property to CustTable. 3. Save the changes. The section template is now linked to the MyReport report. View the report to verify the additional Currency and Credit Max fields are in the middle of each section.

Paper Format
When running a report in Microsoft Dynamics AX 2009, the paper format must be specified for each report type. For example, open the Accounts Receivable module, then Setup, then Forms, and open Form setup. On the Packing slip tab, in the Layout section, view an example of where the Paper format can be specified. Microsoft Dynamics AX 2009 reports use three standard paper formats: Blank Paper - This is used when nothing is pre-printed on the paper for the report. This choice gives the user a Header, optionally a logo, and all system labels assigned to the printed system data. Partly preprinted or Semi preprinted - This is used for paper without a header. This choice gives the user no Header, but gives all system labels assigned to the printed system data. Preprinted - This option is used if the user does not want anything except the system data printed on the report. This choice gives the user no Header and no labels.

Summary
This course discussed the Microsoft Dynamics AX 2009 techniques for generating a report from the database as a printed document. The location in the AOT of all reports is shown to allow access to adjust and create report elements. This course also discussed tools such as the Visual Report Designer, Templates and MorphX which are used to allow adjustments of report layouts.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

4-15

Development I in Microsoft Dynamics AX 2009

Test Your Knowledge


Test your knowledge with the following questions. 1. What are the three major components that constitute a Microsoft Dynamics AX 2009 report? Mark all that apply. (Select all that apply.) ( ) Designs ( ) Datasources ( ) Methods ( ) Layouts between an AutoDesign specification and a custom GeneratedDesign specification?

2. contain which items? Mark all that apply. (Select all that apply.) ( ) Bodies ( ) Footers ( ) Headers ( ) Page Footers What are some features of the Visual Report Designer that make it an ideal choice for designing reports?

4-16

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Chapter 4: Report Adjustments

Quick Interaction: Lessons Learned


Take a moment and write down three key points you have learned from this chapter: 1.

2.

3.

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

4-17

Development I in Microsoft Dynamics AX 2009

Solutions
Test Your Knowledge
1. What are the three major components that constitute a Microsoft Dynamics AX 2009 report? Mark all that apply. (Select all that apply.) () Designs () Datasources () Methods ( ) Layouts 2. What is the difference between an AutoDesign specification and a custom GeneratedDesign specification? MODEL ANSWER - When you are using AutoDesignSpecs, the report layout is generated when the report is run. Its content and layout are based on the query used for the report. In a GeneratedDesign the layout is dictated by its design structure that is created in the Visual Report Designer and not by a query or report template. 3. A Section group can contain which items? Mark all that apply. (Select all that apply.) () Bodies () Footers () Headers ( ) Page Footers 4. What are some features of the Visual Report Designer that make it an ideal choice for designing reports? MODEL ANSWER - The Visual Report Designer allows you to drag and drop report field elements for placement in the report. It allows you to change the scaling while in design mode so you can place your objects more accurately.

4-18

Microsoft Official Training Materials for Microsoft Dynamics Your use of this content is subject to your current services agreement

Você também pode gostar