Show TOC

How to Add New Mapping for a PropertyLocate this document in the navigation structure

This is an example showing how to map properties in the generated code for your Excel application.

Prerequisites

You have generated code for an Excel add-in application using the GWM Excel add-in wizard.

Context

The example contains code snippets, and shows how to customize the generated code in the class, ExcelDataManager.cs, by mapping and binding a property to a column in the Excel; and then performing an update using the class, SubmitChangesViewModel.cs.

Procedure

  1. From the Solution Explorer, open the class, Start of the navigation path Excel ExcelManager ExcelDataManager.cs End of the navigation path
  2. Go the method, CreateExcelBindingTable, and add an additional column in the Excel data table.
    Example For example, add the following line:
    this.ExcelDataTable.Columns.Add(GetDataColumn("BankName", "System.String"));

    Notice that you are expected to provide a property name, and the equivalent C# data type formatting to the EdmType of the property. You can find all the properties in the service proxy class, Start of the navigation path SAP Service  Next navigation step  Reference service.cs End of the navigation path.

  3. Go to the method, BindExcelTableWithRecords, and add the relevant service response data binding to the new column you added in Excel data table.
    Example For example, add following line:
    dataRow["BankName"] = entity.BankName; 
  4. You may skip this step if the Create, Update, and Delete functionality are not supported in the OData service. If these functionlaty are supported in the service, then perform the following to change the methods that handle and modify the ETag functionality:
    1. Go to the method, FillEntityWithData, and then to the newly added column in the Excel data table.
      Example For example:
      if (!dataRow.IsNull("BankName")){ entity.BankName = dataRow["BankName"].ToString(); }
    2. Open the class, Start of the navigation path UIScreens  Next navigation step SubmitReport  Next navigation step ViewModel  Next navigation step SubmitChangesViewModel.cs End of the navigation path.
    3. Go to the method, GetSAPData.
      Add the following code snippet:
       sapDataRow["BankName"] = recordFromBE.BankName;
    4. Go to the method, UpdateRowValues.
      Add the following code snippet:
      rowToUpdate["BankName"] = recordFromBE.BankName;
  5. Re-build and test your project for the Excel add-in application.