How to generating Application Definition File and Webparts for Writeback.
AdventureWorks2000 sample database
Generating the Application Definition File
Open up BDC Meta Man on the PC you want to work on. To Connect to SQL Server Click the drop down arrow on the 'Connect to data source' button in the top right of the screen and choose SQL Server.
In the 'Connect to data source' box enter the name of your Server and SQL Server instance if necessary, and select the Authentication Mode. If you using SQL Authentication you will also have to enter your SQL user account details.
Upon successfully connecting to SQL Server you’ll see the top window of BDC Meta Man populate with a list of databases. You can expand each database to see the list of tables by clicking the plus sign next to each database name.
Now we can see listed all the tables for this particular database. With BDC Meta Man we think of each table as being its own entity. We create an entity by dragging and dropping a table onto our design surface which is the large grey area to the right.
Upon dragging and dropping the table, the entity is created with the Finder and SpecificFinder methods. You can see a view of it on the design surface with the fields listed that are returned by the Finder method. For this walk through drag the dbo.Department table across
Assosiatios
When you have two entities that have a primary key->foreign key relationship between them you can create this relationship as a BDC association. This will allow us to make use of the BDC Related Data web part. To add an association, drag and drop the dbo.Employee table onto our design surface to create an Employee entity. You can create an association simply by dragging and dropping between the fields that are related. With our two entities it is the DepartmentID of the Department entity, and DepartmentID of the Employee entity. Drag and drop from the Department entity DepartmentID to the Employee entity DepartmentID
Doing this drag and drop creates the association for us, and any methods required to bring data back for the BDC Related Data Web Part.
Write back to BDC
When you define your application definition file you are telling the BDC how it can get your data by either executing a Select statement or a stored procedure. There is no reason why instead of doing a Select statement you execute an Insert or Update statement, passing in the values you want to Insert/Update as BDC parameters.
If you right click on a BDC entity when it is placed on the design surface you'll get to the entity management screen. The fourth tab along will allow you to select the fields that you want to be able to insert or update
As well as having an application definition file that contains the Insert and Update statements you need, you are also going to need some web parts for your users to fill in the values. BDC Meta Man not only generates the ADF file for you, but also a c# project that contains all the code you need for your web parts to work! Simply add a .snk file and away you can go with your web parts.
One deployed you will need to configure your web parts on a page and link it all together using BDC actions.
Now all we need to do is generate our application definition file. First we need to set the path to save the file. We set this location by going Configuration -> XML OutPut File from the main options. In the Filename textbox you can either manually type the location and the filename or use the browse button
Once you have saved the filename and path to create your application definition file to simply click the green play button and your application definition file will get generated
Once generated you get the option to open the XML file in your registered XML editor. If you click yes it’ll probably open it up in Internet Explorer for you to view. Look how much XML it has generated for you!
Importing the Application Definition File.
Remember the Business Data Catalog is only part of MOSS 2007 Enterprise Edition. You can download a trial of MOSS 2007 Enterprise Edition here:
http://www.microsoft.com/downloads/details.aspx?FamilyId=2E6E5A9C-EBF6-4F7F-8467-F4DE6BD6B831&displaylang=en
Once installed and correctly configured we need to import our application definition file.
Open up MOSS 2007 Central Administration by either browsing to it or through the start menu on the server running MOSS 2007 – Start -> All Programs -> Microsoft Office Server -> SharePoint 3.0 Central Administration.
Navigate to the Shared Service Provider Administration (SSP Admin) page from the left quick launch menu
In the SSP Admin page you’ll see a whole section devoted to the BDC. Click on ‘Import application definition’.
Use the browser button to locate our application definition file, or type in the path and filename yourself. Leave all the other options as they are for the time being, and click ‘Import’
MOSS 2007 will now go through and validate your application definition file is correct, once it is done you will get a success page. Clicking past that you will see the administration page for the BDC application we just imported
Using our BDC application in MOSS 2007
Browse to the page where you want to add the Business Data Web Part and edit the page. Click ‘Add a Web Part’ button to display the web part gallery.
Scroll down to the ‘Business Data’ section and click the checkboxes for the ‘Business Data List’ web part and the ‘Business Data Related List’ web part. Click the ‘Add’ button to add the web parts to our web part zone. Once the Web Part Gallery form disappears you’ll see the two BDC web parts added to our web part zone. Now we need to configure them. First the Business Data list, click the ‘Open the tool pane’ link to open the web part tool pane down the right hand side of the screen
We need to select what BDC entity our BDC data list is going to display, to do this click on the Browse button
From the pop up window select our dbo.Department Entity and click OK. Then Click OK at the bottom of the Web Part Tool Pane to configuring this web part.
Now we need to configure the BDC Related List web part. Again click on the ‘Open the tool pane’ and select the dbo.Employee entity from the Browse button as you did for the Business Data List. You’ll see when you have selected the Employee entity the relationship drop down is populated and selected with our relationship method. If our entity had multiple association methods this is where we’d select which one to use
Click ok to close the web part tool pane. The final configuration step we need to do is to connect the web parts together so when a Department is selected, only the Employees for that department are listed. To do this click on the small edit button for the Business Data Related List web part and go:
Edit -> Connections -> Get Related Item From -> dbo.Departments
And there we go. We should now be able to bring back all the Departments by clicking on the ‘Retrieve Data’ button on our Business Data List. Upon selecting a department from the returned values the Business Data Related List will bring back the employees for the selected department
Geen opmerkingen:
Een reactie posten