SharePoint BDC Part 1: Getting Started with the Business Data Catalog

Fantastic Blog article from here 

SharePoint BDC Part 1: Getting Started with the Business Data Catalog 

Author: Tobias Zimmergren 
URL: http://www.zimmergren.net | http://www.tozit.com 

Introduction

In this article I will guide you through the very basics of getting started with Business Data Catalog, BDC:

  1. Install the AdventureWorks 2008 Sample Databases
    1. We will use this database as our example for retrieving data using the BDC. 
  2. I will step you through the simple process of creating your ADF (Application Definition File)
    1. We will use this file as our import connection 
  3. I will guide you through how we can import this ADF file and create our BDC Application 
  4. Lastly, I will guide you through the process of creating a basic site and use some of the basic BDC Web Parts

Install the AdventureWorks sample database

  • You’ll need to go and download the AdventureWorks sample databases 
    image
     
  • Just finish the installation by clicking next a couple of times and let the installer do it’s normal Microsoft-installer magic. 
  • You should now see a couple of new databases in your SQL Server Management Studio: 
    image 
    AdventureWorks, AdventureWorks2008, AdventureWorksDW, AdventureWorksDW2008, AdventureWorksLT, AdventureWorksLT2008 

Alright – We’ve got our databases, now we need to start thinking about how we will get data from our SQL server into SharePoint. This is done by creating/generating an Application Definition File (ADF) as you will see in the next section.

Creating the ADF (Application Definition File)

Alright, there’s a few different options to create your ADF (Application Definition File). I will show you how to get started with using the free tool called “Application Definition Editor” that comes with the latest SharePoint Server SDK.

Note: See the bottom section in this article for a summary of links to all resources mentioned in the article.

After you have installed the latest SDK, you can choose to install the “Microsoft BDCTool” located here by default: “C:Program Files2007 Office System Developer ResourcesToolsBDC Definition Editor”. Which will give you the following item in your Start Menu: 
image

Launch the BDC Application Definition Designer

Click the application and launch the editor. You will see an interface like this: 
image

Create or import your ADF file

There’s basically two alternatives when it comes to editing an ADF (Application Definition File). 
One is to create a new one (which I will guide you through first), and the other is to import an existing one (which I will show you after the first alternative).

Alt 1) Creating our own ADF file 
Now we’re going to connect to our newly created sample-databases and create an ADF file for use with those databases.
  • Click on ADD LOB System
  • Choose Connect To Database
  • You will see a nice popup-dialog where you will be able to enter the connection details to your desired database
    • Enter your connection details, example: 
       image 
  • You are presented with the “Designer Surface that looks something like this: 
    image 
  • In our case, we’re going to use the table called “vEmployee” which exist in the AdventureWorks database in order to pull out some information about our employees.
    • Search for the table called vEmployee and drag it out to the Design Surface
    • Search for the table called vEmployeeDepartments and drag it out to the Design Surface
    • It should look something like this: 
      image
    • Make any necessary changes, then click OK
    • You’ll see a view similar to this one after some tweaking: 
      image  
    • After you’ve done the necessary changes to your configuration, making sure it’s a valid ADF with proper filters, enumerators and methods or whatever you need in your application then smile, because we’re done with that part!
Alt 2) Importing an existing ADF file

If you don’t want to do everything from scratch or you’ve already got an ADF file that you wish to modify, you can do so by importing an existing ADF file into the Definition Editor. Here’s how:

  • Open the BDC Definition Editor tool, then click the “Import” button in the menu: 
    image 
  • Browse to your existing ADF file and choose to import it. Simple as that. 
    (I am importing a file called BDCAWDW.xml, which contains definitions for Product, Reseller, ProductSubcategory, ProductCategory as shown below) 
  • You’ll see the imported ADF file’s structure immediately in the designer, under the prerequisite that your SQL connection string in the ADF file is valid: 
    image 

Note: I will not detail how you create filters, finders, methods etc. in this article. You can read more about that here: 
http://msdn.microsoft.com/en-us/library/ms145931(SQL.90).aspx 

I may cover the topic of ADF-functionality in another article later on.

Generate the ADF file from the designer

I really don’t need to tell you this, but there’s a button called “Export” which you use to export the definition you’ve created using the definition editor to an xml file: 
image

Import the ADF file

If we have gotten this far, we might as well get the last few bits in place. 
What we now need to do is to import our ADF file into SharePoint, since that’s where it should reside. Follow along with these few simple steps to make sure you’re properly importing your file into SharePoint.

  • Navigate to your Shared Services Provider Administration site (You can access your SSP through Central Administration) 
  • You are presented with a section called “Business Data Catalog” where you’ll find a bunch of different alternatives. 
  • Make sure you have the permissions to modify the BDC (See the link Business Data Catalog permissions
  • Click “Import application definition” 
    image   
  • Browse for your .xml file and click “OK“: 
    image 
  • You’ll see a progress bar (You don’t see that a lot in SharePoint. I love it!), telling your how the import process is going: 
    image
  • When it’s done, you’ll click “OK” and be presented with an overview of your imported BDC Application: 
    image
Configure permissions on the BDC Application Definition

In order for all users to be able to select/read data from your BDC Application, you’ll need to make sure they’ve got the appropriate permissions to actually do so.

Usually I do this setting on each of the imported entities, in case you want specific permissions on different entities – instead of on the entire application.

  • Select the DropDown list on your first entity and choose “Manage Permissions“: 
    image  
  • Choose “Add Users/Group“: 
    image
  • Enter “NT AUTHORITYAUTHENTICATED USERS” and choose “Select in Clients“: 
    image 
  • Repeat these steps for the other entity as well.
  • You’re done.

Now we have created or imported an ADF file with the Business Data Catalog Definition Editor tool, exported it to an .xml file, imported it into SharePoint, set basic permissions on the entities.

Next, we should make sure that the application works in SharePoint by adding a Business Data Catalog-WebPart to a page.

Use the basic built-in BDC Web Parts

Awesome. Now that we have gotten this far by importing an ADF file into SharePoint and set appropriate permissions on the entities – We’re ready to actually use the ADF connection to view stuff in our database.

Note: I have created a new blank site where I can easily show the built-in BDC Web Parts – so that’s where I am adding my Web Parts.

 

  • Add two Web Parts to your page called “Business Data List” and “Business Data Item“: 
    (Note that when you’ve configured a BDC application, you’ll see the Business Data web parts) 
    image
  • Choose to edit the properties of the Business Data List Web Part: 
    image 
  • Click the Browse-icon to the right to pop up the BDC entity chooser: 
    image 
  • It will present you with the following interface (note, BDC applications will of course vary depending on what you have imported..): 
    image  
  • Double click the “Employee” type, and then click “OK” in your Web Part property window.
  • Repeat this process for the “Business Data Item” Web Part, and select “Employee” in the BDC Type Picker as well.

Now we’ve got one BDC List Web Part which will list all employees, and one BDC Item Web Part that will display details about the employee we select.

In order for this to work we must connect the two Web Parts.

  • Edit menu of your Web Part -> Connections -> Send Selected item To -> Employee 
    image

Test our BDC Application out, and make sure it works!

  • Choose “LastName” then “contains” and enter “smith“: 
    image
  • Select one of the results by clicking the radiobutton to the left, and see that the result (details) about the Employee shows up in the connected Web Part: 
    image 

Resources and links

Summary

This article is a basic step-by-step guide to getting started with BDC in MOSS 2007. I’ve shown you every step from creating the databases required (in our case some sample databases) to creating the ADF file and to finally utilize the BDC connection from a site, using the BDC Web Parts.

In an upcoming post I will talk about how you can create your own BDC Web Parts! Keep your eyes open!