Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
OpenUtilities
  • Product Communities
  • More
OpenUtilities
OpenUtilities Wiki Rounding up quantities on BOM reports
    • Sign in
    • +OpenUtilities
    • +Bentley sisHYD Multi Utility
    • Design Features - promis.e Functionality - Promis.e Standard
    • +OpenUtilities Substation
    • Promis.e Paths
    • -Promis.e Wiki
      • +CONNECT Edition - Promis.e
      • About Promis.e
      • +Administration Features - Promis.e
      • +APIs_VBA - Promis.e
      • +Automation Features - Promis.e
      • +Component Features - Promis.e
      • +Component Management - Promis.e
      • +CONNECT Services - Promis.e
      • +Data Manager - Promis.e
      • +Database Platform Support - Promis.e
      • +Display - Promis.e
      • +Drawing Management - Promis.e
      • +Engineering Design Considerations - Promis.e
      • Error - Object reference...General
      • +Find_Replace - Promis.e
      • Finding the Tutorial
      • +Installation_Configuration - Promis.e
      • +Interoperability - Promis.e
      • +Licensing - Promis.e
      • +Maintenance Features - Promis.e
      • +Migration - Promis.e
      • +OS Support - Promis.e
      • +Panel Layout - Promis.e
      • +Performance - Promis.e
      • +PowerPlatform Support - Promis.e
      • +Print_Publish Features - Promis.e
      • +ProjectWise Integration - Promis.e
      • Promis.e Help file
      • +Reports_Output Features - Promis.e
      • -Template Management - Promis.e
        • +Graphical Plan Template Designer - Template Management - Promis.e
        • -Report Template Designer - Template Management - Promis.e
          • Add leading zeros to numbers on reports
          • Before Print scripts for report templates
          • Concatenating fields on report templates
          • Control number precision on reports
          • Desired Data Field Not Listed in Report Template Designer
          • Display current date and time on reports
          • Quantified BOM report with device IDs on a single line
          • Removing Terminal CP Text from Wire Lists
          • Replacing caret characters on reports
          • Report Page Number Format
          • Report Template Designer
          • Rounding up quantities on BOM reports
          • Sortable Quantified BOM Report
      • +Text Tools - Promis.e
      • Training FAQs
      • +Wire Numbering - Promis.e
      • +Wiring Features - Promis.e
      • +Project Management - Promis.e
      • Promis.e Title
      • Working from home with Promise.e
    • Replace Family - Find_Replace - Promis.e
    • SQL Server Login

     
     Questions about this article, topic, or product? Click here. 

    Rounding up quantities on BOM reports

      Product(s): Promis.e, Bentley Substation
      Version(s): through 08.11.13.73
      Environment: N/A
      Area: Template Management
      Subarea: Report Template Designer

    Background

    Total quantities of parts in a project may not always be whole numbers.  As designed, the project may contain 3.435 lengths of DIN rail or 1.2 boxes of fuses.  While accurate, the totals may not be ideal for how items are actually purchased.

    This article describes how to use scripts to round quantities up to the nearest whole number on quantified bill of materials reports. As an example, the BOM_Qty - Letter template is modified.

    Steps to Accomplish

    1. Open a page in a project that includes some fractional total quantities of part numbers.
    2. Open Report Template Designer.
    3. Select File > Open and open the BOM_Qty - Letter report template.
    4. Select the Designer tab at the bottom of Report Template Designer.
    5. Click to select the cell that displays the quantity in the GroupHeader1 band.
    6. Click the small > button that appears above the cell.
    7. Click the [...] button for the Summary field on the resulting pop up.
    8. On the resulting Summary Editor, set the Summary function field to Custom, keep Summary Running set to Group, click OK. The cell in the Designer view should now read "Custom(...."
    9. Select the Scripts tab at the bottom of the Report Template Designer.
    10. Paste the following into the Scripts, being careful not to overwrite any existing scripts:

      double totalQuantity = 0;
      private void Quantity_SummaryReset(object sender, EventArgs e) {
          // Reset the result each time a group is printed.
          totalQuantity = 0;
      }
      
      private void Quantity_SummaryRowChanged(object sender, EventArgs e) {
          // Calculate a summary.
          totalQuantity += Convert.ToDouble(GetCurrentColumnValue("QUANTITY"));
      }
      
      private void Quantity_SummaryGetResult(object sender, SummaryGetResultEventArgs e) {
          // Round the result
          e.Result = Math.Ceiling(totalQuantity);
          e.Handled = true;
      }


    11. Select the Designer tab at the bottom of Report Template Designer.
    12. Right-click the cell for Quantity in the GroupHeader1 band and select Properties.
    13. On the resulting Property Grid view, expand the Scripts row.  The Scripts row is in the Behavior category.
    14. Set Summary Get Result to Quantity_SummaryGetResult
      Set Summary Reset to Quantity_SummaryReset
      Set Summary Row Changed to Quantity_SummaryRowChanged
      (these are the names of the functions pasted in step 10)
    15. Preview the report by clicking the Preview tab.
    16. If the results are acceptable, use File > Save to save the template or File > Save As to save it as a new template.
    17. Close the Report Template Designer.

    See Also

    Before Print scripts for report templates

    External Links

    DevExpress: How to: Calculate a Custom Summary

      Original Author:  Matt_P
    • Template Management
    • promis.e
    • how to
    • Report Template Designer
    • Bentley Substation
    • en
    • SELECTsupport
    • Share
    • History
    • More
    • Cancel
    • Matt_P Created by Communities MVP Matt_P
    • When: Thu, Jun 2 2016 4:42 PM
    • Siddharaj Talawar Last revision by Bentley Colleague Siddharaj Talawar
    • When: Fri, Apr 3 2020 9:49 AM
    • Revisions: 5
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2021 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies