Skip to Content

In many scenarios we come across situation where the service extended to SharePoint in not flat. That is, it contains complex structure. Out of the box, SharePoint external list is not capable of showing the complex structure on the screen. This would take a little custom coding to help us show case the data in such scenarios.

To explain, I would take an example of a Warehouse. The Warehouse would have the following attribute:

1.       Warehouse Name

2.       Warehouse Location

3.       Warehouse Id

4.       Warehouse Address

5.       Contact Persons
– As there can be more than one contact person for a warehouse , this attribute is a collection of Contact Person which in turn has

·         First Name

·         Last Name

·         Address

6.       Manifest List

-A warehouse can store multiple items of multiple types. To facilitate that we have this attribute as a collection of Manifest List elements this in turn has

·         Item Id

·         Item Name

·         Item Quantity

The aim of the demo is leverage the BCS object model to build ourselves a simple screen to show /create / Delete the data

 

Step 1:

First step would be to create a service. Ideally these should be hosted by your SAP backend, but for demo purpose I am creating a .NET WCF service in line with the structure mentioned above.

For reference please find the demo at the below link.

https://cw.sdn.sap.com/cw/servlet/JiveServlet/downloadBody/146623-102-1-313773/ComplexDataService.zip

 

Step 2:

The next step would be to create a BCS model out of the service exposed in step 1.

  1. Please note that while creating the model, we would not be including the sub-attributes as shown in the image below.

For more reference please find the BCS model at below mentioned url:

https://cw.sdn.sap.com/cw/servlet/JiveServlet/downloadBody/146625-102-1-313776/WareHouse%20BDC%20Model.zip

 

Step 3:

In this step we build ourselves an UI to show / read the data. If you are just starting off with BCS object model coding then it might be a good idea to first read through it on the msdn sites.

Here we would use the “.” (Pronounced: DOT) notation to navigate through the complex structure.

We would take look into the Warehouse web part that can be downloaded from.

https://cw.sdn.sap.com/cw/servlet/JiveServlet/downloadBody/146624-102-2-313774/WareHouse.zip

 

In the read function we are reading the Contact Person in the following way:

PS: for the code please open the attached project.

Here We are trying to get an instance of the field and checking whether the name corresponds to “Contact_Person” and if yes then in that case we are trying the access the elements of the Contact_Person collection by formatting the string like

String Format::  “Contact_Person[0].First_Name”

Similarly , while calling the create method we use the DOT notation to fill up the data in feildValueCollection as shown in the following extract.

PS: for the code please open the attached project.

Here we first we create the collection by using the “CreateCollectionInstance” method of the desired length. Then we assign the collection to the “feildValueDictionary”. Once the collection is created we again form the string format similar to read method (e.g. “Contact_Person[0].First_Name”) and assign the values.

Hope this article helps you over the short coming of SharePoint OOB webpart .

Cheers

Oyshik Moitra

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply