How to Enhance Dynamics GP’s Inventory BOM Report Using SSRS

During a recent project for a client they want to enhance their custom inventory BOM report made by another vendor. Not having access to the original code, I proposed modifying the Bill of Materials Maintenance window to add a print button and developing the report in SSRS.

Modifying the window

1. Log into Dynamics GP and open the Bill of Material Maintenance window in the Inventory Module.

2. On the window navigate to Tools>>Customize>>Modify Current Window. This will open modifier.

Dynamics GP BOM Window

3. Inside of Modifier, click on the “OK” button from the toolbox on the left and drag it onto menu bar of the Bill of Material Maintenance window. As shown on the below screen shot.

BOM window in Modifier

4. Open the Properties of the new “OK” button and change the text for the button. I changed mine to “Print BOM”. Save the changes and Exit Modifier to get back into Dynamics GP.

BOM window in Modifier 2

Adding VBA code to our window

1. With the Window now modified, we need to navigate back to Tools>>Customize>>Add Current Window to Visual Basic. We also need to add the “Print BOM” button and Bill Number field to Visual Basic by selecting the “Add Fields to Visual Basic…” menu.

Add BOM window to VBA Project

2. Now open up Visual Basic Editor, Tools>>Customize. We need to make the button functional by adding some VBA code.

BOM window in VBA

a. First let’s add the References that we need for the project by navigating to Tools>>References from the menu bar. Add or verify that the following References are selected: Visual Basic for Applications, Microsoft Dynamics GP VBA 18.0 Type Library, OLE Automation and Microsoft ActiveX Data Objects 2.1 Library.

Dynamics GP VBA project references

b. Before writing our VBA code we should verified that the window and both fields were added to the VBA project. We can do that by click on the dropdown menu where you see “(General)”. Your screen should look similar to my screen shot below.

VBA project windows and fields

c. Add the following VBA code Object Browser. You will need to change the highlighted VBA code based your SSRS server name, folder location of the report that we will be building and the name of the SSRS report. In the VBA code below:

i. XXXXX – would be my SSRS server name

ii. TWO – is the Folder that I saved the report in

iii. BOM Indented is what I named my report

Sub window_Open(strLocation As String, Menubar As Boolean, top As Long, left As Long, height As Long, width As Long, resizable As Boolean)

With CreateObject(“InternetExplorer.Application”)

.Visible = False

.top = top

.left = left

.height = height

.width = width

.Menubar = Menubar

.Visible = True

.resizable = resizable

.Navigate strLocation

End With

End Sub

Private Sub PrintBOM_BeforeUserChanged(KeepFocus As Boolean, CancelLogic As Boolean)


Dim IE As Object

IBOM = CStr(BillNumber)

window_Open “http://XXXXXXX/ReportServer/Pages/ReportViewer.aspx?%2fTWO%2fBOM+Indented&rs:Command=Render&BOMItem=” & IBOM & vtype, False, 10, 10, 750, 1250, True

End Sub

Creating the stored procedures for the SSRS report.

Now the tricky part, dealing with the undefined amount of levels that a BOM hierarchy can go down. With the help of Google, I found this forum post – Original credit and thanks to Beat Bucher and Tim Foster for the post and original SQL code. I have modified the original stored procedure to fit my client’s needs. Here is the stored procedure code that I used:





CREATE PROCEDURE [dbo].[usp_BOM_Level_Details] (@current char(31)–, @BOMType smallint

) AS


DROP TABLE #result;

Drop Table #stack;


–DECLARE @current char(31) –> use the 2 lines here to test directly in SQL Studio Mgmt

–SET @current=’BB00069E0000BT9′


–if @current is null set @current = ‘BB00069E0000BT9’

DECLARE @lvl int, @line char(31), @Qty numeric(19,5), @ORD1 int, @UOFM char(9), @comptitm char(31)

CREATE TABLE #stack (item char(31), comptitm char(31), Design_Qty numeric(19,5), ORD1 int, UOFM char(9), lvl int)

CREATE TABLE #result (lvl int, item char(31), comptitm char(31), Qty numeric(19,5), ORD1 int, UOFM char(9),

ord int identity(1,1))

INSERT INTO #stack VALUES (@current, ”,1,1,”,1)

SELECT @lvl = 1

WHILE @lvl > 0


IF EXISTS (SELECT * FROM #stack WHERE lvl = @lvl)


SELECT @current = item, @comptitm = comptitm, @Qty = Design_Qty, @ORD1 = ORD1, @UOFM = UOFM

FROM #stack

WHERE lvl = @lvl

— SELECT @line = replicate(‘-‘,(@lvl – 1)) + ‘ ‘ + @current –> spacing by level

–PRINT @line –> replace this print with an INSERT to another table like #BOM

INSERT #result SELECT @lvl,@current, @comptitm, @Qty, @ORD1, @UOFM


WHERE lvl = @lvl

AND item = @current

INSERT #stack


FROM BM00111 –> I edited this for GP

WHERE ITEMNMBR = @current and Component_Status = 1 –and BOMCAT_I = @BOMType –1 –> added BOMCAT for MFG(1) or ENG(2)

ORDER BY ORD –Order by Part Number as in GP Reports CMPTITNM

–ORDER BY POSITION_NUMBER ASC –Order by Position Number–other sequence in GP


SELECT @lvl = @lvl + 1



SELECT @lvl = @lvl – 1


drop table #stack

;WITH CTE as (select ITEMNMBR FROM BM00101)

SELECT T1.lvl,

CASE WHEN T1.lvl = 1 THEN ”


END as item,

CASE WHEN T1.lvl = 1 THEN RTRIM(T1.item)

ELSE RTRIM(T1.comptitm)

END as comptitm,

T1.Qty, T1.ORD1,





,CASE WHEN T1.item in (select ITEMNMBR FROM CTE)






END as [Ext Cost]


#result T1 INNER JOIN IV00101 T2

ON T2.ITEMNMBR = T1.item


DROP TABLE #result;


Building our SSRS BOM Indented Report

SSRS (SQL Server Reporting Services) is a server-based reporting system from Microsoft and part of the SQL server stack. It can be used to prepare and deliver prints through a web site. You can build your reports with either Report Builder or Visual Studio. For this project, we are going to be using Report Builder. Let’s start creating our Indented BOM report using a wizard.

Creating the Data Connection

1. Start Report Builder either from your computer or the Reporting Services web portal. Select New Report in the left pane and Table or Matrix Wizard in the right pane.SSRS wizard

2. Specify a Data Connection in the Table Wizard

A data connection contains the information to connect to an external data source such as a SQL Server database. Usually, you get the connection information and the type of credentials to use from the data source owner. To specify a data connection, you can use a shared data source from the report server or create an embedded data source that is used only in this report.

3. Click the New Button to create a new Data Source and then build on the Data Source Properties window that opens.SSRS Data Source

4. Enter your Connection Properties for the SQL Server and Dynamics GP company database.

SSRS Data Source connection

5. Click the General tab again. To verify that you can connect to the data source, click Test Connection.

The message “Connection created successfully” appears.

6. Click OK.

Creating our Datasets

1. Right click on your new Data Source to create a Dataset.

2. Choose to use a dataset embedded in my report and a Query type of Stored Procedure. Choose the stored procedure we created earlier. (usp_BOM_Level_Details)

SSRS Dataset

3. Add a Parameter for the Dataset Properties. I named mine @BOMItem

Organize Data into Groups in the Table Wizard

When you select fields to group on, you design a table that has rows and columns that display detail data and aggregated data. To start organizing your data into groups:

1. Navigate to the Insert menu, click on the Table icon and select Table Wizard.

SSRS Table Wizard

2. On the New Table or Matrix window drag the lvl, comptitm, item, ITEMDESC and UOFM to the Row Groups section. Drag the Qty, CURRCOST and Ext_Cost fields to the Values Section.

SSRS Table or Matrix Wizard

3. Click Next and de-select Expand/collapse groups.

Table Wizard step two

4. Remove the sub-grouping totals, format the numbers to the forth decimal place and change the row height to 0.025. Your table should look like the below screen shot when your complete.


5. Change the Tablix Properties for the Row and Column Headers to Repeat on each page.

Tablix Properties

The Final Product

Once complete, you should have a Dynamics GP Bill of Materials Maintenance window like the below screen shot and when you select a Bill Number and click the Print BOM button the SSRS report will open and produce the results in the second screen shot. You can download zip file the stored procedure, Dynamics GP package file and SSRS rdl report from here.

Modified Dynamics GP BOM Window

SSRS Indented Inventory BOM Report

Ready to Do Even More with Dynamics and Business Intelligence?

Check out my other blog posts that can help your company become data-driven organization by exploring your Business Intelligence, BI360, Power BI, Microsoft Dynamics GP and CRM.


Power BI Visuals in On Premise SQL Server Reporting Services

Yesterday, January 17, 2017, Microsoft released the Power BI reports in SQL Server Reporting Services (SSRS) technical preview. You can read all about it here. I downloaded the technical preview and installed it on my system and deployed a Power BI Visual to my SSRS web site. Here are the steps to get it installed on your system.

· Download the SSRS Technical Preview and Power BI Designer for the preview


· The Technical Preview has the following system requirements:

    • Your own VM or server (not one in production use)
    • Windows Server 2012 or later (or Windows 8 or later)
    • .NET Framework 4.5.2 or later
    • SQL Server Database Engine (2008 or later), to store the report server database
    • SQL Server Analysis Services (2012 SP1 CU4 or later), to store your data models

· I first installed the SQLServerReportingServices.exe on my system and accepted the licensing terms and agreement and then selected the “Install” button.


· After the installation completed I needed to configure the technical preview of SSRS by selecting the “Configure Report Server” button.


· I provided my SQL Server name to Connect the Reporting Services Configuration Manager.


**NOTE – While the configuration manager let, me configure the SSRS technical preview web site with my original VM’s computer name of ‘BARRYCROWEL38F0’ I could not publish by Power BI report with that computer name. I shortened the name to 7 characters and removed the numbers from the name to get the Power BI Designer Technical Preview to function with the SSRS web site.

· Design a Power BI visual with the Power BI Designer Technical Preview. In my visual, I connected to an SQL Server Analysis Services (SSAS) database. To publish you report to SSRS, select the ‘Save As’ menu option.

Power BI Technical Preview SSRS

· Following the screen prompts and supply the Reporting Server.

Power BI Technical Preview SSRS

· Then enter the report name.

Power BI technical preview SSRS

The final product is a Power BI visual with slicer functionality in an on premise SSRS web site.

**NOTE – the current SSRS technical preview does not work with custom visuals or R visuals.

Power BI On Premise


I’m loving the first on premise technical preview and can’t wait for what next.

Design Best Practices to Build Killer Dashboards

When buying real estate its all about location, location, location. Like real estate, dashboards or data visualizations are all about one thing – data, data, data. With that in mind here are some of my data visualization best practice design tips. Make your data visualization:

  • Relative
  • Interactive
  • Simple

Make it Relative

Make sure that the data underlying your dashboard is up-to-date, accurate and that your selected KPIs, metrics and charts tell your intended story or current business challenges.

Data can be from this quarter, this week, this hour—whatever the right timeline is for your business. Stale data can lend to you thinking you’re making fact-based decisions, but the data is no longer representative of or relevant to your current situation.

Make it interactive

Your dashboard or data visualization has to be relevant to its intended audience. Dashboards need to start with an audience in mind. Who is the consumer of the dashboard? What are their information needs? What do they already know? What are their experiences and prejudices? As we design the dashboard, understanding the consumers of the dashboard will help us craft a product that they love to use.

A complicating factor is that most dashboards have multiple audiences. In fact, delivering the same dashboard across an entire organization has the potential benefit of getting everyone on the same page. However, a diverse audience is hard to serve well. Therefore, try to prioritize the audiences so conflicts can be more easily handled.

After figure out your intended audience, you need to choose the right KPIs, metrics and make it visually engaging – you’ve got everyone looking at the same page. But once they’re on the same page, viewers will have unique questions about what they see. Create your dashboard so that individual viewers can interact with it to get the answers they seek.

Keep it Simple

This one is critical. No Clutter! Resist the temptation to make your dashboard too ashy or over-designed, with gauge-like graphics and widgets. Any dashboard or data visualization should follow the Fibonacci Spiral principle. It is a pretty cool thing to use/apply to your dashboards. Use it wisely and when it works, it works really well. Not all visualizations have to fit the Fibonacci Spiral though. For more on the Fibonacci Spiral principle, please see these links:



For simple and well thought out dashboard designs choose the right chart to tell your story. So how do you choose the right chart? While a few years ago Dr. Andrew Abela published a good Diagram helping to decide about which charts are a better fit for a given data and problem at hand (please click on image below to see it in full size).


Dr. Abela also published interesting thoughts about visualization taxonomies and recommended this 3 years old book by Dan Roam, who also published this Visual Thinking “Codex”. Juice Analytics converted Dr. Abela’s diagram to online Chart Chooser application, I suggest to review it when building your dashboard and selecting a chart to visualization your data.


Final Thoughts

Hope this helps you with your future dashboard and data visualization designs..