Skip to Content
0
Jan 06, 2016 at 07:34 PM

Help with SplitApp using two entity sets

85 Views

I am currently learning SAPUI5 for my company and am working on my first practical application which we will deploy to our Fiori launchpad. We are using a Split App. What we want the app to do, is for the a given manager, a list of subordinate employees will be listed in a master view, and on click of an employee in the list, a table of their upcoming scheduled absences will be listed in a table in the detail view. We created a gateway service on our ERP side with two entity sets, EmployeeListSet, which has the properties EmployeeNumber and EmployeeName, and EmployeeLeaveDetailSet which has the properties EmployeeNumber, EndDate,StartDate, StartTime, EndTime, LeaveID, LeaveText, AbsentDays and AbsentHours . I was able to bind the EmployeeListSet to the master view, and produce a list of subordinate employees. This was accomplished with the following code:

In employeelist.view.js I have

var oList = new sap.m.List("EmployeeList",{
  mode: jQuery.device.is.phone ?
  sap.m.ListMode.None : sap.m.ListMode.SingleSelectMaster,
//  itemPress : function(oEvent) {  //Item Press Event
//  oController.onSelect(oEvent); },
  includeItemInSelection : true,
  inset : true
  });

  oTemplate = new sap.m.StandardListItem("idItems", {title : "{data>EmployeeName}",
    description: "{data>EmployeeNumber}",
    type : sap.m.ListType.Navigation,
   });

  oList.bindAggregation( "items", {
  path : "data>/EmployeeListSet",
  template: oTemplate
  });

and in employee.controller.js I have

onInit: function() {
  var sUrl1 = "/sap/opu/odata/sap/zhcm_leave_check_srv";
  var oModel = new sap.ui.model.odata.ODataModel(sUrl1, false);
  sap.ui.getCore().byId("EmployeeList").setModel(oModel,"data")
  },

In my detail view, detail.view.js, I have set up a table for employee absence data:

var oTable = new sap.m.Table("EmployeeLeave",  {
inset : true,
  headerText : "List of Absences",
  headerDesign : sap.m.ListHeaderDesign.Standard, 
  mode : sap.m.ListMode.None,
  includeItemInSelection : false,
  });

oTable.addColumn(new sap.m.Column({
            header: new sap.ui.commons.Label({text: "Employee Number"}),
             sortProperty: "EmployeeNumber",
             filterProperty: "EmployeeNumber"
         }));

oTable.addColumn(new sap.m.Column({
            header: new sap.ui.commons.Label({text: "Leave ID"}),
             sortProperty: "LeaveID"
         }));


oTable.addColumn(new sap.m.Column({
            header: new sap.ui.commons.Label({text: "Leave Type"}),
             sortProperty: "LeaveText"
         }));

oTable.addColumn(new sap.m.Column({
  header: new sap.m.Label({text: "Start Date"}),
            sortProperty: "StartDate"
        }));

  oTable.addColumn(new sap.m.Column({
            header: new sap.m.Label({text: "End Date"}),
            sortProperty: "EndDate"
        }));

  oTable.addColumn(new sap.m.Column({
            header: new sap.m.Label({text: "Start Time"}),
            sortProperty: "StartTime"
        }));

  oTable.addColumn(new sap.m.Column({
            header: new sap.ui.commons.Label({text: "End Time"}),
         sortProperty: "EndTime"
        }));

  oTable.addColumn(new sap.m.Column({
           header: new sap.ui.commons.Label({text: "Absent Days"}),
            sortProperty: "AbsentDays"
        }));

  oTable.addColumn(new sap.m.Column({
            header: new sap.m.Label({text: "Absent Hours"}),
        sortProperty: "AbsentHours"
        }));



This is what my application looks like so far:

After this point is where I need some help. Notice that I have the itemPress commented out. I need some help with coding the onSelect function. So what we would like the app to do next, is when a list item is selected, the value of EmployeeNumber needs to be passed to the backend and getEntitySet for EmployeeLeaveDetailSet needs to be called and this needs to return the list of scheduled absences to the table on the UI side.

So, can I get help setting up the onSelect function. How will I get the EmployeeNumber value from the list item selected? How do I set up the data model to send the employee number back to the SAP system? (I have read I can use a filter option, but I have no clue how to set that up correctly.) How do I ensure this data is returned to the table in the detail view? I have spent a great deal of time watching youtube tutorials, and reading help articles but haven't seen a concrete example of how to accomplish what I am trying to achieve. Please help!

Thanks,

Kristen

Attachments

leave.png (35.3 kB)