Home » Reports, Technical Terminal

Showing dimensions in metric units on custom reports

Submitted by on 12/22/2008 – 7:36 pmNo Comment

Overview

Due to a bug in SI5, product dimensions (height, width, depth) always appear in imperial/US units on reports. This posting discusses how to modify a custom report to show dimensions in metric units.

Steps to modify custom report

  1. Open the custom report in the Report Designer
  2. Select the Script tab at the bottom of the designer
  3. Add three lines of code to the ActiveReport_DataInitialize event. This will create three new data fields:

    Sub ActiveReport_DataInitialize
    Rpt.Fields.Add(“Height_Metric”)
    Rpt.Fields.Add(“Width_Metric”)
    Rpt.Fields.Add(“Depth_Metric”)
    End Sub

  4. Add the lines of code below to the ActiveReport_FetchData event. This will calculate the metric values (centimeters) and store them in the new data fields.
  5. Function ActiveReport_FetchData(ByVal EOF As Boolean) As Boolean

    Dim itm As DTools.SystemIntegrator.Reporting.Item = ReportUtilities.ReturnItem(rpt)
    Const Factor = 2.54 ‘conversion factor: inches to centimeters
    If itm IsNot Nothing Then
    Rpt.Fields(“Height_Metric”).Value = itm.Height * Factor
    Rpt.Fields(“Width_Metric”).Value = itm.Width * Factor
    Rpt.Fields(“Depth_Metric”).Value = itm.Depth * Factor
    End If
    ActiveReport_FetchData = EOF
    End Function

  6. Go back to the Designer tab
  7. In any textbox where you wish to see one of these data fields, set the DataField property of the textbox to be equal to the name of the new data field (e.g. “Depth_Metric”)

    How to use the new metric data fields

    How to use the new metric data fields

  8. Save and publish the report

Additional Information

See the attached custom report for a sample of how this works in practice.

Download report by clicking here: Line Item Metric Dimensions

Also, see this document for generic instructions on how to add a calculated field to a report: http://downloads.d-tools.com/si5/reports/Docs/Adding_Calculated_Fields_To_A_Report.zip

Popularity: 19% [?]


Comments are closed.