Skip to Content

In Connect SAP R/3 4.6C and SharePoint 2003 – Part II: Define SAP Proxy, I introduced how to define a SAP proxy which can invoke SAP RFC function – Rfc_Customers_Get(..). In this tip, I will introduce how to implement the two web parts after getting the SAP data via SAP proxy. I willl only high light some key points. More SharePoint development knowledge please check Microsoft web site.

12. In the first web part, “Customer List” provider web part, which also implements the IRowProvider interface. IRowProvider Interface is a standard interface which can communicate with other web parts such as ICellConsumer web parts. In other words the IRowProvider web part can provide some parameters to other ICellConsumer web parts, say in my sample case,Customer List web part will provide customer ID to Order List web part which implements ICellConsumer interface. We will talk about the web part communciations later in this tip.

  public class CustomerProviderWebPart : Microsoft.SharePoint.WebPartPages.WebPart, IRowProvider

13. In the Customer List web part, I will add four web controls like:

  DataTable CustomerTable;  TextBox txtBoxSearch; //a text box to allow user input the starting search character   Button searchButton; // a go button to invoke the search  Label label1; // a lable control to store the error info  Label lblCustomerDetail; // a label to display the detailed info of a customer such as telephone number etc.  DropDownList ddlCustomerList; // a drop down list to display the customer list starting with the same characters;

14. The key fuction of the customer provider web part is to export SAP customer data to CustomerTable and to bind data to the dropdown list control.

  protected void CustomerListDataBind(string searchText)  {   CustomerTable = this.GetCustomerListBySearchString(searchText).ToADODataTable();   DataColumn[] dcKey = new DataColumn[1];   dcKey[0] = this.CustomerTable.Columns["Kunnr"];   this.CustomerTable.PrimaryKey = dcKey;   this.ddlCustomerList.DataSource = CustomerTable;   this.ddlCustomerList.DataTextField = "Name1"; //customer name   this.ddlCustomerList.DataValueField = "Kunnr"; //customer number   this.ddlCustomerList.DataBind();  }//end of customer list data bind  protected BRFCKNA1Table GetCustomerListBySearchString(string searchText)  {   SAPCustomerWebParts.BRFCKNA1Table customer_T    = new BRFCKNA1Table();   try   {    proxy.Rfc_Customer_Get("",//customer ID     searchText,//customer name     ref customer_T);   }   catch (Exception ex)   {    this.label1.Text="No data found";    this.label1.Visible =true;   }   return customer_T;  }//end of Get Customer List by Searh String

15. then complete other functions of the Customer Provider web part and lastly the web part will be like below figure.

image

16. The second web part – Sales Order Web Part is a consumer web part which displays sales order of a customer. The customer ID will be passed from the above Customer Provider web part.

17. The Sales Order Web Part contains two key controls,

  SAPCustomerWebParts.SAPProxy1 proxy;  DataTable OrderTable; // a .Net data table to store the sales orders  DataGrid dgOrder; // a grid control to display the sales orders  Label label1; // a lable to display the orders in another way

18. The other parts are very similar to the first web part. The key highlight of this web part is by invoking BAPI BAPI_SALESORDER_GETLIST for fetching a list of sales order from SAP.

  protected SAPCustomerWebParts.BAPIORDERSTable GetOrderListByCustomerID(string customerID)  {   SAPCustomerWebParts.BAPIORDERSTable order_T    = new  BAPIORDERSTable();   BAPIRETURN vBAPIReturn;   try   {    proxy.Bapi_Salesorder_Getlist(customerID,"","","","","",     "1000","0", out vBAPIReturn,ref order_T);    order_T.SortBy("Sd_Doc", "Itm_Number");   }   catch (Exception ex)   {    this.label1.Text="No data found";    this.label1.Visible =true;   }   return order_T;  }//end of Get Customer List by Search String

19. Finally add the two web parts to the SharePoint page and connect them. The final page looks like below figure.

image

Reference:
1.Connect SAP R/3 4.6C and SharePoint 2003 – Part I: Prepare Environment, Ted Teng, Connect SAP R/3 4.6C and SharePoint 2003 – Part I: Prepare Environment, accessed in Dec. 2005
2. Connect SAP R/3 4.6C and SharePoint 2003 – Part II: Define SAP Proxy, Ted Teng, Connect SAP R/3 4.6C and SharePoint 2003 – Part II: Define SAP Proxy, accessed in Dec. 2005.

To report this post you need to login first.

6 Comments

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

  1. Ted Teng Post author
    During the migration process problems have been reported for this blog. The blog content may look corrupt due to not supported HTML code on this platform. Please adjust the blog content manually before moving it to an official community.
    (0) 
  2. A. Acuna
    It is very annoying to visit a page where, without scrollbars, it is possible to see only half of the page. With a 1024 px display should be more than enough. 🙁
    (0) 
    1. Ted Teng Post author
      Sorry I don’t know how to put plain text in SAP webblog style. Here is my blog link which may be a bit clear for display.

      Cheers

      Ted

      (0) 

Leave a Reply